<?php

$add_button = $this->block->generate_add_icon('order/setting/add_stmp_sender');
$head = array(lang('paypal_email'), lang('sender_name'), lang('stmp_account'), lang('options') . $add_button);
$data = array();
$sender_update_url = site_url('order/setting/update_stmp_sender');
$data = array();
foreach ($paypal_senders as $sender) {
    $sender_id = $sender->id;
    $drop_button = block_drop_icon('order/setting/drop_stmp_sender', "{id: {$sender_id}}", TRUE);
    $sender_accounts = $this->stmp_model->fetch_paypal_sender_accounts($sender_id);
    $account_html = '';
    foreach ($sender_accounts as $account) {
        $account_html .= $account->stmp_host . ': ' . $account->stmp_account . block_status_image($account->account_status) . '<br/>';
    }
    $edit_button = block_edit_link(site_url('order/setting/update_stmp_sender_accounts', array($sender_id)));
    $account_html .= $edit_button;
    $data[] = array($this->block->generate_div("paypal_email_{$sender_id}", $sender->paypal_email), $this->block->generate_div("sender_name_{$sender_id}", $sender->sender_name), $account_html, $drop_button);
    echo block_editor("paypal_email_{$sender_id}", 'sender_form', $sender_update_url, "{id: {$sender_id}, type: 'paypal_email'}");
    echo block_editor("sender_name_{$sender_id}", 'sender_form', $sender_update_url, "{id: {$sender_id}, type: 'sender_name'}");
}
echo block_header(lang('notification_email_account_setting'));
echo block_table($head, $data);
<?php

$add_button = $this->block->generate_add_icon('order/setting/add_stmp_account');
$head = array(lang('account_name'), lang('account_password'), lang('stmp_host'), lang('status'), '<div>' . lang('options') . $add_button . '</div>');
$account_update_url = site_url('order/setting/update_stmp_account');
$account_collection = object_to_js_array($hosts, 'id', 'host');
$data = array();
foreach ($accounts as $account) {
    $account_id = $account->id;
    $drop_button = block_drop_icon('order/setting/drop_stmp_accout', "{id: {$account_id}}", TRUE);
    $data[] = array($this->block->generate_div("stmp_account_name_{$account_id}", $account->account_name), $this->block->generate_div("stmp_account_password_{$account_id}", $account->account_password), $this->block->generate_div("stmp_account_host_{$account_id}", $account->stmp_host), '<center>' . block_status_image($account->status) . '</center>', $drop_button);
    echo $this->block->generate_editor("stmp_account_name_{$account_id}", 'account_form', $account_update_url, "{id: {$account_id}, type: 'account_name'}");
    echo $this->block->generate_editor("stmp_account_password_{$account_id}", 'account_form', $account_update_url, "{id: {$account_id}, type: 'account_password'}");
    echo $this->block->generate_editor("stmp_account_host_{$account_id}", 'account_form', $account_update_url, "{id: {$account_id}, type: 'stmp_host'}", $account_collection);
}
echo block_header(lang('stmp_accout_setting'));
echo block_table($head, $data);
<?php 
$head = array(lang('paypal_email'), lang('stmp_account'));
$data = array();
$str = '';
$url = site_url('order/setting/proccess_update_stmp_sender_accounts');
foreach ($accounts as $account) {
    $account_id = $account->id;
    $checkbox = array('name' => 'account_' . $account_id, 'id' => 'account_' . $account_id, 'value' => $account_id, 'checked' => in_array($account_id, $account_ids) ? TRUE : FALSE, 'onclick' => "helper.ajax('{$url}', {sender_id: {$sender->id}, account_id: {$account_id}, checked: this.checked}, 1)");
    $str .= form_checkbox($checkbox) . form_label($account->stmp_host) . ': ' . $account->account_name . block_status_image($account->status) . '<br/><br/>';
}
$data[] = array($sender->paypal_email . ' ( ' . $sender->sender_name . ' )', $str);
$back_button = $this->block->generate_back_icon(site_url('order/setting/notification_email_account'));
$title = lang('stmp_sender_accounts_setting') . $back_button;
echo block_header($title);
echo $this->block->generate_table($head, $data);
echo $back_button;