<?php
use Orchard\FeatureFlags\Context\AccountContext;
use Orchard\FeatureFlags\FeatureService;

if (is_array($this->track) && count($this->track) > 0) {
    $classicalValue       = false;
    $isSoundtrackSubGenre = false;
    if (in_array($this->release->release_subgenre->SubGenre->orchard_id, \Service_Common::getSoundtrackSubgenres())) {
        $isSoundtrackSubGenre = true;
    }
    if ($this->release->ProductType->id == 1 && ($this->release->Genre->genre_id == 12 || $isSoundtrackSubGenre)) {
        $classicalValue = true;
    }
    $featureContext = array('user' => array('username' => $_SESSION['S_USERID']));

    $logger = Zend_Registry::get('applicationLoggerOA');
    $userContext = AccountContext::fromLegacy((string)$_SESSION['S_USERID'], 'oa');
    $featuresServiceClient = new FeatureService($logger);

    $isFocusTracksEnabled = $featuresServiceClient->isVariant(
        'incfeatures_focus_track_oa',
        'enabled',
        $userContext
    );

    $isSingleFocusTracksEnabled = $featuresServiceClient->isVariant(
        'incfeatures_single_focus_track_oa',
        'enabled',
        $userContext
    );

    $clickableForDigitalAudio = true;
    if ($this->isPhysicalRelease || !$this->allowedToApproveProducts) {
        $clickableForDigitalAudio = false;
    }
    ?>
    <div class='panelHeader'><h3>Tracks</h3></div>
    <div class='panelContent'>
        <table class="table table-input-select tracks-audio-table text-nowrap panel-grid">
            <thead>
                <tr>
                    <?php if ($this->isExcludePhysicalIsrcCountEnabled) {
                            if (!$this->isPhysicalRelease) { ?>
                                <th class="th-td-row-space"><b>ISRC Count</b></th>
                            <?php }
                    } else { ?>
                        <th class="th-td-row-space"><b>ISRC Count</b></th>
                    <?php } ?>
                    <th class="th-td-row-space"><b>Name</b></th>
                    <th class="th-td-row-space"><b>Track Version</b></th>
                    <th class="th-td-row-space"><b>Explicit</b></th>
                    <th class="th-td-row-space"><b>Primary Artist</b></th>
                    <?php if (!$classicalValue) { ?>
                        <th class="th-td-row-space"><b>Featuring</b></th>
                    <?php } ?>

                    <?php if (!$classicalValue && $this->isOAFeatureToPrimaryEnabled) { ?>
                        <th class="th-td-row-space ftp"><b>Display Featuring as Primary</b></th>
                    <?php } ?>

                    <th class="th-td-row-space"><b>Remixer</b></th>
                    <th class="th-td-row-space"><b>Producer</b></th>
                    <?php if ($classicalValue) { ?>
                        <th class="th-td-row-space"><b>Composer(s)</b></th>
                        <?php if (!$isSoundtrackSubGenre) { ?>
                            <th class="th-td-row-space"><b>Orchestra(s)</b></th>
                            <th class="th-td-row-space"><b>Ensemble(s)</b></th>
                            <th class="th-td-row-space"><b>Conductor(s)</b></th>
                        <?php }
                    } ?>
                    <th class="trackNumber th-td-row-space"><b>Volume - Track Number</b></th>
                    <?php if ($this->isPhysicalRelease) { ?>
                        <th class="th-td-row-space"><b>Side</b></th>
                    <?php } ?>
                    <th class="th-td-row-space"><b>Offer Type</b></th>
                    <th class="th-td-row-space"><b>ISRC</b></th>
                    <th class="th-td-row-space"><b>Track Duration</b></th>
                    <th class="th-td-row-space"><b>P-Line</b></th>
                    <th class="th-td-row-space"><b>Deduct Publishing</b></th>
                    <?php if (!$this->isPhysicalRelease) { ?>
                        <th><b>Track Lyrics</b></th>
                        <?php if ($isFocusTracksEnabled || $isSingleFocusTracksEnabled) { ?>
                            <th class="th-td-row-space"><b>Focus Track</b></th>
                        <?php } ?>
                    <?php } ?>
                    <th class="th-td-row-space"><b><?=($this->hasTrackAudioLanguage) ? 'Track Audio Language' : 'Language'?></b></th>
                    <th class="th-td-row-space"><b>Type</b></th>
                    <th class="th-td-row-space"><b>Listen</b></th>
                </tr>
            </thead>
            <?php
            $i             = 1;
            $trackVolume   = array();
            $iconPath      = '/images/reject.jpg';
            $musicIconPath = '/images/musicicon.gif';
            $videoIconPath = '/images/videoicon.gif';
            $arrTrackPath  = $this->arrTrackPath;
            $releaseStatus = $this->release->release_status;
            $arrTracklang  = $this->trackmetalanguage;
            $saleStartDate = $this->release->sale_start_date;

            foreach ($this->track as $track) {
                $arrTrackArtists        = array();
                $arrTrackArtistsValue   = array();
                $trackArray             = $this->Releasetrack(
                                              $track,
                                              $this->objReleaseCorrection
                                          );
                $trackNameValue         = $trackArray['trackNameValue'];
                $isTrackVersionChanged  = $trackArray['isTrackVersionChanged'];
                $trackVersion           = $trackArray['trackVersion'];
                $orgnlFileNameValue     = $trackArray['orgnlFileNameValue'];
                $explicitLyricsValue    = $trackArray['explicitLyricsValue'];
                $deductPublishing       = $trackArray['deductPublishing'];
                $pLineValue             = $trackArray['pLineValue'];
                $isVendorTrackIdChanged = $trackArray['isVendorTrackIdChanged'];
                $vendorTrackIdValue     = $trackArray['vendorTrackIdValue'];
                $arrTrackArtistsValue   = $trackArray['arrTrackArtistsValue'];
                $trackArtistValue       = $trackArray['trackArtistValue'];
                $trackComposerValue     = $trackArray['trackComposerValue'];
                $trackOrchestraValue    = $trackArray['trackOrchestraValue'];
                $trackConductorValue    = $trackArray['trackConductorValue'];
                $trackEnsembleValue     = $trackArray['trackEnsembleValue'];
                $trackFeaturingValue    = $trackArray['trackFeaturingValue'];
                $trackFeatureToPrimaryValue = $trackArray['trackFeatureToPrimaryValue'];
                $trackRemixerValue      = $trackArray['trackRemixerValue'];
                $trackProducerValue     = $trackArray['trackProducerValue'];
                $trackPublisherValue    = $trackArray['trackPublisherValue'];
                $trackWriterValue       = $trackArray['trackWriterValue'];
                $trackLanguageValue     = $trackArray['trackLanguageValue'];
                $correctionFields       = $trackArray['correctionFields'];
                $isTrackChenged         = $trackArray['isTrackChenged'];
                $trackClass             = $trackArray['trackClass'];
                $isRingtone             = $trackArray['isRingtone'];
                $isFocusTrack           = isset($track->focus_track) ? 'Yes' : 'No';
                $focusTrackStartDate    = isset($track->focus_track->start_date) ? $track->focus_track->start_date : "";
                $focusTrackEndDate      = isset($track->focus_track->end_date) ? $track->focus_track->end_date : "";
                $arrTrackArtists = isset($track->TrackArtist) ? ((array)$track->TrackArtist) : array();
                $performer     = isset($arrTrackArtists['performer']) ? implode(' | ', $arrTrackArtists['performer']) : "";
                $composer      = isset($arrTrackArtists['composer']) ? implode(' | ', $arrTrackArtists['composer']) : "";
                $orchestra     = isset($arrTrackArtists['orchestra']) ? implode(' | ', $arrTrackArtists['orchestra']) : "";
                $ensemble      = isset($arrTrackArtists['ensemble']) ? implode(' | ', $arrTrackArtists['ensemble']) : "";
                $conductor     = isset($arrTrackArtists['conductor']) ? implode(' | ', $arrTrackArtists['conductor']) : "";
                $featuring     = isset($arrTrackArtists['featuring']) ? implode(' | ', $arrTrackArtists['featuring']) : "";
                $featureToPrimary = isset($arrTrackArtists['feature_to_primary']) ? implode(' | ', $arrTrackArtists['feature_to_primary']) : "";
                $remixer       = isset($arrTrackArtists['remixer']) ? implode(' | ', $arrTrackArtists['remixer']) : "";
                $producer      = isset($arrTrackArtists['producer']) ? implode(' | ', $arrTrackArtists['producer']) : '';
                $key           = 'db' . $track->id;
                $trackPath     = isset($arrTrackPath[$key]['path']) ? $arrTrackPath[$key]['path'] : "";
                $trackDuration = isset($arrTrackPath[$key]['duration']) ? $arrTrackPath[$key]['duration'] : "";
                $trackLanguage = $arrTracklang[$key];
                $class = '';
                $classTrackDurationError = '';
                if (($this->isNewThirtySecondReleaseApprovalWarningEnabled && $releaseStatus != 'in_content' && $this->isReleaseLessThanThirtySeconds && $isRingtone) ||
                    ($releaseStatus != 'in_content' && $this->isRingtoneRelease)){
                        $class = 'full-error-rejection';
                        $classTrackDurationError = 'track-duration-error';
                } ?>
                <tr class='<?=($class ? $class : "");?>'>
                    <?php if ($this->isExcludePhysicalIsrcCountEnabled) {
                            if (!$this->isPhysicalRelease) { ?>
                                <td class="th-td-row-space" align="left">
                                    <?php echo $this->releaseApprovalPresenterObj->getIsrcCountLink($track); ?>
                                </td>
                        <?php } ?>
                    <?php } else { ?>
                        <td class="th-td-row-space" align="left">
                            <?php echo $this->releaseApprovalPresenterObj->getIsrcCountLink($track); ?>
                        </td>
                    <?php } ?>
                    <td class="th-td-row-space" align="left">
                        <span id="spantrack_name<?=$track->id?>"
                            <?php
                            if ($clickableForDigitalAudio) { ?>
                                onclick="createInputBox(
                                    'track_name',
                                    'Track <?=$track->track_id?>Name',
                                    'track',
                                    '<?=$track->id?>',
                                    '<?=htmlentities(addslashes($track->track_name), ENT_QUOTES, "UTF-8")?>',
                                    '<?=$track->cd?>'
                                );"
                            <?php
                            } ?>
                            class="tool error-correction-space">
                            <div id="lbltrack_name<?=$track->id?>"
                                <?php if (!empty($trackNameValue)) {
                                    $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                    $titleHtml .= "Name</label><span class='full-width pull-left'>" . htmlspecialchars($trackNameValue, ENT_QUOTES, 'UTF-8') . "</span>";
                                ?>
                                    title="<?=$titleHtml?>" class="no-margin no-padding error-correction-field approval-field"
                                <?php } ?> class="no-margin no-padding approval-field">
                                <span class="changeColor"
                                    id='changedtrack1_<?=$track->id?>'><?=htmlspecialchars($track->track_name)?>
                                </span>
                            </div>
                        </span>
                    </td>
                    <td class="th-td-row-space" align="left">
                        <span id="spanversion<?=$track->id?>"
                            <?php
                            if ($clickableForDigitalAudio) { ?>
                                onclick="createInputBox(
                                    'version',
                                    'Track <?=$track->track_id?>Version',
                                    'track',
                                    '<?=$track->id?>',
                                    '<?=htmlentities($track->version, ENT_QUOTES, "UTF-8")?>',
                                    '<?=$track->cd?>'
                                );"
                            <?php
                            } ?>
                            class="tool error-correction-space">
                            <div id="lbltrack_version<?php echo $track->id;?>"
                                <?php
                                    $titleAttribute = '';
                                    if ($isTrackVersionChanged) {
                                        if (!empty($trackVersion)) {
                                            $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                            $titleHtml .= "Track Version</label><span class='full-width pull-left'>" . $trackVersion . "</span>";
                                            $titleAttribute = ' title="' . $titleHtml . '"';
                                        }
                                ?> class="no-margin no-padding error-correction-field approval-field"
                                <?php } ?> class="no-margin no-padding approval-field" <?=$titleAttribute?>>
                                <span class="changeColor" id="changedtrack1_<?=$track->id?>"><?=$track->version?></span>
                            </div>
                        </span>
                    </td>
                    <td class="th-td-row-space" align="left">
                        <span id="spanexplicit_lyrics<?=$track->id?>"
                            <?php
                            if ($clickableForDigitalAudio) { ?>
                                onclick="createInputBox(
                                    'explicit_lyrics',
                                    'Track <?=$track->track_id?>Explicit',
                                    'track',
                                    '<?=$track->id?>',
                                    '<?=htmlentities($track->explicit_lyrics, ENT_QUOTES)?>',
                                    '<?=$track->cd?>'
                                );"
                            <?php
                            } ?>
                            class="tool error-correction-space">
                            <div id="lblexplicit_lyrics<?=$track->id?>"
                                <?php if (!empty($explicitLyricsValue)) {
                                    $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                    $titleHtml .= "Explicit</label><span class='full-width pull-left'>" . $explicitLyricsValue . "</span>";
                                ?>
                                    title="<?=$titleHtml?>" class="no-margin no-padding error-correction-field approval-field"
                                <?php } ?> class="no-margin no-padding approval-field">
                                <span class="changeColor" id="changedtrack10_<?=$track->id?>"><?=$track->explicit_lyrics?></span>
                            </div>
                        </span>
                    </td>
                    <td class="th-td-row-space" align="left">
                        <span id="spantrack_artist<?=$track->id?>"
                            <?php
                            if ($clickableForDigitalAudio) { ?>
                                onclick="createInputBox(
                                    'track_artist',
                                    'Track <?=$track->track_id?>Artist',
                                    'track',
                                    '<?=$track->id?>',
                                    '<?=htmlentities(addslashes($performer), ENT_QUOTES, "UTF-8")?>',
                                    '<?=$track->cd?>'
                                );"
                            <?php
                            } ?>
                            class="tool error-correction-space">
                            <div id="lbltrack_artist<?=$track->id?>"
                                <?php
                                    $titleAttribute = '';
                                    if (in_array('performers', $correctionFields) && $performer != "") {
                                        if (!empty($trackArtistValue)) {
                                            $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                            $titleHtml .= "Primary Artist</label><span class='full-width pull-left'>" . $trackArtistValue . "</span>";
                                            $titleAttribute = ' title="' . $titleHtml . '"';
                                        }
                                    ?>
                                    class="no-margin no-padding error-correction-field approval-field"
                                <?php } ?> class="no-margin no-padding approval-field" <?=$titleAttribute?>>
                                <span class="changeColor" id="changedtrack2_<?=$track->id?>"><?=$performer?></span>
                            </div>
                        </span>
                    </td>
                    <?php if (!$classicalValue) { ?>
                        <td class="th-td-row-space" align="left">
                            <span id="spantrack_featuring<?=$track->id?>"
                                <?php if ($clickableForDigitalAudio) { ?>
                                    onclick="createInputBox(
                                        'track_featuring',
                                        'Track <?=$track->track_id?>featuring',
                                        'track',
                                        '<?=$track->id?>',
                                        '<?=htmlentities(addslashes($featuring), ENT_QUOTES, "UTF-8")?>',
                                        '<?=$track->cd?>'
                                    );"
                                <?php } ?>
                                class="tool error-correction-space">
                                <div id="lbltrack_featuring<?=$track->id?>"
                                    <?php
                                        $titleAttribute = '';
                                        if (in_array('featuring', $correctionFields)) {
                                            if (!empty($trackFeaturingValue)) {
                                                $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                                $titleHtml .= "Featuring</label><span class='full-width pull-left'>" . $trackFeaturingValue . "</span>";
                                                $titleAttribute = ' title="' . $titleHtml . '"';
                                            }
                                    ?>
                                    class="no-margin no-padding error-correction-field approval-field"
                                    <?php } ?> class="no-margin no-padding approval-field" <?=$titleAttribute?>>
                                    <span class="changeColor" id="changedtrack1_<?=$track->id?>"><?=$featuring?></span>
                                </div>
                            </span>
                        </td>
                    <?php
                    } ?>

                    <?php if (!$classicalValue && $this->isOAFeatureToPrimaryEnabled) {?>
                        <td class="th-td-row-space ftp" align="left">
                            <span id="spanfeature_to_primary<?=$track->id?>"
                                <?php if ($clickableForDigitalAudio) {
                                    // fieldName,title,tableName,keyId,str,volume
                                ?>
                                    onclick="createInputBox(
                                        'feature_to_primary',
                                        'Track <?=$track->track_id?>feature_to_primary',
                                        'track',
                                        '<?=$track->id?>',
                                        '<?=htmlentities(addslashes($featureToPrimary), ENT_QUOTES, "UTF-8")?>',
                                        '<?=$track->cd?>'
                                    );"
                                <?php } ?>
                                class="tool error-correction-space">
                                <div id="lbltrack_feature_to_primary<?=$track->id?>"
                                    <?php
                                        $titleAttribute = '';
                                        if (in_array('feature_to_primary', $correctionFields)) {
                                            if (!empty($trackFeatureToPrimaryValue)) {
                                                $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                                $titleHtml .= "FeatureToPrimary</label><span class='full-width pull-left'>" . $trackFeatureToPrimaryValue . "</span>";
                                                $titleAttribute = ' title="' . $titleHtml . '"';
                                            }
                                    ?>
                                    class="no-margin no-padding error-correction-field approval-field"
                                    <?php } ?> class="no-margin no-padding approval-field" <?=$titleAttribute?>>
                                    <span class="changeColor" id="changedtrack1_<?=$track->id?>"><?=$featureToPrimary?></span>
                                </div>
                            </span>
                        </td>
                    <?php } ?>

                    <td class="th-td-row-space" align="left">
                        <span id="spantrack_remixer<?=$track->id?>"
                            <?php
                            if ($clickableForDigitalAudio) { ?>
                                onclick="createInputBox(
                                    'track_remixer',
                                    'Track <?=$track->track_id?>remixer',
                                    'track',
                                    '<?=$track->id?>',
                                    '<?=htmlentities(addslashes($remixer), ENT_QUOTES, "UTF-8")?>',
                                    '<?=$track->cd?>'
                                );"
                            <?php
                            } ?>
                            class="tool error-correction-space">
                            <div id="lbltrack_remixer<?=$track->id?>"
                                <?php
                                    $titleAttribute = '';
                                    if (in_array('remixer', $correctionFields) && $remixer != "") {
                                        if (!empty($trackRemixerValue)) {
                                            $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                            $titleHtml .= "Remixer</label><span class='full-width pull-left'>" . $trackRemixerValue . "</span>";
                                            $titleAttribute = ' title="' . $titleHtml . '"';
                                        }
                                ?>
                                class="no-margin no-padding error-correction-field approval-field"
                                <?php } ?> class="no-margin no-padding approval-field" <?=$titleAttribute?>>
                                <span class="changeColor" id="changedtrack2_<?=$track->id?>"><?=$remixer?></span>
                            </div>
                        </span>
                    </td>
                    <td class="th-td-row-space" align="left">
                        <span id="spanproducer<?=$track->id?>"
                            <?php
                            if ($clickableForDigitalAudio) { ?>
                                onclick="createInputBox(
                                    'producer',
                                    'Track <?=$track->track_id?> Producer',
                                    'track',
                                    '<?=$track->id?>',
                                    '<?=htmlentities(addslashes($producer), ENT_QUOTES, "UTF-8")?>',
                                    '<?=$track->cd?>'
                                );"
                            <?php
                            } ?>
                            class="tool error-correction-space">
                            <div id="lblproducer<?=$track->id?>"
                                <?php
                                    $titleAttribute = '';
                                    if (in_array('producer', $correctionFields)) {
                                        if (!empty($trackProducerValue)) {
                                            $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                            $titleHtml .= "Producer</label><span class='full-width pull-left'>" . $trackProducerValue . "</span>";
                                            $titleAttribute = ' title="' . $titleHtml . '"';
                                        }
                                ?>
                                    class="no-margin no-padding error-correction-field approval-field"
                                <?php } ?> class="no-margin no-padding approval-field" <?=$titleAttribute?>>
                                <span class="changeColor" id="changedtrack2_<?=$track->id?>"><?=$producer?></span>
                            </div>
                        </span>
                    </td>
                    <?php if ($classicalValue) { ?>
                        <td class="th-td-row-space" align="left">
                            <span id="spancomposer<?=$track->id?>"
                                <?php if ($clickableForDigitalAudio) { ?>
                                    onclick="createInputBox(
                                        'composer',
                                        'Track <?=$track->track_id?> Composer',
                                        'track',
                                        '<?=$track->id?>',
                                        '<?=htmlentities(addslashes($composer), ENT_QUOTES, "UTF-8")?>',
                                        '<?=$track->cd?>'
                                    );"
                                <?php } ?>
                                class="tool error-correction-space">
                                <div id='lblcomposer<?=$track->id?>'
                                    <?php
                                        $titleAttribute = '';
                                        if (in_array('composers', $correctionFields) && $composer != "") {
                                            if (!empty($trackComposerValue)) {
                                                $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                                $titleHtml .= "Composer(s)</label><span class='full-width pull-left'>" . $trackComposerValue . "</span>";
                                                $titleAttribute = ' title="' . $titleHtml . '"';
                                            }
                                    ?>
                                        class="no-margin no-padding error-correction-field approval-field"
                                    <?php } ?> class="no-margin no-padding approval-field" <?=$titleAttribute?>>
                                    <span <?php echo ''; ?> id="changedtrack5_<?=$track->id?>"><?=$composer?></span>
                                </div>
                            </span>
                        </td>
                        <?php if (!$isSoundtrackSubGenre) { ?>
                            <td class="th-td-row-space" align="left">
                                <span id="spanorchestra<?=$track->id?>"
                                    <?php
                                    if ($clickableForDigitalAudio) { ?>
                                        onclick="createInputBox(
                                            'orchestra',
                                            'Track <?=$track->track_id?> Orchestra',
                                            'track',
                                            '<?=$track->id?>',
                                            '<?=htmlentities(addslashes($orchestra), ENT_QUOTES, "UTF-8")?>',
                                            '<?=$track->cd?>'
                                        );"
                                    <?php
                                    } ?>
                                    class="tool error-correction-space">
                                    <div id="lblorchestra<?=$track->id?>"
                                        <?php
                                            $titleAttribute = '';
                                            if (in_array('orchestras', $correctionFields) && $orchestra != "") {
                                                if (!empty($trackOrchestraValue)) {
                                                    $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                                    $titleHtml .= "Orchestra(s)</label><span class='full-width pull-left'>" . $trackOrchestraValue . "</span>";
                                                    $titleAttribute = ' title="' . $titleHtml . '"';
                                                }
                                        ?>
                                            class="no-margin no-padding error-correction-field approval-field"
                                        <?php } ?> class="no-margin no-padding approval-field" <?=$titleAttribute?>>
                                        <span <?php echo ''; ?> id="changedtrack6_<?=$track->id?>"><?=$orchestra?></span>
                                    </div>
                                </span>
                            </td>
                            <td class="th-td-row-space" align="left">
                                <span id="spanensemble<?=$track->id?>"
                                    <?php
                                    if ($clickableForDigitalAudio) { ?>
                                        onclick="createInputBox(
                                            'ensemble',
                                            'Track <?=$track->track_id?>Ensemble',
                                            'track',
                                            '<?=$track->id?>',
                                            '<?=htmlentities(addslashes($ensemble), ENT_QUOTES, "UTF-8")?>',
                                            '<?=$track->cd?>'
                                        );"
                                    <?php
                                    } ?>
                                    class="tool error-correction-space">
                                    <div id='lblensemble<?=$track->id?>'
                                        <?php
                                            $titleAttribute = '';
                                            if (in_array('ensembles', $correctionFields) && $ensemble != "") {
                                                if (!empty($trackEnsembleValue)) {
                                                    $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                                    $titleHtml .= "Ensemble(s)</label><span class='full-width pull-left'>" . $trackEnsembleValue . "</span>";
                                                    $titleAttribute = ' title="' . $titleHtml . '"';
                                                }
                                        ?>
                                            class="no-margin no-padding error-correction-field approval-field"
                                        <?php } ?> class="no-margin no-padding approval-field" <?=$titleAttribute?>>
                                        <span <?php echo ''; ?> id="changedtrack7_<?=$track->id?>"><?=$ensemble?></span>
                                    </div>
                                </span>
                            </td>
                            <td class="th-td-row-space" align="left">
                                <span id="spanconductor<?=$track->id?>"
                                    <?php
                                    if ($clickableForDigitalAudio) { ?>
                                        onclick="createInputBox(
                                            'conductor',
                                            'Track <?=$track->track_id?>Conductor',
                                            'track',
                                            '<?=$track->id?>',
                                            '<?=htmlentities(addslashes($conductor), ENT_QUOTES, "UTF-8")?>',
                                            '<?=$track->cd?>'
                                        );"
                                    <?php
                                    } ?>
                                    class="tool error-correction-space">
                                    <div id="lblconductor<?=$track->id?>"
                                        <?php
                                             $titleAttribute = '';
                                             if (in_array('conductors', $correctionFields) && $conductor != "") {
                                                 if (!empty($trackConductorValue)) {
                                                     $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                                     $titleHtml .= "Conductor(s)</label><span class='full-width pull-left'>" . $trackConductorValue . "</span>";
                                                     $titleAttribute = ' title="' . $titleHtml . '"';
                                                 }
                                        ?>
                                            class="no-margin no-padding error-correction-field approval-field"
                                        <?php } ?> class="no-margin no-padding approval-field" <?=$titleAttribute?>>
                                        <span <?php echo ''; ?> id="changedtrack8_<?=$track->id?>"><?=$conductor?></span>
                                    </div>
                                </span>
                            </td>
                        <?php }
                    } ?>
                    <td class="th-td-row-space" align="left"><?=($track->cd . ' - ' . $track->track_id)?></td>
                    <?php if ($this->isPhysicalRelease) { ?>
                        <td class="th-td-row-space" align="left"><?=$track->track_side ?></td>
                    <?php } ?>
                    <td align="center" class="th-td-row-space"><?=($track->offer_type)?></td>
                    <td class="th-td-row-space" align="left"><?=($track->isrc)?></td>
                    <td class='th-td-row-space <?=($classTrackDurationError ? $classTrackDurationError : "");?>' align="left">
                        <span class="error-correction-space">
                            <?=sprintf('%02d', $track->length_minute/60)?>:
                            <?=sprintf('%02d', $track->length_minute%60)?>:
                            <?=sprintf('%02s', $track->length_seconds);?>
                        </span>
                    </td>
                    <td class="th-td-row-space" align="left">
                        <span id="spanp_line<?=$track->id?>"
                            <?php
                            if ($clickableForDigitalAudio) { ?>
                                onclick="createInputBox(
                                    'p_line',
                                    'Track <?=$track->track_id?> P-Line',
                                    'track',
                                    '<?=$track->id?>',
                                    '<?=htmlentities($track->p_line, ENT_QUOTES, "UTF-8")?>',
                                    '<?=$track->cd?>'
                                );"
                            <?php
                            } ?>
                            class="tool error-correction-space">
                            <div id="lblp_line<?=$track->id?>"
                                <?php if (!empty($pLineValue)) {
                                    $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                    $titleHtml .= "P-Line</label><span class='full-width pull-left'>" . $pLineValue . "</span>";
                                ?>
                                    title="<?=$titleHtml?>" class="no-margin no-padding error-correction-field approval-field"
                                <?php } ?> class="no-margin no-padding approval-field">
                                <span class="changeColor" id="changedtrack11_<?=$track->id?>"><?=$track->p_line?></span>
                            </div>
                        </span>
                    </td>
                    <td
                    <?php if ($releaseStatus == 'in_content') { ?>
                        class='noClick'
                    <?php } ?> class="th-td-row-space" align="left">
                        <span id="spanthird_party_publisher<?=$track->id?>"
                            <?php
                            if ($releaseStatus != 'in_content') {
                                if ($clickableForDigitalAudio) { ?>
                                    onclick="createInputBox(
                                        'third_party_publisher',
                                        'Track<?=$track->track_id?>Third_Party_Publisher',
                                        'track',
                                        '<?=$track->id?>',
                                        '<?=htmlentities($track->third_party_publisher, ENT_QUOTES)?>',
                                        '<?=$track->cd?>'
                                    );"
                                <?php
                                }
                            }
                            ?>
                            class="tool error-correction-space">
                            <div id="lblthird_party_publisher<?=$track->id?>"
                                <?php if (!empty($deductPublishing)) {
                                    $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                    $titleHtml .= "Deduct Publishing</label><span class='full-width pull-left'>" . $deductPublishing . "</span>";
                                ?>
                                    title="<?=$titleHtml?>" class="no-margin no-padding error-correction-field approval-field"
                                <?php } ?> class="no-margin no-padding approval-field">
                                <span class="changeColor" id="changedtrack11_<?=$track->id;?>"><?=$track->third_party_publisher?></span>
                            </div>
                        </span>
                    </td>
                    <?php
                    if (!$this->isPhysicalRelease) { ?>
                        <td class="th-td-row-space" align="left">
                            <span id="spanlyrics<?=$track->id?>" class="<?php echo !empty($this->lyricsInfo[$track->id]['lyrics_corrected']) ? 'errorCorrection_yellow' : ''; ?> tool error-correction-space">
                                <?php
                                if (!empty($this->lyricsInfo[$track->id]['has_lyrics'])) { ?>
                                    <a class="popTriggerZFPages" href="/relationships/viewtracklyrics?track_id=<?=$track->id?>&product_id=<?=$this->release->release_id?>" target="_blank">Yes</a>
                                    <?php
                                } elseif ($this->lyricsInfo[$track->id]['is_warning']) { ?>
                                    <div class ="no-margin no-padding approval-field error-rejection-field" title="This release does not contain track lyrics"></div>No
                          <?php } elseif ($this->lyricsInfo[$track->id]['is_warning']) { ?>
                                    <div class ="no-margin no-padding approval-field error-rejection-field" title="This priority release does not contain track lyrics"></div>No
                                <?php } else { ?>
                                   No
                                <?php } ?>
                            </span>
                        </td>

                        <?php if ($isFocusTracksEnabled || $isSingleFocusTracksEnabled) { ?>
                            <td class="th-td-row-space" align="left">
                                <span id="spanfocus_track<?=$track->id?>"
                                    <?php if ($clickableForDigitalAudio) { ?>
                                        onclick="createInputBox(
                                            'focus_track',
                                            'Track <?=$track->track_id?> Focus Track',
                                            'track',
                                            '<?=$track->id?>',
                                            '<?=htmlentities($isFocusTrack, ENT_QUOTES, "UTF-8")?>',
                                            '<?=$track->cd?>'
                                        );"
                                    <?php } ?>
                                    class="tool error-correction-space">
                                    <div id="lblfocus_track<?=$track->id?>" class="no-margin no-padding approval-field">
                                        <span class="changeColor" id="changedtrack11_<?=$track->id?>">
                                            <?php if ($isFocusTracksEnabled && $focusTrackStartDate >= $saleStartDate) { ?>
                                                <div class ="no-margin no-padding focus-track-info" title="Focus track start date comes after sales start date."></div>
                                            <?php } ?>
                                            <?=$isFocusTrack?>
                                            <?php if ($isFocusTracksEnabled && isset($track->focus_track)) { ?>
                                                <br>
                                                <?=$focusTrackStartDate?> - <?=$focusTrackEndDate?>
                                            <?php } ?>
                                        </span>

                                    </div>
                                </span>
                            </td>
                        <?php } ?>

                    <?php } ?>
                    <td class="th-td-row-space" align="left">
                        <span id="spanmeta_language<?=$track->id?>"
                            <?php
                            if ($trackLanguage == 'Mandarin (Simplified)') {
                                $trackLanguage = 'Mandarin';
                            } elseif ($trackLanguage == 'Mandarin (Traditional)') {
                                $trackLanguage = 'Cantonese';
                            }
                            if ($clickableForDigitalAudio) { ?>
                                onclick="createInputBox(
                                    'meta_language',
                                    'Track <?=$track->track_id?>Language',
                                    'track',
                                    '<?=$track->id?>',
                                    '<?=htmlentities($trackLanguage, ENT_QUOTES)?>',
                                    '<?=$track->cd?>'
                                );"
                            <?php
                            } ?>
                            class="tool error-correction-space">
                            <div id="lblmeta_language<?=$track->id?>"
                                <?php if (!empty($trackLanguageValue)) {
                                    $titleHtml = "<div class='font-weight'>Corrected</div><label class='top-space zero-margin-bottom'>";
                                    $titleHtml .= "Track Audio Language</label><span class='full-width pull-left'>" . $trackLanguageValue;
                                    $titleHtml .= "</span>";
                                ?>
                                    title="<?=$titleHtml?>" class="no-margin no-padding error-correction-field approval-field"
                                <?php } ?> class="no-margin no-padding approval-field">
                                <span class="changeColor" id="changedtrack12_<?=$track->id?>"><?=$trackLanguage?></span>
                            </div>
                        </span>
                    </td>
                    <?php $trackImage = ($track->track_type == 'video') ? $videoIconPath : $musicIconPath; ?>
                    <td class="th-td-row-space">
                        <span id="spantrack_type<?=$track->id?>" class="tracks-audio-music">
                            <div class="pull-left tracks-audio-player top-space">
                                <span><?=$track->track_type?></span>
                            </div>
                            <div class="pull-left">
                                <img src="<?=$trackImage?>" alt="<?=$track->track_type?>" class="trackicon">
                            </div>
                        </span>
                    </td>
                    <td class="th-td-row-space" align="left">
                        <div id="spanoriginal_file_name<?=$track->id?>" class="tracks-audio-music error-correction-space">
                            <div id="mediacontainer_db<?=$track->id?>" class="pull-left <?=$trackClass?>">
                                <div id='smallPlayerdb<?=$track->id?>'>
                                    <div class="audioUploadStatus">
                                        <div class="time notDisplay"
                                             id='totaltimedb<?=$track->id?>'><?=$trackDuration?></div>
                                                <a href="/streaming/product/<?= $this->release->release_id ?>/track/<?= $track->id ?>/stream"
                                                    onClick="window.open('/streaming/product/<?= $this->release->release_id ?>/track/<?= $track->id ?>/stream<?=($this->isAnyTrackChange) ? '/correction/correction' : ''?>', '_blank', 'width=800,height=60,resizable'); return false;"
                                                    target="_blank"
                                                    class="player-link"
                                                >
                                                <img src="/images/play.svg" height="16" alt="listen" border=0 align="absmiddle">
                                                </a>
                                    </div>
                                </div>
                            </div>
                            <img src="<?=$iconPath?>" alt="Reject"
                            <?php
                            if ($clickableForDigitalAudio) { ?>
                                onclick="createInputBox(
                                    'original_file_name',
                                    'Track <?=$track->track_id?>Player',
                                    'track',
                                    '<?=$track->id?>',
                                    '<?=htmlentities($track->original_file_name, ENT_QUOTES)?>',
                                    '<?=$track->cd?>'
                                );"
                            <?php
                            } ?>
                            id="rejectPlayer" class="rejectPlayer pull-left tracks-audio-player">
                        </div>
                    </td>
                </tr>
                <?php
                $i++;
            } ?>
        </table>
    </div>
<?php } else { ?>
    <div class='data'>No track found</div>
<?php } ?>
<input type='hidden' id='trackVolume' value="<?=(isset($trackVolume) ? count($trackVolume) : 0)?>">
