<?php
includeContainer('_library_lib.php', 1);
setSessionLang();
$socInfo = getSocInfo();

$message = '';
if (!isModEnabled('eventorganization') || !isModEnabled('member') || !isModEnabled('don') || !isModEnabled('webportal')) {
    $message = $langs->trans("TEMPLATE_MODULES_NOTICE") ."<br><br>";
}

require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
$formSetup = new FormSetup($db);

$item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'USE_TEXT_LOGO')->setAsYesNo();
$item->nameText = $langs->trans("USE_TEXT_LOGO");

$item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'CUSTOM_SLOGAN');
$item->nameText = $langs->trans("CUSTOM_SLOGAN");
$item->cssClass = 'minwidth500';

$item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'CUSTOM_DESCRIPTION');
$item->nameText = $langs->trans("CUSTOM_DESCRIPTION");
$item->cssClass = 'minwidth500';

// Get available langs for the website
$TField = array();
$website_langs = getAvailableLangs();
$available_langs = $website_langs['langs'];
$langs_code_shortcode = $website_langs['langs_code_shortcode'];
foreach ($available_langs as $key => $value) {
    $TField[$key] = trim(explode('(', $langs->trans("Language_".$langs_code_shortcode[$key]))[0]);
}
$item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'SUPPORTED_LANGS');
$item->nameText = $langs->trans("SUPPORTED_LANGS");
$item->setAsMultiSelect($TField);

$item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'MAIN_COLOR');
$item->nameText = $langs->trans("MAIN_COLOR");
$item->cssClass = 'minwidth500';

$item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'SECONDARY_COLOR');
$item->nameText = $langs->trans("SECONDARY_COLOR");
$item->cssClass = 'minwidth500';

if (isModEnabled('member')) {
    $formSetup->newItem('membersArea')->setAsTitle();
    $item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'ENABLE_MEMBER_REGISTRATION_PAGE')->setAsYesNo();
    $item->nameText = $langs->trans("ENABLE_MEMBER_REGISTRATION_PAGE");
    
    $item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'ENABLE_MEMBER_LIST_PAGE')->setAsYesNo();
    $item->nameText = $langs->trans("ENABLE_MEMBER_LIST_PAGE");
    
    if (isModEnabled('webportal')) {
        $item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'ENABLE_MEMBER_AREA_PAGE')->setAsYesNo();
        $item->nameText = $langs->trans("ENABLE_MEMBER_AREA_PAGE");
    }
}

if (isModEnabled('eventorganization')) {
    $formSetup->newItem('eventsArea')->setAsTitle();
    $item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'ENABLE_EVENTS_SECTION')->setAsYesNo();
    $item->nameText = $langs->trans("ENABLE_EVENTS_SECTION");
    
    $item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'SHOW_EVENT_PARTICIPATE_LINK')->setAsYesNo();
    $item->nameText = $langs->trans("SHOW_EVENT_PARTICIPATE_LINK");
}

if (isModEnabled('don')) {
    $formSetup->newItem('DonationsArea')->setAsTitle();
    $item = $formSetup->newItem('WS_'.strtoupper($website->ref).'_' . 'ENABLE_DONATION_PAGE')->setAsYesNo();
    $item->nameText = $langs->trans("ENABLE_DONATION_PAGE");
}


/*=============================================================
============NEXT PART WILL BE INTEGRATED IN CORE===============
=============================================================*/


/*
 * Actions
 */

$websitetemplateconf = GETPOSTINT('websitetemplateconf');
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';


/*
 * View
 */

print load_fiche_titre($langs->trans('SetupAndProperties'), '', 'title_setup');

if ($message) {
    print $message;
}

if (!empty($formSetup->items)) {

	
    $out2 = '';
	$out2.= '<form action="config.php" method="POST" >';
	// generate hidden values from $formSetup->formHiddenInputs
	if (!empty($formSetup->formHiddenInputs) && is_array($formSetup->formHiddenInputs)) {
		foreach ($formSetup->formHiddenInputs as $hiddenKey => $hiddenValue) {
			$out2.= '<input type="hidden" name="'.dol_escape_htmltag($hiddenKey).'" value="' . dol_escape_htmltag($hiddenValue) . '">';
		}
	}

    // generate output table
    $out2 .= $formSetup->generateTableOutput(true);

    // Submit button
    $out2 .= '<input type="hidden" name="action" value="">';
    $out2 .= '<input type="hidden" name="websitetemplateconf" value="1">';
	$out2 .= '<br>';
	$out2 .= '<div class="form-setup-button-container center">';
	$out2 .= '<input class="button button-submit" type="submit" href="">';
	$out2 .= '</div>';

	$out2 .= '</form>';
    print $out2;
}


/*
 * Style
 */

?>
<style>
.bodywebpage-config {
    max-width: 70%;
    margin: auto;
    margin-top: 50px;
}
</style>
<?php


?>