<script>
// handleControls - controls visibility of controls.
function handlePluginCheckboxes() {
  var clientsCheckbox = document.getElementById("clients");
  var invoicesCheckbox = document.getElementById("invoices");
  var requiredCheckbox = document.getElementById("client_required");
  var requiredLabel = document.getElementById("required_label");
  if (clientsCheckbox.checked) {
    requiredCheckbox.style.visibility = "visible";
	requiredLabel.style.visibility = "visible";
	invoicesCheckbox.disabled = false;
  } else {
	requiredCheckbox.checked = false;
	requiredCheckbox.style.visibility = "hidden";
	requiredLabel.style.visibility = "hidden";
	invoicesCheckbox.checked = false;
    invoicesCheckbox.disabled = true;
  } 

  var expensesCheckbox = document.getElementById("expenses");
  var taxCheckbox = document.getElementById("tax_expenses");
  var taxLabel = document.getElementById("tax_label");
  if (expensesCheckbox.checked) {
    taxCheckbox.style.visibility = "visible";
    taxLabel.style.visibility = "visible";
  } else {
	taxCheckbox.checked = false;
    taxCheckbox.style.visibility = "hidden";
    taxLabel.style.visibility = "hidden";
  }

  var customFieldsCheckbox = document.getElementById("custom_fields");
  var configureLabel = document.getElementById("cf_config");
  if (customFieldsCheckbox.checked) {
    configureLabel.style.visibility = "visible";
  } else {
    configureLabel.style.visibility = "hidden";
  }

  var notificationsCheckbox = document.getElementById("notifications");
  configureLabel = document.getElementById("notifications_config");
  if (notificationsCheckbox.checked) {
    configureLabel.style.visibility = "visible";
  } else {
    configureLabel.style.visibility = "hidden";
  }
}
</script>

{$forms.profileForm.open}

{if $user->canManageTeam()}
{include file="datetime_format_preview.tpl"}
{/if}

<table cellspacing="4" cellpadding="7" border="0">
    <tr>
      <td>
        <table cellspacing="1" cellpadding="2" border="0">
          <tr>
            <td align="right" nowrap>{$i18n.label.person_name} (*):</td>
            <td>{$forms.profileForm.name.control}</td>
          </tr>
          <tr>
            <td align="right" nowrap>{$i18n.label.login} (*):</td>
            <td>{$forms.profileForm.login.control}</td>
          </tr>

{if !$auth_external}
          <tr>
            <td align="right" nowrap>{$i18n.label.password} (*):</td>
            <td>{$forms.profileForm.password1.control}</td>
          </tr>
          <tr>
            <td align="right" nowrap>{$i18n.label.confirm_password} (*):</td>
            <td>{$forms.profileForm.password2.control}</td>
          </tr>
{/if}

          <tr>
            <td align="right" nowrap>{$i18n.label.email}:</td>
            <td>{$forms.profileForm.email.control}</td>
          </tr>
          <tr>
            <td></td>
            <td>{$i18n.label.required_fields}</td>
          </tr>

{if $user->canManageTeam()}
          <tr>
            <td colspan="2">&nbsp;</td>
          </tr>
          <tr>
            <td align="right" nowrap>{$i18n.label.team_name}:</td>
            <td>{$forms.profileForm.team_name.control}</td>
          </tr>
          <!-- <tr>
            <td align="right">{$i18n.label.address}:</td>
            <td>{$forms.profileForm.address.control}</td>
          </tr> -->
          <tr>
            <td align="right">{$i18n.label.currency}:</td>
            <td>{$forms.profileForm.currency.control}</td>
          </tr>
          <tr>
            <td align="right" nowrap>{$i18n.label.lock_interval}:</td>
            <td>{$forms.profileForm.lock_interval.control}</td>
          </tr>
          <tr>
           <td align="right" nowrap>{$i18n.label.language}:</td>
           <td>{$forms.profileForm.lang.control}</td>
          </tr>
          <tr>
            <td align="right">{$i18n.label.decimal_mark}:</td>
            <td>{$forms.profileForm.decimal_mark.control} <font id="decimal_preview" color="#777777">&nbsp;</font></td>
          <tr>
            <td align="right" nowrap>{$i18n.label.date_format}:</td>
            <td>{$forms.profileForm.format_date.control} <font id="date_format_preview" color="#777777">&nbsp;</font></td>
          </tr>
          <tr>
            <td align="right" nowrap>{$i18n.label.time_format}:</td>
            <td>{$forms.profileForm.format_time.control} <font id="time_format_preview" color="#777777">&nbsp;</font></td>
          </tr>
          <tr>
            <td align="right" nowrap>{$i18n.label.week_start}:</td>
            <td>{$forms.profileForm.start_week.control}</td>
          </tr>
          <tr>
            <td align="right" nowrap>{$i18n.form.profile.tracking_mode}:</td>
            <td>{$forms.profileForm.tracking_mode.control}</td>
          </tr>
          <tr>
            <td align="right" nowrap>{$i18n.form.profile.record_type}:</td>
            <td>{$forms.profileForm.record_type.control}</td>
          </tr>

          {* initialize preview text *}
          <script>
            MakeFormatPreview("date_format_preview", document.getElementById("format_date"));
            MakeFormatPreview("time_format_preview", document.getElementById("format_time"));
            
            function adjustDecimalPreview()
            {
              var mark = document.getElementById("decimal_mark").value;
              var example = document.getElementById("decimal_preview");
              example.innerHTML = "<i>3"+mark+"14</i>";
            }
            adjustDecimalPreview();
          </script>

          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>

          <tr>
             <td colspan="2" class="sectionHeader">{$i18n.form.profile.plugins}</td>
          </tr>
          <tr><td>&nbsp;</td></tr>
          <tr>
            <td align="right" nowrap>{$forms.profileForm.charts.control}</td>
            <td>{$i18n.title.charts}</td>
          </tr>
          <tr>
            <td align="right" nowrap>{$forms.profileForm.clients.control}</td>
            <td>{$i18n.title.clients} {$forms.profileForm.client_required.control} <span id="required_label">{$i18n.label.required}</span></td>
          </tr>
          <tr>
            <td align="right" nowrap>{$forms.profileForm.invoices.control}</td>
            <td>{$i18n.title.invoices}</td>
          </tr>
          <tr>
            <td align="right" nowrap>{$forms.profileForm.custom_fields.control}</td>
            <td>{$i18n.label.custom_fields} <span id="cf_config"><a href="cf_custom_fields.php">{$i18n.label.configure}</a></span></td>
          </tr>
          <tr>
            <td align="right" nowrap>{$forms.profileForm.expenses.control}</td>
            <td>{$i18n.title.expenses} {$forms.profileForm.tax_expenses.control} <span id="tax_label">{$i18n.label.tax}</span></td>
          </tr>
          <tr>
            <td align="right" nowrap>{$forms.profileForm.notifications.control}</td>
            <td>{$i18n.title.notifications} <span id="notifications_config"><a href="notifications.php">{$i18n.label.configure}</a></span></td>
          </tr>
{/if}

          <tr>
            <td colspan="2">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="2" height="50" align="center">{$forms.profileForm.btn_save.control}</td>
          </tr>
        </table>
      </td>
    </tr>
</table>
{$forms.profileForm.close}