function updated($gc_old, $gc_new) { $type = getMsg('GCT', 'GC_LOG_TYPE'); $header = str_replace('{code}', $gc_new->code, getMsg('GCT', 'GC_LOG_UPDATED')); $body = ''; $sendtype = array(GC_SENDTYPE_EMAIL => getMsg('GCT', 'GC_SENDTYPE_EMAIL'), GC_SENDTYPE_POST => getMsg('GCT', 'GC_SENDTYPE_POST')); $status = array(GC_STATUS_ACTIVE => getMsg('GCT', 'GC_STATUS_ACTIVE'), GC_STATUS_PENDING => getMsg('GCT', 'GC_STATUS_PENDING'), GC_STATUS_BLOCKED => getMsg('GCT', 'GC_STATUS_BLOCKED')); $amount_old = modApiFunc('Localization', 'currency_format', $gc_old->amount); $amount_new = modApiFunc('Localization', 'currency_format', $gc_new->amount); $remainder_old = modApiFunc('Localization', 'currency_format', $gc_old->remainder); $remainder_new = modApiFunc('Localization', 'currency_format', $gc_new->remainder); $country_old = modApiFunc('Location', 'getCountry', $gc_old->country_id); $country_new = modApiFunc('Location', 'getCountry', $gc_new->country_id); $state_old = modApiFunc('Location', 'getState', $gc_old->state_id); $state_new = modApiFunc('Location', 'getState', $gc_new->state_id); $fields = array(array($gc_old->from, $gc_new->from, getMsg('GCT', 'GC_FROM')), array($gc_old->to, $gc_new->to, getMsg('GCT', 'GC_TO')), array($gc_old->message, $gc_new->message, getMsg('GCT', 'GC_MESSAGE')), array($amount_old, $amount_new, getMsg('GCT', 'GC_AMOUNT')), array($remainder_old, $remainder_new, getMsg('GCT', 'GC_REMAINDER')), array($sendtype[$gc_old->sendtype], $sendtype[$gc_new->sendtype], getMsg('GCT', 'GC_SENDTYPE')), array($status[$gc_old->status], $status[$gc_new->status], getMsg('GCT', 'GC_STATUS')), array($gc_old->fname, $gc_new->fname, getMsg('GCT', 'GC_FNAME')), array($gc_old->lname, $gc_new->lname, getMsg('GCT', 'GC_LNAME')), array($gc_old->zip, $gc_new->zip, getMsg('GCT', 'GC_ZIP')), array($gc_old->city, $gc_new->city, getMsg('GCT', 'GC_CITY')), array($gc_old->address, $gc_new->address, getMsg('GCT', 'GC_ADDRESS')), array($gc_old->phone, $gc_new->phone, getMsg('GCT', 'GC_PHONE')), array($gc_old->email, $gc_new->email, getMsg('GCT', 'GC_EMAIL')), array($country_old, $country_new, getMsg('GCT', 'GC_COUNTRY')), array($state_old, $state_new, getMsg('GCT', 'GC_STATE'))); foreach ($fields as $f) { $body .= GiftCertificateLogger::__prepareLogMessageOnChange($f[0], $f[1], $f[2]); } $refid = $gc_new->id; modApiFunc('Timeline', 'addLog', $type, $header, $body, $refid, GC_LOG_REFSPACE); }
function createGC($order_id) { loadClass('GiftCertificateLogger'); $order = modApiFunc("Checkout", "getOrderInfo", $order_id, modApiFunc("Localization", "whichCurrencyToDisplayOrderIn", $order_id)); $gcs = $this->addGCFromOrderProducts($order['Products'], $order_id); foreach ($gcs as $i => $gc) { if (!empty($gc->errors)) { GiftCertificateLogger::failed($gc, $order_id); } else { GiftCertificateLogger::purchased($gc, $order_id); } } }