<?php
use Orchard\Common\Proxy;
use Orchard\Service\GrassAuth;

$configuration = Zend_Registry::get('configuration');
$oauthConfig = new Vectorapi\ApiConfig($configuration);
$oauthConfig->setVapiConfig('oa', $_SESSION['S_USERID']);
$logger = Zend_Registry::get('applicationLoggerOA');
$awsConfig = yaml_parse_file(APPLICATION_PATH . '/configs/aws.yml');

include_once(APPLICATION_PATH . '/../public/oa/includes/suite_oa_application.inc');

if (!empty($this->subaccount->dateDeleted->date)) {
    $subaccountName = '<del>' . $this->subaccount->subaccountName. '</del>';
} else {
    $subaccountName = $this->subaccount->subaccountName;
}
 $this->placeholder('breadcrumb')->set('<a href="/relationships.php">Relationships</a> > <a href="/cont_mgmt/view_vendor.php?vendor_id='.$this->subaccount->vendor->vendorId.'">'.(trim($this->subaccount->vendor->vendorName) != '' ? $this->subaccount->vendor->vendorName : $this->subaccount->vendor->company).'</a> > '.$this->subaccount->subaccountName);
 $url = "/subaccount/viewsubaccount/subaccount_id/".$this->subaccount->subaccountId;
 $this->placeholder('itemDiv')->set("<h1>". $subaccountName ."</h1><ul id='itemInfo'>
	<li>Sub Account ID: <a href=$url>".$this->subaccount->subaccountId."</a></li></ul>");
?>
<div class="panelHeader">
			<h3>Sub Account Info</h3>
			<?php
				if (!$this->viewVendorPermission) {
			?>
			<ul>
				<li><a href="/subaccount/editsubaccount/subaccount_id/<?=$this->subaccount->subaccountId?>">Edit</a></li>
			</ul>
			<?php
				}
			?>
</div>
<div class="panelContent">
	<table class="form">
		<tr>
			<th>Sub Account Name:</th>
			<td><?=$this->subaccount->subaccountName?></td>
		</tr>
		<tr>
			<th>Genre:</th>
			<td><?=isset($this->subaccount->genre) ? $this->subaccount->genre->genreName : ''?></td>
		</tr>
		<tr>
			<th>Website Url:</th>
			<td><?=$this->subaccount->websiteUrl?></td>
		</tr>
		<tr>
			<th>Myspace Url:</th>
			<td><?=$this->subaccount->myspaceUrl?></td>
		</tr>
		<tr>
			<th>City:</th>
			<td><?=$this->subaccount->city?></td>
		</tr>
		<tr>
			<th>State Province:</th>
			<td><?=$this->stateName?></td>
		</tr>
		<tr>
			<th>Country:</th>
			<td><?=isset($this->subaccount->country)? $this->subaccount->country->countryName:''?></td>
		</tr>

		<tr>
			<th>Soundscan US Code:</th>
			<td><?=isset($this->soundscanCodes[1]) ? $this->soundscanCodes[1] : ''?></td>
		</tr>

		<tr>
			<th>Soundscan CA Code:</th>
			<td><?=isset($this->soundscanCodes[2]) ? $this->soundscanCodes[2] : ''?></td>
		</tr>
		<tr>
			<th>Revenue Display Split:</th>
			<td><?=isset($this->subaccount->commissionOverride)? ($this->subaccount->commissionOverride*100).'%':''?></td>
		</tr>
	    <tr>
	        <th>Revenue Split Type:</th>
	        <td><?=isset($this->subaccount->subaccountSplitType) ? $this->subaccount->subaccountSplitType : ''?></td>
	    </tr>
		<tr>
			<th>Description:</th>
			<td><?=isset($this->subaccount->description)? $this->subaccount->description:''?></td>
		</tr>
	</table>
</div>
<?php echo $this->partial('subaccount/_subaccountcontacts.phtml', array('view' => $this));
	if (!$this->viewVendorPermission) {
	  echo $this->partial('subaccount/_catalog.phtml', array('view' => $this));
	}

if (!$this->viewVendorPermission) {
?>
<div class="panelHeader">
	<h3>Current Restrictions</h3>
	<ul>
		<li><a href="/subaccount/editsubaccountcarveout/subaccount_id/<?=$this->subaccount->subaccountId;?>">Edit</a></li>
	</ul>
</div>
<div class="panelContent">
<?php echo $this->partial('subaccount/_viewsubaccountcarveout.phtml', array('view' => $this));?>
</div>
<div class="panelHeader">
	<h3>Royalty Collections</h3>
	<ul>
		<li><a href="/subaccount/editroyaltycollectionterritories/subaccount_id/<?=$this->subaccount->subaccountId;?>">Edit</a></li>
	</ul>
</div>
<div class="panelContent">
<?php echo $this->partial('subaccount/_viewsubaccountroyaltycollection.phtml', array('view' => $this));?>
</div>
    <script type="text/javascript">
        embedSuiteModule('fingerprint-rules', { vendorId: <?=$this->subaccount->vendor->vendorId?>, subaccountId: <?=$this->subaccount->subaccountId;?> });
    </script>
<div class="panelHeader" id="performancerightsdeliverysettings_header">
    <h3>Performance Rights Delivery Settings</h3>
    <ul>
        <li>
            <a href="/subaccount/editperformancerightsdeliverysettings/subaccount_id/<?=$this->subaccount->subaccountId?>" class="btn btn-link btn-sm">Edit</a>
        </li>
    </ul>
</div>
<div class="panelContent" id="performancerightsdeliverysettings_content">
<?php echo $this->partial('subaccount/_viewperformancerightsdeliverysettings.phtml', $this);?>
</div>
<div class="panelHeader" id="grasregistration_header">
    <h3>GRAS Registration</h3>
    <ul>
        <li>
            <a href="/subaccount/editgrasregistration/subaccount_id/<?=$this->subaccount->subaccountId?>" class="btn btn-link btn-sm">Edit</a>
        </li>
    </ul>
</div>
<div class="panelContent" id="grasregistration_content">
    <table class="form">
        <tr>
            <td width="40%">Repertoire Owner :</td>
            <td><?php echo $this->rep_owner_name; ?></td>
        </tr>
        <tr>
            <td>Repertoire Owner Key Code :</td>
            <td><?php echo $this->rep_owner_code; ?></td>
        </tr>
        <tr>
            <td>GRAS imprint :</td>
            <td><?php echo $this->gras_imprint_name; ?></td>
        </tr>
        <tr>
            <td>GRAS imprint Key Code :</td>
            <td><?php echo $this->gras_imprint_code; ?></td>
        </tr>
        <tr>
            <td>FLoR (U.S. Distro Only) :</td>
            <td><?=$this->financial_label_name?></td>
        </tr>
        <tr>
            <td>FLoR (U.S. Distro Only) Key Code :</td>
            <td><?=$this->financial_label_code?></td>
        </tr>
				<tr>
					<td>SAP Profit Center :</td>
					<td><?=$this->sap_profit_center_name?></td>
				</tr>
				<tr>
					<td>SAP Profit Center Key Code :</td>
					<td><?=$this->sap_profit_center_code?></td>
				</tr>				
    </table>
</div>
<?php } ?>
