protected function createSubLeaves()
 {
     $communicationItems = $this->model->restCollection;
     if ($this->model->archive) {
         $communicationItems->filter(new Not(new Equals('Status', 'Not Sent')));
     }
     $communicationItems->intersectWith(Communication::find(), 'CommunicationID', 'CommunicationID', ['Title', 'DateToSend']);
     $this->registerSubLeaf($table = new Table($communicationItems->addSort('DateCreated', false)), $searchPanel = new CommunicationItemSearchPanel('SearchPanel'), $sendAllButton = new Button('SendAllCommunicationsButton', 'Send All Communications Now', function () {
         foreach (Communication::findUnsentCommunications() as $unsentCommunication) {
             CommunicationProcessor::sendCommunication($unsentCommunication, true);
         }
         throw new ForceResponseException(new RedirectResponse('./'));
     }), new CommunicationItemCollectionCheckbox('EnableSendingEmails'));
     $sendAllButton->setConfirmMessage('Are you sure you want to send all scheduled emails?');
     $table->bindEventsWith($searchPanel);
     $table->columns = ['#' => 'CommunicationItemID', 'Title' => '{Title}', 'Recipient', 'DateCreated', 'Date to Send' => new DateColumn('DateToSend', 'Date to Send', CommunicationDecorator::DATE_FORMAT), 'DateSent', 'Status', '' => '<a class="view-content-button" data-id="{CommunicationItemID}" href="#ViewContent">View Content</a>'];
 }