<?php
$updateLanguageId = array();
if (isset($this->releaseLocalization['items']) && !empty($this->releaseLocalization['items'])) {
    foreach ($this->releaseLocalization['items'] as $release) {
        $updateLanguageId[] = $release['language_id'];
    }
}
?>

<h2>Localizations</h2>
<br>
<div class="panelHeader">
	<h3>Release Localization</h3>
</div><!-- /.panelHeader -->

<!-- hidden fields -->
<input type="hidden" id="short-synopsis" value="<?=$this->shortSynopsis?>" />
<input type="hidden" id="long-synopsis" value="<?=$this->longSynopsis?>" />
<!-- /hidden fields -->

<div class="panelContent">

    <form action="/localization/saverelease" method="post">

        <input type="hidden" name="releaseId" value="<?=$this->releaseId?>" />
        <input type="hidden" name="productType" value="<?=$this->productType?>" />
        <input type="hidden" name="deleteLanguageId" id="deleteLanguage" value="" />
        <input type="hidden" name="updateLanguageId" id="updateLanguage" value="<?=implode(',', $updateLanguageId)?>" />

        <table class="data localization-table">
            <tr>
                <th class="center" width="19%">&nbsp;</th>
                <th class="center" width="23%">Release Name</th>
                <th class="center more" width="28%">Long Synopsis</th>
                <th class="center more" width="30%">Short Synopsis</th>
            </tr>
            <tr>
                <td class="center">&nbsp;</td>
                <td class="center"><div><?=$this->releaseName?></div></td>
                <td class="center more"><div class="hide"><?=$this->longSynopsis?></div></td>
                <td class="center more"><div class="hide"><?=$this->shortSynopsis?></div></td>
            </tr>
        </table>

        <table class="data localization-table releaseName" id="<?=$this->releaseId?>">
            <tr>
                <th class="center"  width="19%">Localization Language</th>
                <th class="center" width="23%">Release Name Localization<span class="required">*</span></th>
                <th class="center" width="28%">Long Synopsis Localization<span class="required">*</span></th>
                <th class="center" width="30%">Short Synopsis Localization</th>
            </tr>

        <?php $count = 1;
        if (isset($this->releaseLocalization['items']) && !empty($this->releaseLocalization['items'])) {
            foreach ($this->releaseLocalization['items'] as $release) {
        ?>
            <tr>
                <td class="locale-item-film center" >
                    <?=$this->formSelect('release[' . $count . '][language_id]', $release['language_id'], array('multiple' => false, 'class'=>'locale-language','style'=>'width:90%;'), $this->languages)?>
                </td>
                <td class="locale-item-film center">
                    <input type="text" name="release[<?=$count?>][product_name]" value="<?=trim($release['product_name'])?>" />
                </td>
                <td class="locale-item-film center">
                    <textarea class="textField film-textarea long-synopsis" name="release[<?=$count?>][long_synopsis]"><?=trim($release['long_synopsis'])?></textarea>
                </td>
                <td class="locale-item-film center">
                    <textarea class="textField film-textarea short-synopsis" name="release[<?=$count?>][short_synopsis]"><?=trim($release['short_synopsis'])?></textarea>
                    <div class="film-locale-remove"> <a href="javascript:void(0);" onclick="filmLocalization.remove(this,<?=$release['language_id']?>);" title="Remove Localization">&times;</a></div>
                </td>
            </tr>
        <?php $count++;
            }
        } ?>

        </table><!-- /.releaseName -->

        <table class="data localization-table">
            <tr>
                <td class="right"><a href="javascript:filmLocalization.add('releaseName', 'release');" title="Add Localization">Add Localization</a></td>
            </tr>
        </table>

        <div id="localization-save-btn">
            <input type="submit" value="Save Changes" title="Save Changes" class="btn btn-primary btn-sm" />
        </div><!-- /#localization-save-btn -->

        <div id="errMsgFilm" class="errormsgForRelease film-local-errorMsg"></div>

    </form><!-- form -->

</div><!-- /.panelContent -->

<?=$this->partial("/localization/_addfilmtemplate.phtml", $this)?>
