60
53
* Constructs the customer object and loads customer and support option data.
63
* @param integer $customer_id
56
* @param string $customer_id
57
* @throws CustomerNotFoundException
64
58
* @see Customer::load();
66
60
function __construct(CRM &$crm, $customer_id)
69
$this->connection = &$crm->getConnection();
63
$this->connection =& $crm->getConnection();
70
64
$this->customer_id = $customer_id;
72
66
// attempt to load the data
78
* Convenience method for setting all customer data at once. This probably is only used by batch
79
* scripts setting up customers.
82
* @param string $country
83
* @param string $account_manager
85
public function setData($name, $country, $account_manager)
88
$this->country = $country;
89
$this->account_manager = $account_manager;
94
* Saves the object to the database. Returns true on success, PEAR_Error otherwise.
96
* @return mixed True on success, PEAR_Error otherwise.
98
abstract public function save();
102
* Loads customer information into the object. This method must set
103
* this->exists to true if the customer exists and set it to false if
106
* @see Customer::exists
72
* Loads customer information into the object.
74
* @throws CustomerNotFoundException
108
76
abstract protected function load();
112
* Returns a Contract object representing the contract for the
113
* given contract ID. This should ONLY return contracts for the
116
* @param integer $contract_id
117
* @return Contract The Contract object for the given contract ID
119
abstract public function &getContract($contract_id);
123
80
* Returns an array of contracts for this customer.
125
* @param mixed Options An array of options that determine which contracts should be returned. For Legacy purposes, if this
126
* is boolean then it will be used to indicate if only active contracts should be returned.
82
* @param mixed Options An array of options that determine which contracts should be returned.
127
83
* @return Contract[] An array of Contract objects
129
abstract public function getContracts($options = false);
133
* Returns a Contact object representing the contact for the
134
* given contact ID. This should ONLY return contacts for the
137
* @param integer $contact_id
138
* @return Contact The Contact object for the given contact ID
140
abstract public function &getContact($contact_id);
85
abstract public function getContracts($options = array());
162
107
abstract public function getDetails();
166
* Returns an array of the currently redeemed incident types for the issue.
168
* @param integer $issue_id The issue ID
169
* @return array An array containing the redeemed incident types
171
public function getRedeemedIncidentDetails($issue_id)
173
$types = $this->crm->getIncidentTypes();
175
foreach ($types as $id => $title) {
176
if ($this->isRedeemedIncident($issue_id, $id)) {
188
* Method used to get the overall statistics of issues in the system for a
191
* @param mixed $contract_ids
192
* @return array The customer related issue statistics
194
abstract public function getOverallStats($contract_ids);
198
* Returns a log of activity for a given customer
200
* @param integer $limit The max number of log items to return
203
abstract public function getLog($limit = 200);
110
* Returns a message to be displayed to a customer on the top of the issue creation page.
114
abstract public function getNewIssueMessage();
119
// * Method used to get the overall statistics of issues in the system for a
122
// * @param mixed $contract_ids
123
// * @return array The customer related issue statistics
125
// abstract public function getOverallStats($contract_ids);
205
127
public function getCustomerID()
212
134
return $this->name;
215
public function exists()
217
return $this->exists;
221
public function getCRM()
226
public function getConnection()
228
return $this->connection;
137
public function getAccountManager()
139
// TODO: Figure out what this should return. Name, email, user ID, etc?
140
return $this->account_manager;
233
144
* String representation of this object
239
150
return "ID: " . $this->customer_id . "\n" .
240
151
"Name: " . $this->name . "\n";
156
* Returns any notes for for the specified customer.
158
* @return array An array containing the note details.
160
function getNoteDetails()
168
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "customer_note
170
cno_customer_id = '" . Misc::escapeString($this->customer_id) . "'";
171
$res = DB_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
172
if (PEAR::isError($res)) {
173
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
182
* Method used to get the list of technical account managers for
183
* a given customer ID.
185
* @return array The list of account managers
187
public function getEventumAccountManagers()
194
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "customer_account_manager,
195
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
197
cam_usr_id=usr_id AND
200
$res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC, array($this->crm->getProjectID(),
201
$this->customer_id));
202
if (PEAR::isError($res)) {
203
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
216
class CustomerNotFoundException extends CRMException
218
public function __construct($customer_id, Exception $previous=null) {
219
parent::__construct("Customer '" . $customer_id . "' not found", 0, $previous);
b'\\ No newline at end of file'