assignInclude( 'header' , TPL_PATH . 'header.' . TPL_EXT );
$oTpl->assignInclude( 'footer' , TPL_PATH . 'footer.' . TPL_EXT );
$oTpl->prepare();
// Check if we're getting a cat_id or an ev_id
if ( $sType == 'category' )
{
$asQuery[0] = "SELECT
e.ev_id,
e.ev_naam,
e.ev_url,
e.ev_beschrijving_kort,
e.ev_vvk_isopen,
DAY( ev_begin ) AS ev_begin_day,
MONTH( ev_begin ) AS ev_begin_month,
YEAR( ev_begin ) AS ev_begin_year,
DAYOFWEEK( ev_begin ) AS ev_begin_dayofweek,
DAY( ev_eind ) AS ev_eind_day,
MONTH( ev_eind ) AS ev_eind_month,
YEAR( ev_eind ) AS ev_eind_year,
DAYOFWEEK( ev_eind ) AS ev_eind_dayofweek,
DATE_FORMAT( e.ev_vvk_begin , '%e-%m-%y' ) AS vvk_begin_datum,
DATE_FORMAT( e.ev_vvk_begin , '%H:%i' ) AS vvk_begin_tijd,
DATE_FORMAT( e.ev_vvk_eind , '%e-%m-%y' ) AS vvk_eind_datum,
DATE_FORMAT( e.ev_vvk_eind , '%H:%i' ) AS vvk_eind_tijd,
e.ev_single_page
FROM
categorieen c,
evenementen e
WHERE
c.cat_ispublished = 1
AND
c.cat_id = " . $iId . "
AND
e.ev_id = c.cat_ev
AND
e.ev_ispublished = 1
";
$asQuery[1] = "SELECT
cat_id,
cat_ev,
cat_naam,
cat_beschrijving_kort
FROM
categorieen
WHERE
cat_id = " . $iId . "
AND
cat_ispublished = 1
LIMIT
0, 1
";
}
else
{
$asQuery[0] = "SELECT
ev_id,
ev_naam,
ev_url,
ev_beschrijving_kort,
ev_is_uitverkocht,
ev_vvk_isopen,
DAY( ev_begin ) AS ev_begin_day,
MONTH( ev_begin ) AS ev_begin_month,
YEAR( ev_begin ) AS ev_begin_year,
DAYOFWEEK( ev_begin ) AS ev_begin_dayofweek,
DAY( ev_eind ) AS ev_eind_day,
MONTH( ev_eind ) AS ev_eind_month,
YEAR( ev_eind ) AS ev_eind_year,
DAYOFWEEK( ev_eind ) AS ev_eind_dayofweek,
DATE_FORMAT( ev_vvk_begin , '%e-%m-%y' ) AS vvk_begin_datum,
DATE_FORMAT( ev_vvk_begin , '%H:%i' ) AS vvk_begin_tijd,
DATE_FORMAT( ev_vvk_eind , '%e-%m-%y' ) AS vvk_eind_datum,
DATE_FORMAT( ev_vvk_eind , '%H:%i' ) AS vvk_eind_tijd,
CASE
WHEN
NOW() < ev_vvk_begin
THEN
1
ELSE
0
END AS now_iseerder,
CASE
WHEN
NOW() > ev_vvk_eind
THEN
1
ELSE
0
END AS now_islater,
ev_single_page
FROM
evenementen
WHERE
ev_id = " . $iId . "
AND
ev_ispublished = 1
";
$asQuery[1] = "SELECT
cat_id,
cat_ev,
cat_naam,
cat_beschrijving_kort
FROM
categorieen
WHERE
cat_ev = " . $iId . "
AND
cat_ispublished = 1
ORDER BY
cat_volgorde
";
}
$oTpl->assignGlobal( 'POST_RETURN_URL' , 'show/products/' . $iId . '/' );
// Execute query to retrieve event info
$arQuery[0] = @mysql_query( $asQuery[0] );
if ( $arQuery[0] == FALSE )
{
$oError->addDbError( $asQuery[0] , mysql_error() , mysql_errno() , __FILE__ , __LINE__ );
}
else
{
$iRowCount = mysql_num_rows( $arQuery[0] );
$aEvent = mysql_fetch_assoc( $arQuery[0] );
// If there is not exactly 1 event, something's wrong. If the join went wrong, the relation is invalid. Both cases need the script to produce an error.
if ( $iRowCount != 1 or $aEvent['ev_id'] == NULL or ($aEvent['ev_id'] == 3 and (!isset($_SESSION['miyu_auth']) or $_SESSION['miyu_auth'] != 1)))
{
$oError->addError( ERR_INVALID_CAT_EV , $aLang['invalid_cat_ev'] , __FILE__ , __LINE__ , FALSE );
}
else
{
// Execute query to retrieve category data (1 or more)
$arQuery[1] = @mysql_query( $asQuery[1] );
if ( $arQuery[1] == FALSE )
{
$oError->addDbError( $asQuery[1] , mysql_error() , mysql_errno() , __FILE__ , __LINE__ );
}
else
{
// If there is more than one category and the event data tells us to show them as multiple pages, redirect
if ( mysql_num_rows( $arQuery[1] ) > 1 and $aEvent['ev_single_page'] == FALSE )
{
//header( "Location: " . SITE_URL . "show/products/" . $aEvent['ev_id'] );
//exit();
}
//TPL// Ladies and gentlemen, we've got event-info. So why not tell the template?
$oTpl->newBlock( 'events' );
$oTpl->newBlock( 'event' );
$oTpl->assign( array( "EVENT_NAME" => $aEvent['ev_naam'],
"EVENT_LINK" => SITE_URL . "show/products/" . $aEvent['ev_id']
)
);
$aTmp = array();
$aTmp['ev_id'] = $aEvent['ev_id'];
$aTmp['ev_naam'] = $aEvent['ev_naam'];
$_SESSION['continue_shopping'] = 'show/products/' . $aEvent['ev_id'];
// If there's a short description of the event, send it to the template.
if ( ( strlen( trim( $aEvent['ev_beschrijving_kort'] ) ) > 0 and
$aEvent['ev_beschrijving_kort'] != NULL
) or
$aEvent['ev_begin_year'] != 0
)
{
// Instantiate block ...
$oTpl->newBlock( 'event_description' );
// ... and add value to it.
$oTpl->assign( "EVENT_DESC", nl2br( trim( $aEvent['ev_beschrijving_kort'] ) ) );
// Prepare date value...
// Date of beginning
$aTmp[1] = sprintf( $aLang['day_and_date'] ,
$aEvent['ev_begin_day'] . " " . $aLang['months'][ $aEvent['ev_begin_month'] ] . " " . $aEvent['ev_begin_year'] ,
$aLang['days'][ $aEvent['ev_begin_dayofweek'] ]
);
// Date of ending
$aTmp[2] = sprintf( $aLang['day_and_date'] ,
$aEvent['ev_eind_day'] . " " . $aLang['months'][ $aEvent['ev_eind_month'] ] . " " . $aEvent['ev_eind_year'] ,
$aLang['days'][ $aEvent['ev_eind_dayofweek'] ]
);
// Add dates together
$aTmp[3] = sprintf( $aLang['event_date_info'] ,
$aTmp[1] ,
$aTmp[2]
);
// Assign date value
$oTpl->assign( 'EVENT_DATE_INFO' , $aTmp[3] );
// Return to parent block.
$oTpl->gotoBlock( 'event' );
}
if ( substr( $aEvent['ev_url'] , 0 , 7 ) == 'http://' )
{
$oTpl->newBlock( 'event_url' );
$oTpl->assign( array( 'EVENT_URL' => $aEvent['ev_url'] ,
'EVENT_NAME' => $aEvent['ev_naam']
)
);
$oTpl->gotoBlock( 'event' );
}
// Check if presales are opened or not and if they are to be open in the future or if they're closed never to open again
if ( $aEvent['ev_vvk_isopen'] != 1 )
{
//TPL// Presales closed, so instantiate block to tell users
$oTpl->newBlock( 'event_presales_closed' );
// Are presales in the past...
$sPresalesClosed = ( $aEvent['now_iseerder'] == 1 ) ? $aLang['presales_not_yet_opened'] : '' ;
// ... or in the future?
$sPresalesClosed = ( $aEvent['now_islater'] == 1 ) ? $aLang['presales_closed'] : $sPresalesClosed ;
//TPL// And, quite important, tell the template what to show to the user
$oTpl->assign( array( "LANG_PRESALES_CLOSED_TITLE" => $aLang['presales_closed_title'],
"LANG_PRESALES_CLOSED"
=> sprintf( $sPresalesClosed , $aEvent['vvk_begin_datum'] . ", " . $aEvent['vvk_begin_tijd'] )
. ((1 == $aEvent['now_islater'] and 1 != $aEvent['ev_is_uitverkocht']) ? '
' . $aLang['tickets_available_at_door'] : '')
)
);
}
else
{
$iCount = 0;
// Loop through the categories and get their (sub-) info
while ( $aCategory = mysql_fetch_assoc( $arQuery[1] ) )
{
$iCount++;
//TPL// We've got a category, so instantiatie a block and send the categories name to the template.
$oTpl->newBlock( 'category' );
$oTpl->assign( "CAT_NAME", $aCategory['cat_naam'] );
//TPL// Do we have a short description of the category?
if ( strlen( trim( $aCategory['cat_beschrijving_kort'] ) ) > 0 and
$aCategory['cat_beschrijving_kort'] != NULL
)
{
// Instantiate the block ...
$oTpl->newBlock( 'category_description' );
// ... and assign variable for the newly created block.
$oTpl->assign( "CAT_DESC" , nl2br( trim( $aCategory['cat_beschrijving_kort'] ) ) );
// Return to the parent block.
$oTpl->gotoBlock( 'category' );
}
// Retrieve basic info about article
$asQuery[2] = "SELECT
artikel_id,
artikel_naam,
artikel_stukprijs,
artikel_image,
artikel_voorraad,
artikel_voorraad_ishard,
artikel_max_perorder,
artikel_beschrijving_kort
FROM
artikelen
WHERE
artikel_cat = " . $aCategory['cat_id'] . "
AND
artikel_vvk_isopen = 1
ORDER BY
artikel_volgorde ASC
";
$arQuery[2] = @mysql_query( $asQuery[2] );
if ( $arQuery[2] == FALSE )
{
$oError->addDbError( $asQuery[2] , mysql_error() , mysql_errno() , __FILE__ , __LINE__ );
}
else
{
$iArtCount = 0;
while ( $aArtikel = mysql_fetch_assoc( $arQuery[2] ) )
{
$iArtCount++;
//TPL// We have a product; tell the template what product we're dealing with.
$oTpl->newBlock( 'product' );
$oTpl->assign( array( "PRODUCT_ID" => $aArtikel['artikel_id'],
"PRODUCT_NAME" => $aArtikel['artikel_naam'],
"PRODUCT_PRICE_FORMAT" => sprintf( "%01.2f" , $aArtikel['artikel_stukprijs'] ),
"LANG_ADDTOCART" => $aLang['add_to_cart'] ,
"PRODUCT_MAX_PERORDER" => $aArtikel['artikel_max_perorder']
)
);
if (null !== $aArtikel['artikel_image'] and file_exists(PRODIMG_PATH . $aArtikel['artikel_image']))
{
$oTpl->newBlock( 'product_image' );
$oTpl->assign( array( "IMAGE_URL" => PRODIMG_URL . $aArtikel['artikel_image'] ) );
$oTpl->gotoBlock( 'product' );
}
$iCountNumber = 1;
while ( $iCountNumber <= $aArtikel['artikel_max_perorder'] )
{
$oTpl->newBlock( 'number_option' );
$oTpl->assign( 'OPTION_NUMBER' , $iCountNumber );
$iCountNumber++;
}
if ( $aArtikel['artikel_beschrijving_kort'] != NULL )
{
$oTpl->newBlock( 'product_desc' );
$oTpl->assign( 'PRODUCT_DESC' , $aArtikel['artikel_beschrijving_kort'] );
}
}
if (7 == $aEvent['ev_id']) {
$iArtCount++;
//TPL// We have a product; tell the template what product we're dealing with.
$oTpl->newBlock( 'ext_product' );
$oTpl->assign( array( "PRODUCT_ID" => 999999,
"PRODUCT_NAME" => 'Toegangskaart Afterparty',
'PRODUCT_DESC' => 'Koop je ticket voor de afterparty bij De Kelder.
'
. 'Klik hier voor de website.'
)
);
}
if ( $iArtCount == 0 )
{
//TPL// INSTANTIATE BLOCK message
$oTpl->newBlock( 'cat_message' );
//TPL// ASSIGN VARS FOR BLOCK message (containing 'there are no products in this category')
$oTpl->assign( "LANG_CAT_MSG" , $aLang['no_products_found'] );
$oTpl->gotoBlock( 'category' );
}
else
{
// We could show the number of articles for this category. If so, do it here.
}
}
$oTpl->gotoBlock( 'event' );
}
if ( $iCount == 0 )
{
//TPL// INSTANTIATE BLOCK message
$oTpl->newBlock( 'event_message' );
//TPL// ASSIGN VARS FOR BLOCK message (containing 'there are no categories')
$oTpl->assign( "LANG_EVENT_MSG" , $aLang['no_cats_found'] );
$oTpl->gotoBlock( 'events' );
}
else
{
// We could show the number of events. If so, do it here.
}
}
}
}
}
break;
default:
$oTpl = new TemplatePower( TPL_PATH . 'eventlist.' . TPL_EXT , T_BYFILE );
$oTpl->assignInclude( 'header' , TPL_PATH . 'header.' . TPL_EXT );
$oTpl->assignInclude( 'footer' , TPL_PATH . 'footer.' . TPL_EXT );
$oTpl->prepare();
$oTpl->newBlock( 'events' );
$oTpl->assign( array(
'LANG_EVENTS' => ucfirst( $aLang['events'] )
)
);
$oTpl->newBlock( 'event' );
$oTpl->assign( array( 'EV_NAAM' => 'Schotland Festival 2007' ,
'EV_ID' => 2 ,
'EV_SITE' => 'http://www.schotlandfestival.nl/'
)
);
$oTpl->gotoBlock( 'events' );
$oTpl->newblock( 'event' );
$oTpl->assign( array( 'EV_NAAM' => 'Castlefest 2007' ,
'EV_ID' => 1 ,
'EV_SITE' => 'http://www.castlefest.com/'
)
);
break;
}
$aToTpl = array( "PAGE_TITLE" => $sPageTitle = "Pygmalion - Webshop",
"css" => array( 'events' , 'eventlist' )
);
require_once( INC_PATH . 'tpl_ending.' . PHP_EXT );
?>