<?php
	// this is the customer panel settings, here he can enable/disable a chatbot and receiving promotional messages

	$clientId = Mage::getSingleton('customer/session')->getCustomer()->getId(); // get customer id
	$chatdata = Mage::getModel('chatbot/chatdata')->load($clientId, 'customer_id'); // load profile info from customer id
	$chatbotHelper = Mage::helper('werules_chatbot');

	$tgUsername = $chatbotHelper->getTelegramBotUsername();
	$fbUsername = $chatbotHelper->getFacebookPageChatID();
?>
<div class="dashboard">
	<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
	<div class="page-title">
		<h1><?php echo $this->__('Chatbot Settings') ?></h1>
	</div>
	<form action="<?php echo $this->getUrl('chatbot/settings/save') ?>" method="post" id="form-validate" autocomplete="off">
		<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
		<div class="fieldset">
			<ul class="form-list">
				<?php if (Mage::getStoreConfig('chatbot_enable/general_config/disable_promotional_messages') == "1"): ?>
					<li>
						<div class="input-box">
							<input <?php if ($chatdata->getEnablePromotionalMessages() != "0") echo "checked"; ?> type="checkbox" title="<?php echo $this->__('Receive Promotional Messages?') ?>" class="checkbox" name="enable_promotional_messages" id="enable_promotional_messages" />
							<label for="enable_telegram" class="required"><em>*</em><?php echo $this->__('Receive Promotional Messages?') ?></label>
						</div>
					</li>
				<?php endif; ?>
				<li>
					<div class="input-box">
						<input <?php if ($chatdata->getEnableTelegram() != "0") echo "checked"; ?> type="checkbox" title="<?php echo $this->__('Enable Telegram?') ?>" class="checkbox" name="enable_telegram" id="enable_telegram" />
						<label for="enable_telegram" class="required"><em>*</em><?php echo $this->__('Enable Telegram?') ?></label>
					</div>
					<?php if ($tgUsername): ?> <!-- bot username -->
						<p>
							<?php
								echo $this->__("Start a bot conversation on Telegram") . ": ";
								$url = $chatbotHelper->_tgUrl . $tgUsername;
								if (!($chatdata->getTelegramChatId()))
									$url .= "?start=" . $chatdata->getHashKey();
							?>
							<a href="<?php echo $url; ?>" target="_blank"><?php echo $this->__('Here') ?></a>
						</p>
					<?php endif; ?>
				</li>
				<li>
					<div class="input-box">
						<input <?php if ($chatdata->getEnableFacebook() != "0") echo "checked"; ?> type="checkbox" title="<?php echo $this->__('Enable Facebook?') ?>" class="checkbox" name="enable_facebook" id="enable_facebook" />
						<label for="enable_facebook" class="required"><em>*</em><?php echo $this->__('Enable Facebook?') ?></label>
					</div>
					<?php if ($fbUsername): ?> <!-- bot username -->
					<p>
						<?php
							echo $this->__("Start a bot conversation on Facebook Messenger") . ": ";
							$url = $chatbotHelper->_fbUrl . $fbUsername;
						?>
						<a href="<?php echo $url; ?>" target="_blank"><?php echo $this->__('Here') ?></a>
					</p>
					<?php endif; ?>
				</li>
				<?php
				/*
				<li>
					<div class="input-box">
						<input <?php if ($chatdata->getEnableWhatsapp() == "1") echo "checked"; ?> type="checkbox" title="<?php echo $this->__('Enable Whatsapp?') ?>" class="checkbox" name="enable_whatsapp" id="enable_whatsapp" />
					</div>
					<label for="enable_whatsapp" class="required"><em>*</em><?php echo $this->__('Enable Whatsapp?') ?></label>
				</li>
				<li>
					<div class="input-box">
						<input <?php if ($chatdata->getEnableWechat() == "1") echo "checked"; ?> type="checkbox" title="<?php echo $this->__('Enable Wechat?') ?>" class="checkbox" name="enable_wechat" id="enable_wechat" />
					</div>
					<label for="enable_wechat" class="required"><em>*</em><?php echo $this->__('Enable Wechat?') ?></label>
				</li>
				*/
				?>
			</ul>
		</div>
		<!-- buttons -->
		<p class="required"><?php echo $this->__('* Required Fields') ?></p>
		<div class="buttons-set">
			<p class="back-link">
				<a href="<?php echo $this->getBackUrl() ?>">
					<small>&laquo; </small><?php echo $this->__('Back') ?>
				</a>
			</p>
			<button type="submit" title="<?php echo $this->__('Save') ?>" class="button">
				<span>
					<span>
						<?php echo $this->__('Save') ?>
					</span>
				</span>
			</button>
		</div>
	</form>
</div>