17 import(
'classes.monograph.Representative');
26 function getById($representativeId, $monographId =
null){
27 $sqlParams = array((
int) $representativeId);
29 $sqlParams[] = (int) $monographId;
34 FROM representatives r
35 JOIN submissions s ON (r.submission_id = s.submission_id)
36 WHERE r.representative_id = ?
37 ' . ($monographId?
' AND s.submission_id = ?':
''),
42 if ($result->RecordCount() != 0) {
43 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
56 'SELECT * FROM representatives WHERE submission_id = ? AND is_supplier = ?', array((
int) $monographId, 1));
68 'SELECT * FROM representatives WHERE submission_id = ? AND is_supplier = ?', array((
int) $monographId, 0));
89 $representative->setId($row[
'representative_id']);
90 $representative->setRole($row[
'role']);
91 $representative->setRepresentativeIdType($row[
'representative_id_type']);
92 $representative->setRepresentativeIdValue($row[
'representative_id_value']);
93 $representative->setName($row[
'name']);
94 $representative->setPhone($row[
'phone']);
95 $representative->setEmail($row[
'email']);
96 $representative->setUrl($row[
'url']);
97 $representative->setIsSupplier($row[
'is_supplier']);
98 $representative->setMonographId($row[
'submission_id']);
100 if ($callHooks)
HookRegistry::call(
'RepresentativeDAO::_fromRow', array(&$representative, &$row));
102 return $representative;
111 'INSERT INTO representatives
112 (submission_id, role, representative_id_type, representative_id_value, name, phone, email, url, is_supplier)
114 (?, ?, ?, ?, ?, ?, ?, ?, ?)',
116 (
int) $representative->getMonographId(),
117 $representative->getRole(),
118 $representative->getRepresentativeIdType(),
119 $representative->getRepresentativeIdValue(),
120 $representative->getName(),
121 $representative->getPhone(),
122 $representative->getEmail(),
123 $representative->getUrl(),
124 (
int) $representative->getIsSupplier()
129 return $representative->getId();
138 'UPDATE representatives
140 representative_id_type = ?,
141 representative_id_value = ?,
147 WHERE representative_id = ?',
149 $representative->getRole(),
150 $representative->getRepresentativeIdType(),
151 $representative->getRepresentativeIdValue(),
152 $representative->getName(),
153 $representative->getPhone(),
154 $representative->getEmail(),
155 $representative->getUrl(),
156 (
int) $representative->getIsSupplier(),
157 (
int) $representative->getId()
167 return $this->
deleteById($representative->getId());
176 'DELETE FROM representatives WHERE representative_id = ?', (
int) $entryId
185 return $this->
_getInsertId(
'representatives',
'representative_id');