<?php
/*
* Template's variables
*/

//Adding the head
$template->addFile( 'INCLUDE_HEADER', BASE_DIR_TEMPLATE . '/include/header.html' );

//Adding the top
$template->addFile( 'INCLUDE_HEAD', BASE_DIR_TEMPLATE . '/include/head.html' );

//Adding the footer
$template->addFile( 'INCLUDE_FOOTER', BASE_DIR_TEMPLATE . '/include/footer.html' );

//Adding the scripts
$template->addFile( 'INCLUDE_JAVASCRIPT', BASE_DIR_TEMPLATE . '/include/javascript.html' );

//Metadatas
try{

	//Checking
	if( isset( $meta ) ){

		//Defining
		$object							= SearchController::byId( 'metadata', $meta );

		//Defining
		$template->METADATA_TITLE		= $object->title;
		$template->METADATA_DESCRIPTION	= $object->description;
		$template->METADATA_KEYWORDS	= $object->keyword;

	}

}catch( Exception $e ){}

//Company
try{

	//Defining the object
	$object								= SearchController::byId( 'company' );

	//Defining the company to template
	$template->OBJ_COMPANY_VARIABLE		= $object;

	//Formating the phone to template
	$template->COMPANY_PHONE_FORMATTED	= str_replace( [ '(', ')', ' ', '-', '.' ], '', $object->phone );


}catch( Exception $e ){}

//Configuration
try{

	//Defining
	$object	= SearchController::byId( 'configuration' );

	//Checking
	if( $object->maintenance )
		//Redirecting
		header( 'Location:' . BASE_URL . '/manutencao' );

	//Defining the codes to template
	$template->CODE_TOP		= $object->top;
	$template->CODE_MIDDLE	= $object->middle;
	$template->CODE_FOOTER	= $object->footer;

	//Checking
	if( $page->module == 'sucesso' )
		//Defining the code to template
		$template->CODE_SUCCESS	= $object->success;

}catch( Exception $e ){}

//Menu
try{

	//Defining
	$records	= ListController::orderly( 'product-category', 'name' );

	//Checking
	if( !is_null( $records ) )
		//Listing
		foreach( $records as $record ){

			//Defining the object to template
			$template->OBJ_MENU_PRODUCT_CATEGORY	= $record;

			//Defining the products
			$products								= ListController::byCategoryOrderly( 'product', $record->id );

			//Checking
			if( !is_null( $products ) )
				//Listring
				foreach( $products as $product ){

					//Defining the object to template
					$template->OBJ_MENU_PRODUCT_WITH_CATEGORY	= $product;

					//Showing the block
					$template->block( 'MENU_PRODUCT_WITH_CATEGORY' );

				}

			//Showing the block
			$template->block( 'MENU_PRODUCT_CATEGORY' );

		}

	//Defining
	$records	= ListController::orderly( 'service', 'name' );

	//Checking
	if( !is_null( $records ) )
		//Listing
		foreach( $records as $record ){

			//Defining the object to template
			$template->OBJ_MENU_SERVICE	= $record;

			//Showing the block
			$template->block( 'MENU_SERVICE' );

		}

}catch( Exception $e ){}

//Defining some variables
$template->BASE_URL		= BASE_URL;
$template->BASE_URL_CSS	= BASE_URL_CSS;
$template->BASE_URL_IMG	= BASE_URL_IMG;
$template->BASE_URL_JS	= BASE_URL_JS;
$template->PROJECT_NAME	= PROJECT_NAME;