<h2>Localizations</h2>
<br />
<div class="panelHeader">
	<h3>Release Localization</h3>
</div>
<div class="panelContent">
<form action="/localization/saverelease" method="post">
<input type="hidden" name="releaseId" value="<?php echo $this->releaseId;?>">
	<table class="data localization-table" id="tblRelease">
			<tr style="width: 25%;">
				<th class="center">Release Name</th>
				<th class="center">Localization Language</th>
				<th class="center">Localization Text</th>
                <th class="center">Delivered Version</th>
			</tr>
			<tr>
				<td align="center"><?php echo $this->releaseName;?></td>
				<td colspan="3" class="locale-items" width="90%">
					<ul class="releaseName" id="<?php echo $this->releaseId; ?>">
					<?php if(isset($this->releaseLocalization->release) && !empty($this->releaseLocalization->release)) {
					        foreach ($this->releaseLocalization->release as $release) {
					    ?>
						<li>
							<div class="locale-item" style="width: 30%; padding: 5px;">
								<?=$this->formSelect('release[releaseName][languageId][]', $release->languageId, array('multiple' => false, 'class'=>'locale-language'), $this->languages)?>
							</div>
							<div class="locale-item" style="width: 30%; padding: 5px;">
							    <input type="text" value="<?php echo htmlentities($release->releaseName, ENT_QUOTES, 'UTF-8');?>" name="release[releaseName][languageValue][]">
							</div>
                            <div class="locale-item" style="width: 30%; padding: 5px;">
							    <input type="text" value="<?php echo htmlentities($release->deliveredVersion, ENT_QUOTES, 'UTF-8');?>" name="release[releaseName][deliveredVersion][]">
							</div>
							<div class="locale-remove"style="width: 5%;"> <a href="#">&times;</a></div>
						</li>
						<?php
					        }
					} ?>
					</ul>
				</td>
			</tr>
			<tr> <td colspan="4" align="right"><a href="javascript:localization.add('releaseName', 'release');">Add Localization</a></td></tr>
			<?php
            $artists = array();
            if (!empty($this->releaseArtists)) {
                foreach ( $this->releaseArtists as $artist ) {
                    if (in_array($artist->role, $this->localizedArtistTypes)) {
                        $artists[$artist->role][$artist->releaseArtistId] = array(
                            'artistName' => $artist->artistName
                        );
                    }
                }
            }

            $localizationArtists = array();
            if (!empty($this->releaseLocalization->releaseArtist)) {
                foreach ( $this->releaseLocalization->releaseArtist as $artist ) {
                    if (in_array($artist->role, $this->localizedArtistTypes)) {
                        $localizationArtists[$artist->role][$artist->releaseArtistId][] = array(
                            'artistName' => $artist->artistName,
                            'languageId' => $artist->languageId
                        );
                    }
                }
            }
           ?>
</table>
<?php
echo $this->partial('/localization/_artist.phtml', array('artists' => $artists, 'localizationArtists' => $localizationArtists, 'languages' => $this->languages));
?>
<div id="localization-save-btn">
    <input type="submit" value="Save Changes" class="btn btn-primary btn-sm" />
</div>
<div id="errMegs" class="errormsgForRelease"></div>
</form>
</div>
<?php  echo $this->partial("/localization/_listtracks.phtml", $this);?>
<?php  echo $this->partial("/localization/_addtemplate.phtml", $this);?>
<?php  echo $this->partial("/localization/_addartisttemplate.phtml", $this);?>
