executeQuery($sql, [$release_id]);
if ($rs === false) {
show_pdo_error($sql, $pdoWrapperObj->getLastStatement());
}
if ($row = $rs[0]) {
$num_of_tracks_in_the_release = $row['num_of_tracks_in_a_release'];
}
//get number of scheme for track
$sql = "select count(pricing_scheme_id) as num_of_scheme_for_track
from dms_master_pricing_scheme
where scheme_level = 'track' and product_type_id = ?";
$rs = $pdoWrapperObj->executeQuery($sql, [$product_type_id]);
if ($rs === false) {
show_pdo_error($sql, $pdoWrapperObj->getLastStatement());
}
if ($row = $rs[0]) {
$num_of_scheme_for_track = $row['num_of_scheme_for_track'];
}
//get tracks that have scheme
$tracks = array();
$sql = "select distinct eat.id
from track_pricing_tier eatpt
inner join track eat on eat.id = eatpt.unique_track_id
where eatpt.active = 'Y' and eat.release_id = ?";
$rs = $pdoWrapperObj->executeQuery($sql, [$release_id]);
if ($rs === false) {
show_pdo_error($sql, $pdoWrapperObj->getLastStatement());
}
foreach ($rs as $row) {
$tracks[] = $row['id'];
}
if(count($tracks)){
foreach($tracks as $track_id){
//determine whether each track has all its scheme default
$sql = "select count(x.pricing_tier_id) as c
from dms_master_pricing_scheme dmps
inner join(
select pricing_tier_id as pricing_tier_id, eat.id
from track_pricing_tier eatpt
inner join track eat on eat.id = eatpt.unique_track_id
where eatpt.active = 'Y' and eat.id = ?
) x on x.pricing_tier_id = dmps.default_pricing_tier
where dmps.product_type_id = ?";
$dataParams = [];
$dataParams[] = $track_id;
$dataParams[] = $product_type_id;
$rs = $pdoWrapperObj->executeQuery($sql, $dataParams);
if ($rs === false) {
show_pdo_error($sql, $pdoWrapperObj->getLastStatement());
}
if ($row = $rs[0]) {
if($row['c']==$num_of_scheme_for_track){
$num_of_tracks_selling_at_default_pricing++;
}
}
}
}
}else{
//get number of tracks in the release
$sql = "select count(eat.id) as num_of_tracks_in_a_release
from track eat
where eat.upc = ?";
$rs = $pdoWrapperObj->executeQuery($sql, [$upc]);
if ($rs === false) {
show_pdo_error($sql, $pdoWrapperObj->getLastStatement());
}
if ($row = $rs[0]) {
$num_of_tracks_in_the_release = $row['num_of_tracks_in_a_release'];
}
//get number of scheme for track
$sql = "select count(pricing_scheme_id) as num_of_scheme_for_track
from dms_master_pricing_scheme
where scheme_level = 'track' and product_type_id = ?";
$rs = $pdoWrapperObj->executeQuery($sql, [$product_type_id]);
if ($rs === false) {
show_pdo_error($sql, $pdoWrapperObj->getLastStatement());
}
if ($row = $rs[0]) {
$num_of_scheme_for_track = $row['num_of_scheme_for_track'];
}
//get tracks that have scheme
$tracks = array();
$sql = "select distinct eat.id
from track_pricing_tier eatpt
inner join track eat on eat.id = eatpt.unique_track_id
where eatpt.active = 'Y' and eat.upc = ?";
$rs = $pdoWrapperObj->executeQuery($sql, [$upc]);
if ($rs === false) {
show_pdo_error($sql, $pdoWrapperObj->getLastStatement());
}
foreach ($rs as $row) {
$tracks[] = $row['id'];
}
if(count($tracks)){
foreach($tracks as $track_id){
//determine whether each track has all its scheme default
$sql = "select count(x.pricing_tier_id) as c
from dms_master_pricing_scheme dmps
inner join(
select pricing_tier_id as pricing_tier_id, eat.id
from track_pricing_tier eatpt
inner join track eat on eat.id = eatpt.unique_track_id
where eatpt.active = 'Y' and eat.id = ?
) x on x.pricing_tier_id = dmps.default_pricing_tier
where dmps.product_type_id = ?";
$dataParams = [];
$dataParams[] = $track_id;
$dataParams[] = $product_type_id;
$rs = $pdoWrapperObj->executeQuery($sql, $dataParams);
if ($rs === false) {
show_pdo_error($sql, $pdoWrapperObj->getLastStatement());
}
if ($row = $rs[0]) {
if($row['c']==$num_of_scheme_for_track){
$num_of_tracks_selling_at_default_pricing++;
}
}
}
}
}//--------------get tracks selling at default pricing at all stores (end)--------------------------
if(!$isCatalog){
$sql = "select customer_master_master_id, count(default_pricing_tier) as total_num_of_scheme, sum(if(x.pricing_tier_id is not null,1,0)) as num_of_scheme_set_to_default
from dms_master_pricing_scheme
left join (
select eatpt.pricing_tier_id
from release_pricing_tier eatpt
where eatpt.release_id = ? and eatpt.active = 'Y'
) x on x.pricing_tier_id = default_pricing_tier
where scheme_level = 'release' and product_type_id = ?
group by customer_master_master_id
";
$dataParams = [];
$dataParams[] = $release_id;
$dataParams[] = $product_type_id;
$rs = $pdoWrapperObj->executeQuery($sql, $dataParams);
if ($rs === false) {
show_pdo_error($sql, $pdoWrapperObj->getLastStatement());
}
$num_of_stores_selling_at_defult_pricing = 0;
$total_num_of_stores = 0;
foreach ($rs as $row) {
if(($row['total_num_of_scheme'] - $row['num_of_scheme_set_to_default'])==0){
$num_of_stores_selling_at_defult_pricing++;
}
$total_num_of_stores++;
}
}else{
$sql = "select customer_master_master_id, count(default_pricing_tier) as total_num_of_scheme, sum(if(x.pricing_tier_id is not null,1,0)) as num_of_scheme_set_to_default
from dms_master_pricing_scheme
left join (
select eatpt.pricing_tier_id
from release_pricing_tier eatpt
where eatpt.upc = ? and eatpt.active = 'Y'
) x on x.pricing_tier_id = default_pricing_tier
where scheme_level = 'release' and product_type_id = ?
group by customer_master_master_id
";
$dataParams = [];
$dataParams[] = $upc;
$dataParams[] = $product_type_id;
$rs = $pdoWrapperObj->executeQuery($sql, $dataParams);
if ($rs === false) {
show_pdo_error($sql, $pdoWrapperObj->getLastStatement());
}
$num_of_stores_selling_at_defult_pricing = 0;
$total_num_of_stores = 0;
foreach ($rs as $row) {
if(($row['total_num_of_scheme'] - $row['num_of_scheme_set_to_default'])==0){
$num_of_stores_selling_at_defult_pricing++;
}
$total_num_of_stores++;
}
}
?>
| Fraction of tracks that are selling at default pricing at all
stores |
Fraction of stores selling this release at default pricing |
| =($num_of_tracks_selling_at_default_pricing) . " / ".$num_of_tracks_in_the_release?> |
=($num_of_stores_selling_at_defult_pricing . " / ".$total_num_of_stores)?> |
}else{
?>
| No Product Type Specificed for this release. Please choose product
type. |
}?>