function copyEmailContent($hotelId) { //copy emails default $row_email_default = $this->getTable('ManageEmailsDefault'); $defaultEmails = $row_email_default->getDefaultEmailsForHotel($hotelId); foreach ($defaultEmails as $defaultEmail) { $emailsTable = $this->getTable('ManageEmails'); $emailsTable->hotel_id = $hotelId; $emailsTable->email_subject = $defaultEmail->email_default_subject; $emailsTable->email_name = $defaultEmail->email_default_name; $emailsTable->email_type = $defaultEmail->email_default_type; $emailsTable->is_default = 1; if (!$emailsTable->store()) { throw new Exception("Error saving email templates"); } $newEmailId = $emailsTable->email_id; $hoteltranslationsModel = new JHotelReservationModelhoteltranslations(); $translations = $hoteltranslationsModel->getAllTranslationObjects(EMAIL_TEMPLATE_TRANSLATION, $defaultEmail->email_default_id); if (count($translations) > 0) { foreach ($translations as $translation) { $translationTable = $this->getTable('HotelTranslations'); $translationTable->bind($translation); $translationTable->object_id = $newEmailId; $translationTable->id = null; if (!$translationTable->store()) { throw new Exception("Error saving email templates translation"); } } } } return true; }