00001 <?php
00002
00016
00017
00018
00022 define('SUBSCRIPTION_TYPE_FORMAT_ONLINE', 0x01);
00023 define('SUBSCRIPTION_TYPE_FORMAT_PRINT', 0x10);
00024 define('SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE', 0x11);
00025
00026
00027 class SubscriptionType extends DataObject {
00028
00029
00030
00031
00036 function getTypeId() {
00037 return $this->getData('typeId');
00038 }
00039
00044 function setTypeId($typeId) {
00045 return $this->setData('typeId', $typeId);
00046 }
00047
00052 function getJournalId() {
00053 return $this->getData('journalId');
00054 }
00055
00060 function setJournalId($journalId) {
00061 return $this->setData('journalId', $journalId);
00062 }
00063
00068 function getSubscriptionTypeName() {
00069 return $this->getLocalizedData('name');
00070 }
00071
00077 function getName($locale) {
00078 return $this->getData('name', $locale);
00079 }
00080
00086 function setName($name, $locale) {
00087 return $this->setData('name', $name, $locale);
00088 }
00089
00094 function getSubscriptionTypeDescription() {
00095 return $this->getLocalizedData('description');
00096 }
00097
00103 function getDescription($locale) {
00104 return $this->getData('description', $locale);
00105 }
00106
00112 function setDescription($description, $locale) {
00113 return $this->setData('description', $description, $locale);
00114 }
00115
00120 function getCost() {
00121 return $this->getData('cost');
00122 }
00123
00128 function setCost($cost) {
00129 return $this->setData('cost', $cost);
00130 }
00131
00136 function getCurrencyCodeAlpha() {
00137 return $this->getData('currencyCodeAlpha');
00138 }
00139
00144 function setCurrencyCodeAlpha($currencyCodeAlpha) {
00145 return $this->setData('currencyCodeAlpha', $currencyCodeAlpha);
00146 }
00147
00152 function getCurrencyString() {
00153 $currencyDao = &DAORegistry::getDAO('CurrencyDAO');
00154 $currency =& $currencyDao->getCurrencyByAlphaCode($this->getData('currencyCodeAlpha'));
00155
00156 if ($currency != null) {
00157 return $currency->getName();
00158 } else {
00159 return 'manager.subscriptionTypes.currency';
00160 }
00161 }
00162
00167 function getCurrencyStringShort() {
00168 $currencyDao = &DAORegistry::getDAO('CurrencyDAO');
00169 $currency =& $currencyDao->getCurrencyByAlphaCode($this->getData('currencyCodeAlpha'));
00170
00171 if ($currency != null) {
00172 return $currency->getCodeAlpha();
00173 } else {
00174 return 'manager.subscriptionTypes.currency';
00175 }
00176 }
00177
00182 function getDuration() {
00183 return $this->getData('duration');
00184 }
00185
00190 function setDuration($duration) {
00191 return $this->setData('duration', $duration);
00192 }
00193
00198 function getDurationYearsMonths() {
00199 $years = (int)floor($this->getData('duration')/12);
00200 $months = (int)fmod($this->getData('duration'), 12);
00201 $yearsMonths = '';
00202
00203 if ($years == 1) {
00204 $yearsMonths = '1 ' . Locale::Translate('manager.subscriptionTypes.year');
00205 } elseif ($years > 1) {
00206 $yearsMonths = $years . ' ' . Locale::Translate('manager.subscriptionTypes.years');
00207 }
00208
00209 if ($months == 1) {
00210 $yearsMonths .= $yearsMonths == '' ? '1 ' : ' 1 ';
00211 $yearsMonths .= Locale::Translate('manager.subscriptionTypes.month');
00212 } elseif ($months > 1){
00213 $yearsMonths .= $yearsMonths == '' ? $months . ' ' : ' ' . $months . ' ';
00214 $yearsMonths .= Locale::Translate('manager.subscriptionTypes.months');
00215 }
00216
00217 return $yearsMonths;
00218 }
00219
00224 function getFormat() {
00225 return $this->getData('format');
00226 }
00227
00232 function setFormat($format) {
00233 return $this->setData('format', $format);
00234 }
00235
00240 function getFormatString() {
00241 switch ($this->getData('format')) {
00242 case SUBSCRIPTION_TYPE_FORMAT_ONLINE:
00243 return 'manager.subscriptionTypes.format.online';
00244 case SUBSCRIPTION_TYPE_FORMAT_PRINT:
00245 return 'manager.subscriptionTypes.format.print';
00246 case SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE:
00247 return 'manager.subscriptionTypes.format.printOnline';
00248 default:
00249 return 'manager.subscriptionTypes.format';
00250 }
00251 }
00252
00257 function getInstitutional() {
00258 return $this->getData('institutional');
00259 }
00260
00265 function setInstitutional($institutional) {
00266 return $this->setData('institutional', $institutional);
00267 }
00268
00273 function getMembership() {
00274 return $this->getData('membership');
00275 }
00276
00281 function setMembership($membership) {
00282 return $this->setData('membership', $membership);
00283 }
00284
00289 function getDisablePublicDisplay() {
00290 return $this->getData('disable_public_display');
00291 }
00292
00297 function setDisablePublicDisplay($disablePublicDisplay) {
00298 return $this->setData('disable_public_display', $disablePublicDisplay);
00299 }
00300
00305 function getSequence() {
00306 return $this->getData('sequence');
00307 }
00308
00313 function setSequence($sequence) {
00314 return $this->setData('sequence', $sequence);
00315 }
00316
00321 function getSummaryString() {
00322 return $this->getSubscriptionTypeName() . ' - ' . $this->getDurationYearsMonths() . ' - ' . sprintf('%.2f', $this->getCost()) . ' ' . $this->getCurrencyStringShort();
00323 }
00324 }
00325
00326 ?>