<?
global $vis_language;
if($facebook_details!=-1) { ?>
<div class="vis_main_window vis_shadow vis_round_corner">
    <table cellpadding="0" cellspacing="0" width="100%"><tr><td><div class="vis_main_header"><?= $vis_language['TXTINTEGRATIONS']; ?></div></td><td align="right">
    <a class="vis_link" href="?vis_module=setting&vis_operation=fb_integration" target="_blank" ><span class="vis-icon vis-icon-plus"></span> <?= $vis_language['TXTADD'] ?></a> | <span class="vis-pointer" onclick="$(this).visInterface('load_dialog', {'vis_module':'setting', 'vis_operation':'edit_fb_app', 'vis_static_area':'vis_edit_fb_app_dialog' });">Edit</span></td></tr></table>
    <div class="vis_main_window_content vis_round_corner">
    <table cellpadding="0" cellspacing="0" width="100%" class="vis_list_table"><th>Page</th><th>Status</th><th width="50"></th><?
    for($i=0;$i<count($facebook_details);$i++) echo '<tr><td class="vis-pointer" onclick="$(this).visInterface(\'load_dialog\', {\'vis_module\':\'setting\', \'vis_operation\':\'fb_mapping\', \'vis_integration_id\':'.$facebook_details[$i]['integration_id'].', \'vis_static_area\':\'vis_fb_form\'})">'.$facebook_details[$i]['user_name'].'</td><td>'.($facebook_details[$i]['is_enabled']==1?$vis_language['TXTENABLED']:$vis_language['TXTDISABLED']).'</td><td><span onclick="$(this).visInterface(\'load_dialog\', {\'vis_module\':\'setting\', \'vis_operation\':\'get_fb_integration_delete\', \'vis_integration_id\':'.$facebook_details[$i]['integration_id'].', \'vis_static_area\':\'vis_fb_integration_delete_form\'})" class="vis-icon-med vis-icon-trash" title="'.$vis_language['TXTDELETE'].'"></span></td></tr>'; ?>
    </table><input type="hidden" name="vis_integration_id" value="<?= $facebook_details['integration_id'] ?>" />
</div></div><?
}
else {?>
    <div class="vis_main_window vis_shadow vis_round_corner"><table cellpadding="0" cellspacing="0" width="100%"><tr><td><div class="vis_main_header"><?= $vis_language['TXTINTEGRATIONS']; ?></div></td><td align="right"><?
    if($setting!=-1) { ?><a class="vis_link" href="?vis_module=setting&vis_operation=fb_integration" ><span class="vis-icon vis-icon-plus"></span> <?= $vis_language['TXTADD'] ?></a> | <span class="vis-pointer" onclick="$(this).visInterface('load_dialog', {'vis_module':'setting', 'vis_operation':'edit_fb_app', 'vis_static_area':'vis_edit_fb_app_dialog' });">Edit</span><? } ?></td></tr></table><div class="vis_main_window_content vis_round_corner"><?
    if($setting==-1) { ?>
        <form name="vis_fb_settings" id="vis_fb_settings"><table cellpadding="3" cellspacing="3" width="100%">
            <tr><td width="120">APP Id</td><td><input name="fb_app_id" type="text" class="vis_input" /></td></tr>
            <tr><td>APP Secret key</td><td><input name="fb_secret" type="text" class="vis_input" /></td></tr>
            <tr><td>Canvas url</td><td><input name="fb_canvas_url" type="text" class="vis_input" value="http://support.domain.com/manage/" /></td></tr>
            <tr><td colspan="2"><div class="vis_seperator_horizontal"></div></td></tr>
            <tr><td colspan="2"><span class="vis_button" onclick="$(this).visExecution('submit_form',{'vis_module':'setting', 'vis_operation':'save_fb_settings', 'vis_form':'vis_fb_settings'})">Add</span></td></tr>
       </table></form><?
    }
    else { ?>
    <div class="vis_sub_title">Facebook Page not configured yet. Click <a class="vis_link" href="?vis_module=setting&vis_operation=fb_integration" target="_blank">here</a> to add your Facebook Pages.</div><?
    } ?>
    </div></div> <?
}?>