function onAction()
 {
     $gc_code = modApiFunc('Request', 'getValueByKey', 'gc_code');
     if (Validator::isNotEmpty($gc_code) && modApiFunc('GiftCertificateApi', 'isCodeValid', $gc_code) && modApiFunc('GiftCertificateApi', 'doesCodeExist', $gc_code)) {
         loadClass('GiftCertificateUpdater');
         //
         $cr = new GiftCertificateUpdater($gc_code);
         //         ,
         if ($cr->isError()) {
             modApiFunc('Session', 'set', 'gc_update_action_result', 'failed');
             modApiFunc('Session', 'set', 'gc_update_action_errors', $cr->errors);
             modApiFunc('Session', 'set', 'SessionPost', $_POST);
             return;
         }
         //                                    ,                .             ,
         //         $map                 $_POST          .
         //                              ,                     .
         $cr->initByMap($_POST);
         //                     .
         $cr->save();
         if ($cr->isError()) {
             modApiFunc('Session', 'set', 'gc_update_action_result', 'failed');
             modApiFunc('Session', 'set', 'gc_update_action_errors', $cr->errors);
             modApiFunc('Session', 'set', 'SessionPost', $_POST);
         } else {
             modApiFunc('Session', 'set', 'gc_update_action_result', 'updated');
             if ($cr->sendtype === GC_SENDTYPE_EMAIL && $cr->status === GC_STATUS_ACTIVE) {
                 modApiFunc('EventsManager', 'throwEvent', 'GiftCertificateCreated', $cr);
             }
         }
     }
 }
 function GiftCertificate($gc_code)
 {
     parent::GiftCertificateUpdater($gc_code);
 }
 function updateGCstatus($order_id, $status)
 {
     loadClass('GiftCertificateUpdater');
     $order = modApiFunc("Checkout", "getOrderInfo", $order_id, modApiFunc("Localization", "whichCurrencyToDisplayOrderIn", $order_id));
     $gcs = $this->getGiftCertificatesForOrderId($order_id);
     if (is_array($gcs) && !empty($gcs)) {
         foreach ($gcs as $i => $_gc) {
             $gc_updated = new GiftCertificateUpdater($_gc['gc_code']);
             $gc_updated->status = $status;
             if (!empty($gc_updated->errors)) {
                 #GiftCertificateLogger::failed($gc_updated, $order_id);
             } else {
                 $gc_updated->save();
                 if ($gc_updated->purchased_order_id !== null) {
                     // GC was purchased by customer
                     modApiFunc('EventsManager', 'throwEvent', 'GiftCertificatePurchased', $gc_updated);
                 } else {
                     // GC was created by Admin
                     modApiFunc('EventsManager', 'throwEvent', 'GiftCertificateCreated', $gc_updated);
                 }
             }
         }
     }
 }