[ Index ] |
PHP Cross Reference of Eventum |
[Summary view] [Print] [Text view]
1 <?php 2 /* vim: set expandtab tabstop=4 shiftwidth=4 encoding=utf-8: */ 3 // +----------------------------------------------------------------------+ 4 // | Eventum - Issue Tracking System | 5 // +----------------------------------------------------------------------+ 6 // | Copyright (c) 2003, 2004, 2005, 2006, 2007 MySQL AB | 7 // | | 8 // | This program is free software; you can redistribute it and/or modify | 9 // | it under the terms of the GNU General Public License as published by | 10 // | the Free Software Foundation; either version 2 of the License, or | 11 // | (at your option) any later version. | 12 // | | 13 // | This program is distributed in the hope that it will be useful, | 14 // | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 // | GNU General Public License for more details. | 17 // | | 18 // | You should have received a copy of the GNU General Public License | 19 // | along with this program; if not, write to: | 20 // | | 21 // | Free Software Foundation, Inc. | 22 // | 59 Temple Place - Suite 330 | 23 // | Boston, MA 02111-1307, USA. | 24 // +----------------------------------------------------------------------+ 25 // | Authors: Bryan Alsdorf <bryan@mysql.com> | 26 // +----------------------------------------------------------------------+ 27 // 28 29 require_once (APP_INC_PATH . "customer/class.abstract_customer_backend.php"); 30 require_once (APP_INC_PATH . "class.date.php"); 31 32 /** 33 * Example customer backend. This does not cover all functionality, but should provide an idea 34 * on how to implement a backend. 35 * 36 * @author Bryan Alsdorf <bryan@mysql.com> 37 */ 38 class Example_Customer_Backend extends Abstract_Customer_Backend 39 { 40 // array of customer data used for this example 41 var $data; 42 43 /** 44 * Overide the connect method to populate a variable instead of connecting to a database 45 */ 46 function connect() 47 { 48 $this->data = array( 49 1 => array( 50 "customer_id" => 1, 51 "customer_name" => "Bryan's widget factory", 52 "start_date" => '2004-03-10', 53 "expiration_date" => '2010-03-10', 54 "contacts" => array( 55 array( 56 'contact_id' => 87, 57 'first_name' => 'Bryan', 58 'last_name' => 'Alsdorf', 59 'email' => 'bryan@example.com', 60 'phone' => '+1 (123) 456-7890' 61 ), 62 array( 63 'contact_id' => 93, 64 'first_name' => 'Bob', 65 'last_name' => 'Smith', 66 'email' => 'bob@example.com', 67 'phone' => '+1 (123) 456-7890' 68 ) 69 ), 70 "address" => "1234 Blah Street,\nHouston, TX 12345", 71 "support_level_id" => 1, 72 "account_manager" => array("Sales guy", "Salesguy@example.com") 73 ), 74 2 => array( 75 "customer_id" => 2, 76 "customer_name" => "Joao, Inc.", 77 "start_date" => '2004-08-01', 78 "expiration_date" => '2005-08-01', 79 "contacts" => array( 80 array( 81 'contact_id' => 67, 82 'first_name' => 'Joao', 83 'last_name' => 'Prado Maia', 84 'email' => 'jpm@example.com', 85 'phone' => '+1 (123) 456-7890' 86 ) 87 ), 88 "address" => "123 Fake Street,\nSpringfield, USA", 89 "support_level_id" => 3, 90 "account_manager" => array("Sales guy", "Salesguy@example.com") 91 ), 92 3 => array( 93 "customer_id" => 3, 94 "customer_name" => "Example Corp.", 95 "start_date" => '2002-01-01', 96 "expiration_date" => '2006-01-01', 97 "contacts" => array( 98 array( 99 'contact_id' => 21, 100 'first_name' => 'J', 101 'last_name' => 'Man', 102 'email' => 'j-man@example.com', 103 'phone' => '+1 (123) 456-7890' 104 ), 105 array( 106 'contact_id' => 22, 107 'first_name' => 'John', 108 'last_name' => 'Doe', 109 'email' => 'John.Doe@example.com', 110 'phone' => '+1 (123) 456-7890' 111 ) 112 ), 113 "address" => "56789 Some drive,\nFooo, Foo 12345", 114 "support_level_id" => 4, 115 "account_manager" => array("Sales guy", "Salesguy@example.com") 116 ) 117 ); 118 } 119 120 121 /** 122 * Returns the name of the backend 123 * 124 * @return string The name of the backend 125 */ 126 function getName() 127 { 128 return "example"; 129 } 130 131 132 /** 133 * Returns true if the backend uses support levels, false otherwise 134 * 135 * @access public 136 * @return boolean True if the project uses support levels. 137 */ 138 function usesSupportLevels() 139 { 140 // this example will use support levels so override parent method 141 return true; 142 } 143 144 145 /** 146 * Returns the contract status associated with the given customer ID. 147 * Possible return values are 'active', 'in_grace_period' and 'expired'. 148 * 149 * @access public 150 * @param integer $customer_id The customer ID 151 * @return string The contract status 152 */ 153 function getContractStatus($customer_id) 154 { 155 // active contracts have an expiration date in the future 156 $expiration = strtotime($this->data[$customer_id]['expiration_date']); 157 $now = Date_API::getCurrentUnixTimestampGMT(); 158 if ($expiration > $now) { 159 return 'active'; 160 } elseif ($expiration > ($now + (DAY * $this->getExpirationOffset()))) { 161 return 'in_grace_period'; 162 } else { 163 return 'expired'; 164 } 165 } 166 167 168 /** 169 * Retrieves the customer titles associated with the given list of issues. 170 * 171 * @access public 172 * @param array $result The list of issues 173 * @see Issue::getListing() 174 */ 175 function getCustomerTitlesByIssues(&$result) 176 { 177 if (count($result) > 0) { 178 for ($i = 0; $i < count($result); $i++) { 179 if (!empty($result[$i]["iss_customer_id"])) { 180 $result[$i]["customer_title"] = $this->getTitle($result[$i]["iss_customer_id"]); 181 } 182 } 183 } 184 } 185 186 187 /** 188 * Retrieves the support levels associated with the given list of issues. 189 * 190 * @access public 191 * @param array $result The list of issues 192 * @see Issue::getListing() 193 */ 194 function getSupportLevelsByIssues(&$result) 195 { 196 if (count($result) > 0) { 197 $support_levels = $this->getSupportLevelAssocList(); 198 for ($i = 0; $i < count($result); $i++) { 199 if (!empty($result[$i]["iss_customer_id"])) { 200 $result[$i]["support_level"] = @$support_levels[$this->getSupportLevelID($result[$i]['iss_customer_id'])]; 201 } 202 } 203 } 204 } 205 206 207 /** 208 * Method used to get the details of the given customer. 209 * 210 * @access public 211 * @param integer $customer_id The customer ID 212 * @param boolean $force_refresh If the cache should not be used. 213 * @param integer $contract_id The contract ID 214 * @return array The customer details 215 */ 216 function getDetails($customer_id, $force_refresh = false, $contract_id = false) 217 { 218 $support_levels = $this->getSupportLevelAssocList(); 219 $details = $this->data[$customer_id]; 220 $details["support_level"] = $support_levels[$details["support_level_id"]]; 221 $details["contract_status"] = $this->getContractStatus($customer_id); 222 $details["note"] = Customer::getNoteDetailsByCustomer($customer_id); 223 return $details; 224 } 225 226 227 // PLEASE NOTE: 228 // This example does not implement per-incident 229 // support so those methods will not be included here 230 231 232 /** 233 * Returns a list of customers (companies) in the customer database. 234 * 235 * @access public 236 * @return array An associated array of customers. 237 */ 238 function getAssocList() 239 { 240 $assoc = array(); 241 foreach ($this->data as $id => $details) { 242 $assoc[$id] = $details["customer_name"]; 243 } 244 return $assoc; 245 } 246 247 248 /** 249 * Method used to get the customer names for the given customer id. 250 * 251 * @access public 252 * @param integer $customer_id The customer ID 253 * @return string The customer name 254 */ 255 function getTitle($customer_id) 256 { 257 return $this->data[$customer_id]["customer_name"]; 258 } 259 260 261 /** 262 * Method used to get an associative array of the customer names 263 * for the given list of customer ids. 264 * 265 * @access public 266 * @param array $customer_ids The list of customers 267 * @return array The associative array of customer id => customer name 268 */ 269 function getTitles($customer_ids) 270 { 271 $assoc = array(); 272 foreach ($this->data as $id => $details) { 273 if (in_array($id, $customer_ids)) { 274 $assoc[$id] = $details["customer_name"]; 275 } 276 } 277 return $assoc; 278 } 279 280 281 /** 282 * Method used to get the list of email addresses associated with the 283 * contacts of a given customer. 284 * 285 * @access public 286 * @param integer $customer_id The customer ID 287 * @return array The list of email addresses 288 */ 289 function getContactEmailAssocList($customer_id) 290 { 291 $assoc = array(); 292 foreach ($this->data[$customer_id]['contacts'] as $key => $contact) { 293 $assoc[] = $contact["email"]; 294 } 295 return $assoc; 296 } 297 298 299 /** 300 * Method used to get the customer and customer contact IDs associated 301 * with a given list of email addresses. 302 * 303 * @access public 304 * @param array $emails The list of email addresses 305 * @return array The customer and customer contact ID 306 */ 307 function getCustomerIDByEmails($emails) 308 { 309 $assoc = array(); 310 foreach ($this->data as $company_id => $details) { 311 foreach ($details['contacts'] as $contact) { 312 // in a perfect world you would want to do partial searches 313 // here, but as an example in_array() will do 314 if (in_array($contact["email"], $emails)) { 315 return array($company_id, $contact['contact_id']); 316 } 317 } 318 } 319 return $assoc; 320 } 321 322 323 /** 324 * Method used to get the overall statistics of issues in the system for a 325 * given customer. 326 * 327 * @access public 328 * @param integer $customer_id The customer ID 329 * @return array The customer related issue statistics 330 */ 331 function getOverallStats($customer_id) 332 { 333 // don't count customer notes, emails, phone calls 334 $stmt = "SELECT 335 iss_id, 336 sta_is_closed 337 FROM 338 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue 339 LEFT JOIN 340 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 341 ON 342 iss_sta_id=sta_id 343 WHERE 344 iss_customer_id=$customer_id"; 345 $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt); 346 if ((PEAR::isError($res)) || (empty($res)) || (count($res) == 0)) { 347 return array( 348 'total_issues' => 0, 349 'total_open' => 0, 350 'total_closed' => 0, 351 'total_persons' => 0, 352 'total_emails' => 0, 353 'total_calls' => 0, 354 'average_first_response' => 0, 355 'average_close' => 0 356 ); 357 } else { 358 $issues = array(); 359 $open = 0; 360 $closed = 0; 361 foreach ($res as $issue_id => $status) { 362 $issues[] = $issue_id; 363 if (empty($status)) { 364 $open++; 365 } else { 366 $closed++; 367 } 368 } 369 } 370 371 // get the list of distinct persons from the notification 372 // list, phone support and notes tables 373 $stmt = "SELECT 374 iss_id, 375 sub_usr_id, 376 not_usr_id, 377 phs_usr_id 378 FROM 379 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue 380 LEFT JOIN 381 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note 382 ON 383 not_iss_id=iss_id 384 LEFT JOIN 385 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support 386 ON 387 phs_iss_id=iss_id 388 LEFT JOIN 389 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription 390 ON 391 sub_iss_id=iss_id AND 392 sub_usr_id <> 0 AND 393 sub_usr_id IS NOT NULL 394 LEFT JOIN 395 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription_type 396 ON 397 sbt_sub_id=sub_id AND 398 sbt_type='emails' 399 WHERE 400 iss_customer_id=$customer_id"; 401 $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC); 402 $persons = array(); 403 for ($i = 0; $i < count($res); $i++) { 404 if ((!empty($res[$i]['sub_usr_id'])) && (!in_array($res[$i]['sub_usr_id'], $persons))) { 405 $persons[] = $res[$i]['sub_usr_id']; 406 } 407 if ((!empty($res[$i]['not_usr_id'])) && (!in_array($res[$i]['not_usr_id'], $persons))) { 408 $persons[] = $res[$i]['not_usr_id']; 409 } 410 if ((!empty($res[$i]['phs_usr_id'])) && (!in_array($res[$i]['phs_usr_id'], $persons))) { 411 $persons[] = $res[$i]['phs_usr_id']; 412 } 413 } 414 415 // get list of staff emails 416 $stmt = "SELECT 417 usr_email 418 FROM 419 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user, 420 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_user, 421 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue 422 WHERE 423 pru_usr_id=usr_id AND 424 pru_prj_id=iss_prj_id AND 425 iss_id=$issue_id AND 426 pru_role <> " . User::getRoleID('Customer'); 427 $staff_emails = $GLOBALS["db_api"]->dbh->getCol($stmt); 428 429 $stmt = "SELECT 430 sup_from 431 FROM 432 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email 433 WHERE 434 sup_iss_id IN (" . implode(", ", $issues) . ")"; 435 $emails = $GLOBALS["db_api"]->dbh->getCol($stmt); 436 $total_emails = 0; 437 foreach ($emails as $address) { 438 $email = strtolower(Mail_API::getEmailAddress($address)); 439 $staff_emails = array_map('strtolower', $staff_emails); 440 if (@in_array($email, $staff_emails)) { 441 $total_emails++; 442 } 443 } 444 445 $stmt = "SELECT 446 COUNT(*) 447 FROM 448 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support 449 WHERE 450 phs_iss_id IN (" . implode(", ", $issues) . ")"; 451 $calls = $GLOBALS["db_api"]->dbh->getOne($stmt); 452 453 $stmt = "SELECT 454 AVG(UNIX_TIMESTAMP(iss_first_response_date) - UNIX_TIMESTAMP(iss_created_date)) AS first_response_time 455 FROM 456 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue 457 WHERE 458 iss_id IN (" . implode(", ", $issues) . ")"; 459 $avg_first_response = $GLOBALS["db_api"]->dbh->getOne($stmt); 460 if (!empty($avg_first_response)) { 461 // format the average into a number of minutes 462 $avg_first_response = $avg_first_response / 60; 463 } 464 465 $stmt = "SELECT 466 AVG(UNIX_TIMESTAMP(iss_closed_date) - UNIX_TIMESTAMP(iss_created_date)) AS closed_time 467 FROM 468 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue 469 WHERE 470 iss_id IN (" . implode(", ", $issues) . ")"; 471 $avg_close = $GLOBALS["db_api"]->dbh->getOne($stmt); 472 if (!empty($avg_close)) { 473 // format the average into a number of minutes 474 $avg_close = $avg_close / 60; 475 } 476 477 return array( 478 'total_issues' => count($issues), 479 'total_open' => $open, 480 'total_closed' => $closed, 481 'total_persons' => count($persons), 482 'total_emails' => $total_emails, 483 'total_calls' => (integer) $calls, 484 'average_first_response' => Misc::getFormattedTime($avg_first_response), 485 'average_close' => Misc::getFormattedTime($avg_close) 486 ); 487 } 488 489 490 /** 491 * Method used to build the overall customer profile from the information 492 * stored in the customer database. 493 * 494 * @access public 495 * @param integer $usr_id The Eventum user ID 496 * @return array The customer profile information 497 */ 498 function getProfile($usr_id) 499 { 500 // this is used to return all details about the customer/contact in one fell swoop. 501 // for this example it will just return the details 502 return $this->getDetails(User::getCustomerID($usr_id)); 503 } 504 505 506 /** 507 * Method used to get the details associated with a customer contact. 508 * 509 * @access public 510 * @param integer $contact_id The customer contact ID 511 * @return array The contact details 512 */ 513 function getContactDetails($contact_id) 514 { 515 $assoc = array(); 516 foreach ($this->data as $company_id => $details) { 517 foreach ($details['contacts'] as $contact) { 518 if ($contact['contact_id'] == $contact_id) { 519 $contact['customer_id'] = $company_id; 520 return $contact; 521 } 522 } 523 } 524 return $assoc; 525 } 526 527 528 /** 529 * Returns the list of customer IDs that are associated with the given 530 * email value (wildcards welcome). Contrary to the name of the method, this 531 * also works with customer names 532 * 533 * @access public 534 * @param string $email The email value 535 * @return array The list of customer IDs 536 */ 537 function getCustomerIDsLikeEmail($email) 538 { 539 $ids = array(); 540 foreach ($this->data as $customer) { 541 if (stristr($customer['customer_name'], $email) !== false) { 542 $ids[] = $customer['customer_id']; 543 continue; 544 } 545 546 foreach ($customer['contacts'] as $contact) { 547 if (stristr($contact['email'], $email) !== false) { 548 $ids[] = $customer['customer_id']; 549 } 550 } 551 } 552 return $ids; 553 } 554 555 556 /** 557 * Performs a customer lookup and returns the matches, if 558 * appropriate. 559 * 560 * @access public 561 * @param string $field The field that we are trying to search against 562 * @param string $value The value that we are searching for 563 * @return array The list of customers 564 */ 565 function lookup($field, $value) 566 { 567 if ($field == "email") { 568 $details = $this->getCustomerIDsLikeEmail($value); 569 if (count($details) > 0) { 570 list($id, $contact_id) = $details; 571 } else { 572 $id = 0; 573 } 574 } elseif ($field == "customer_id") { 575 if (empty($this->data[$value])) { 576 $id = 0; 577 } else { 578 $id = $value; 579 } 580 } 581 if ($id > 0) { 582 return array($this->getDetails($id)); 583 } 584 } 585 586 587 /** 588 * Method used to notify the customer contact that a new issue was just 589 * created and associated with his Eventum user. 590 * 591 * @access public 592 * @param integer $issue_id The issue ID 593 * @param integer $contact_id The customer contact ID 594 * @return void 595 */ 596 function notifyCustomerIssue($issue_id, $contact_id) 597 { 598 // send a notification email to your customer here 599 } 600 601 602 /** 603 * Method used to get the list of available support levels. 604 * 605 * @access public 606 * @return array The list of available support levels 607 */ 608 function getSupportLevelAssocList() 609 { 610 return array( 611 1 => "Normal 1", 612 2 => "Normal 2", 613 3 => "Enhanced", 614 4 => "Ultra-Special" 615 ); 616 } 617 618 619 /** 620 * Returns the support level of the current support contract for a given 621 * customer ID. 622 * 623 * @access public 624 * @param integer $customer_id The customer ID 625 * @return string The support contract level 626 */ 627 function getSupportLevelID($customer_id) 628 { 629 return $this->data[$customer_id]["support_level_id"]; 630 } 631 632 633 /** 634 * Returns the list of customer IDs for a given support contract level. 635 * 636 * @access public 637 * @param integer/array $support_level_id The support level ID or an array of support level IDs 638 * @param mixed $support_options An integer or array of integers indicating various options to get customers with. 639 * @return array The list of customer IDs 640 */ 641 function getListBySupportLevel($support_level_id, $support_options = false) 642 { 643 if (!is_array($support_level_id)) { 644 $support_level_id = array($support_level_id); 645 } 646 $assoc = array(); 647 foreach ($this->data as $company_id => $details) { 648 if (in_array($details["support_level_id"], $support_level_id)) { 649 $assoc[] = $company_id; 650 } 651 } 652 return $assoc; 653 } 654 655 656 /** 657 * Returns an array of support levels grouped together. 658 * 659 * @access public 660 * @return array an array of support levels. 661 */ 662 function getGroupedSupportLevels() 663 { 664 return array( 665 "Normal" => array(1,2), 666 "Enhanced" => array(3), 667 "Ultra-Special" => array(4) 668 ); 669 } 670 671 672 /** 673 * Checks whether the given technical contact ID is allowed in the current 674 * support contract or not. 675 * 676 * @access public 677 * @param integer $customer_contact_id The customer technical contact ID 678 * @return boolean 679 */ 680 function isAllowedSupportContact($customer_contact_id) 681 { 682 foreach ($this->data as $id => $details) { 683 foreach ($details['contacts'] as $contact) { 684 if ($contact['contact_id'] == $customer_contact_id) { 685 return true; 686 } 687 } 688 } 689 return false; 690 } 691 692 693 /** 694 * Method used to get the associated customer and customer contact from 695 * a given set of support emails. This is especially useful to automatically 696 * associate an issue to the appropriate customer contact that sent a 697 * support email. 698 * 699 * @access public 700 * @param array $sup_ids The list of support email IDs 701 * @return array The customer and customer contact ID 702 */ 703 function getCustomerInfoFromEmails($sup_ids) 704 { 705 $senders = Support::getSender($sup_ids); 706 if (count($senders) > 0) { 707 $emails = array(); 708 for ($i = 0; $i < count($senders); $i++) { 709 $emails[] = Mail_API::getEmailAddress($senders[$i]); 710 } 711 list($customer_id, $contact_id) = $this->getCustomerIDByEmails($emails); 712 $company = $this->getDetails($customer_id); 713 $contact = $this->getContactDetails($contact_id); 714 return array( 715 'customer_id' => $customer_id, 716 'customer_name' => $company['customer_name'], 717 'contact_id' => $contact_id, 718 'contact_name' => $contact['first_name'] . " " . $contact['last_name'], 719 'contacts' => $this->getContactEmailAssocList($customer_id) 720 ); 721 } else { 722 return array( 723 'customer_id' => '', 724 'customer_name' => '', 725 'contact_id' => '', 726 'contact_name' => '', 727 'contacts' => '' 728 ); 729 } 730 } 731 732 733 /** 734 * Method used to get the customer login grace period (number of days). 735 * 736 * @access public 737 * @return integer The customer login grace period 738 */ 739 function getExpirationOffset() 740 { 741 // customers can log in up to 30 days after the contract expires. 742 return 30; 743 } 744 745 746 /** 747 * Method used to get the details of the given customer contact. 748 * 749 * @access public 750 * @param integer $contact_id The customer contact ID 751 * @return array The customer details 752 */ 753 function getContactLoginDetails($contact_id) 754 { 755 $stmt = "SELECT 756 usr_email, 757 usr_password, 758 usr_full_name 759 FROM 760 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user 761 WHERE 762 usr_customer_contact_id = $contact_id"; 763 $res = $GLOBALS["db_api"]->dbh->getRow($stmt); 764 if (PEAR::isError($res)) { 765 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 766 return -1; 767 } else { 768 if (empty($res)) { 769 return -2; 770 } else { 771 return $res; 772 } 773 } 774 } 775 776 777 /** 778 * Returns the end date of the current support contract for a given 779 * customer ID. 780 * 781 * @access public 782 * @param integer $customer_id The customer ID 783 * @return string The support contract end date 784 */ 785 function getContractEndDate($customer_id) 786 { 787 return $this->data[$customer_id]['expiration_date']; 788 } 789 790 791 /** 792 * Returns the name and email of the sales account manager of the given customer ID. 793 * 794 * @access public 795 * @param integer $customer_id The customer ID 796 * @return array An array containing the name and email of the sales account manager 797 */ 798 function getSalesAccountManager($customer_id) 799 { 800 return $this->data[$customer_id]['account_manager']; 801 } 802 803 804 /** 805 * Returns the start date of the current support contract for a given 806 * customer ID. 807 * 808 * @access public 809 * @param integer $customer_id The customer ID 810 * @return string The support contract start date 811 */ 812 function getContractStartDate($customer_id) 813 { 814 return $this->data[$customer_id]['start_date']; 815 } 816 817 818 /** 819 * Returns a message to be displayed to a customer on the top of the issue creation page. 820 * 821 * @param array $customer_id Customer ID. 822 */ 823 function getNewIssueMessage($customer_id) 824 { 825 // we could do anything we wanted in here, but we will just say "hi" 826 return "Hi! Please create a new issue"; 827 } 828 829 830 /** 831 * Checks whether the given customer has a support contract that 832 * enforces limits for the minimum first response time or not. 833 * 834 * @access public 835 * @param integer $customer_id The customer ID 836 * @return boolean 837 */ 838 function hasMinimumResponseTime($customer_id) 839 { 840 $support_level = $this->getSupportLevelID($customer_id); 841 if ($support_level == 1 || $support_level == 2) { 842 return true; 843 } 844 } 845 846 847 /** 848 * Returns the minimum first response time in seconds for the 849 * support level associated with the given customer. 850 * 851 * @access public 852 * @param integer $customer_id The customer ID 853 * @return integer The minimum first response time 854 */ 855 function getMinimumResponseTime($customer_id) 856 { 857 // normal level customers will not recieve a response for atleast a day 858 $support_level = $this->getSupportLevelID($customer_id); 859 if ($support_level == 1 || $support_level == 2) { 860 return (60 * 60 * 24); 861 } 862 } 863 864 865 /** 866 * Returns the maximum first response time associated with the 867 * support contract of the given customer. 868 * 869 * @access public 870 * @param integer $customer_id The customer ID 871 * @return integer The maximum first response time, in seconds 872 */ 873 function getMaximumFirstResponseTime($customer_id) 874 { 875 $support_level = $this->getSupportLevelID($customer_id); 876 if ($support_level == 1 || $support_level == 2) { 877 // 2 days for normal 878 return (60 * 60 * 24 * 2); 879 } elseif ($support_level == 3) { 880 // 1 day for special 881 return (60 * 60 * 24); 882 } elseif ($support_level == 4) { 883 // 30 minutes for special 884 return (60 *30); 885 } 886 } 887 888 889 /** 890 * Method used to send an expiration notice. 891 * 892 * @access public 893 * @param integer $contact_id The customer contact ID 894 * @param boolean $is_expired Whether this customer is expired or not 895 * @return void 896 */ 897 function sendExpirationNotice($contact_id, $is_expired = FALSE) 898 { 899 // send a support expiration notice email to your customer here 900 } 901 902 903 /** 904 * Method used to notify the customer contact that an existing issue 905 * associated with him was just marked as closed. 906 * 907 * @access public 908 * @param integer $issue_id The issue ID 909 * @param integer $contact_id The customer contact ID 910 * @return void 911 */ 912 function notifyIssueClosed($issue_id, $contact_id) 913 { 914 // send a notification email to your customer here 915 } 916 917 918 /** 919 * Method used to send an email notification to the sender of a 920 * set of email messages that were manually converted into an 921 * issue. 922 * 923 * @access public 924 * @param integer $issue_id The issue ID 925 * @param array $sup_ids The email IDs 926 * @param integer $customer_id The customer ID 927 * @return array The list of recipient emails 928 */ 929 function notifyEmailConvertedIntoIssue($issue_id, $sup_ids, $customer_id = FALSE) 930 { 931 // send a notification email to your customer here 932 } 933 934 935 /** 936 * Method used to send an email notification to the sender of an 937 * email message that was automatically converted into an issue. 938 * 939 * @access public 940 * @param integer $issue_id The issue ID 941 * @param string $sender The sender of the email message (and the recipient of this notification) 942 * @param string $date The arrival date of the email message 943 * @param string $subject The subject line of the email message 944 * @return void 945 */ 946 function notifyAutoCreatedIssue($issue_id, $sender, $date, $subject) 947 { 948 // send a notification email to your customer here 949 } 950 951 952 /** 953 * Method used to get the contract details for a given customer contact. 954 * 955 * @access public 956 * @param integer $contact_id The customer contact ID 957 * @return array The customer contract details 958 */ 959 function getContractDetails($contact_id, $restrict_expiration) 960 { 961 $contact = $this->getContactDetails($contact_id); 962 $customer = $this->getDetails($contact['customer_id']); 963 $support_levels = $this->getSupportLevelAssocList(); 964 965 return array( 966 'contact_name' => $contact['first_name'] . ' ' . $contact['last_name'], 967 'company_name' => $customer['customer_name'], 968 'contract_id' => $customer['customer_id'], 969 'support_level' => $support_levels[$customer['support_level_id']], 970 'expiration_date' => $customer['expiration_date'] 971 ); 972 } 973 974 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 19 21:21:33 2007 | Cross-referenced by PHPXref 0.7 |