<?php 
/**
 * Screen languages\translate
 * @version 1.0.1
 * @package Backend\Languages
 * 
*/

?>
<div class="row" >
<div class="col-lg-12" >
            <h3><?= R('page_title_translate') ?></h3>
            <div class="panel panel-default">
	            <div class="panel-body">
		            <ul class="nav nav-pills">
		                <li class="<?=$this->data['page'] == "resources" ? "active":"" ?>"><a href="<?= __SITEBASE ?>/languages/list_resources"><?= R("page_nav_resources") ?></a></li>
		                <li class="<?=$this->data['page'] == "descriptions" ? "active":"" ?>"><a href="<?= __SITEBASE ?>/languages/list_descriptions"><?= R("page_nav_descriptions") ?></a></li>
		             </ul>
	             </div>
             </div>
             <div class="panel panel-default">
	         <div class="panel-body">
             <?=R('label_Translate_to') ?>: 
             <select onchange="window.location.href='<?= __SITEBASE ?>/languages/list_<?= $this->data['page'] ?>?langid='+this.value" name="langid">
             	<?php foreach($this->data['language_list'] as $lang ) { ?>
             		<option <?= $lang->id == $this->data['lang_selected'] ? "selected":"" ?> value="<?= $lang->id ?>"><?= D($lang->descriptioncode) ?></option>
             	<?php } ?>
             </select>
             </div>
             </div>
             <div class="panel">
             <div class="panel panel-default">
	         <div class="panel-body">
           	 <div class="table-responsive" >
           	 <form name="form1" method="post" action="<?= __SITEBASE ?>/languages/<?= $this->data['page'] ?>_save">
              <table id="table1" class="table table-hover table-striped tablesorter">
                <thead>
                  <tr>
                    <th class="header"><?=R('label_code') ?> <i class="fa fa-sort"></th>
                    <th class="header"><?=R('label_default_english') ?> <i class="fa fa-sort"></i></th>
                    <th class="header"><?=R('label_value') ?></th>
                  </tr>
                </thead>
                <tbody>
                <?php
                foreach($this->data['list'] as $line)  { 
               		if($line->languageid==__DEFAULTLANG) { ?>
                  <tr>
                  	 <td>
                    	<?= $line->code ?>
                	</td>
                    <td>
                    	<?= $line->valuetext ?>
                	</td>
                    <td>
                    	<?php 
                    	$lang = $this->data['list'][$line->code."_".$this->data['lang_selected']];  	 
                    	if ($lang) { ?>
                    		
                    		<textarea rows="2" cols="120" class="form-control" type="text" onchange="javascript:$('#changed_<?= $lang->id ?>').val('1');"  name="valuetext_<?= $lang->id ?>"><?= $lang->valuetext ?></textarea>
                    		<input type="hidden" value="" id="changed_<?= $lang->id ?>" name="changed_<?= $lang->id ?>">
                       <?php } ?> 
                       	
                  </tr>
               <?php
                  }
                }
                ?>
                </tbody>
              </table>
              <div class="pull-left">
              <input type="hidden" name="langid" value="<?= $this->data['lang_selected'] ?>">
              <button type="submit" class="btn btn-default" name="submit"><?= R('btn_save') ?></button>
              </div>
              </form>
              </div>
              </div>
              </div>
            </div>
       </div>
</div> 
          