public function delete(Mage_Core_Model_Abstract $template)
 {
     $templateId = $template->getId();
     // removing attachments
     $attachmentCollection = Mage::getModel('aitemails/aitattachment')->getTemplateAttachments($templateId);
     if (count($attachmentCollection) > 0) {
         foreach ($attachmentCollection as $attachment) {
             @unlink(Aitoc_Aitemails_Model_Aitattachment::getBasePath() . $attachment->getAttachmentFile());
             @unlink(Aitoc_Aitemails_Model_Aitattachment::getBaseTmpPath() . $attachment->getAttachmentFile());
             Mage::getModel('aitemails/aitattachment')->load($attachment->getId())->delete();
         }
     }
     return parent::delete($template);
 }