<?php

/*------------------------------------------------------------------------
# com_invoices - Invoice Manager for Joomla
# ------------------------------------------------------------------------
# author				Germinal Camps
# copyright 			Copyright (C) 2012 - 2016 JoomlaThat.com. All Rights Reserved.
# @license				http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: 			http://www.joomlathat.com
# Technical Support:	Forum - http://www.joomlathat.com/support
-------------------------------------------------------------------------*/

//no direct access
defined('_JEXEC') or die('Restricted access.');

$params = JComponentHelper::getParams( 'com_invoices' );
$document = JFactory::getDocument();
$show_editor = 0;//$params->get('notes_editor', 1);
$editor = null;

if ($show_editor) {
  $editor = JFactory::getEditor();
}

?>

<div class="form-group">
  <label class="control-label col-lg-3" for="notes"> <?php echo JText::_( 'NOTES' ); ?> </label>
  <div class="controls col-lg-9">
    <?php
      if ($show_editor) {
        $before = $document->_script['text/javascript'];
        $beforelenght = strlen($before);
        echo $editor->display('notes', $this->invoice->notes, '100%', '200', '60', '20', true);
        $after = $document->_script['text/javascript'];
        $editorscript = substr($after, $beforelenght);
        //echo $editorscript;die;
   
      } else { ?>
        <textarea class="form-control" name="notes" id="notes" cols="100" rows="10"><?php echo $this->invoice->notes; ?></textarea>
      <?php }
    ?>
  </div>
</div>
<div class="form-group">
  <label class="control-label col-lg-3" for="admin_notes"> <?php echo JText::_( 'ADMIN_NOTES' ); ?> </label>
  <div class="controls col-lg-9">
    <?php
      if ($show_editor) {
        echo $editor->display('admin_notes', $this->invoice->admin_notes, '100%', '200', '60', '20', true);
      } else { ?>
        <textarea class="form-control" name="admin_notes" id="admin_notes" cols="100" rows="10"><?php echo $this->invoice->admin_notes; ?></textarea>
      <?php }
    ?>
  </div>
</div>
<?php if ($show_editor) { ?>  
<script type="text/javascript">

tinymce.remove();

<?php echo $editorscript; ?>
/*
tinymce.init({
  directionality: "ltr",
  selector: "textarea.mce_editable",
  language : "en",
  mode : "specific_textareas",
  autosave_restore_when_empty: false,
  skin : "lightgray",
  theme : "modern",
  schema: "html5",

  inline_styles : true,
  gecko_spellcheck : true,
  entity_encoding : "raw",
  force_br_newlines : false, force_p_newlines : true, forced_root_block : 'p',
  toolbar_items_size: "small",

  relative_urls : true,
  remove_script_host : false,
});
*/
</script>
<?php } ?>