<?php
/**
 * cdvb100_page
 *
 * all pages for cdvb100
 *
 * @version    1.0
 * @author     Erik Timmers, amgate <erik.timmers@amgate.com>
 * @copyright  Amgate, 2010
 * @since      11-01-2010 - initial creation
 * @package    CDVB0100
 */

class cdvb100_page extends stdModule
{

    /**
     * cdvb100_page
     *
     * PHP4 constructor
     *
     * @access public
     * @return void
     */
    function cdvb100_page()
    {
	$this->stdModule('cdvb0100');
        $this->_settings->templates->profileSelect	    = 'profileSelect.tpl';
        $this->_settings->templates->profileControl         = 'profileControl.tpl';
        $this->_settings->templates->control	            = 'control.tpl';
        $this->_settings->templates->fini  	            = 'fini.tpl';
        $this->_settings->templates->overviewprofileselect  = 'overviewprofileselect.tpl';
        $this->_settings->templates->clienteleOverview      = 'clienteleOverview.tpl';
        $this->_settings->templates->editRevenue            = 'editRevenue.tpl';
	$this->_settings->templates->editRevenueMonth       = 'editRevenueMonth.tpl';
        $this->_settings->templates->stockStatus            = 'stockStatus.tpl';
        $this->_settings->templates->procurementStatus      = 'procurementStatus.tpl';
        $this->_settings->templates->orderhistory           = 'orderhistory.tpl';
        $this->_settings->templates->orderhistoryDetail     = 'orderhistoryDetail.tpl';

    }


    /**
     * profileSelect
     *
     * page where user can select a profile and a praktijk
     * first page in handling scan
     *
     * @access public
     * @param  array    $aProfile       all the profiles [ array( id => name ) ]
     * @param  array    $aPraktijken    all the praktijken [ array (profile-is => array (id => name) ) ]
     * @return void
     */
    function profileSelect($aProfile, $aPraktijken)
    {
		$this->_smrt->assign('aProfile', $aProfile);
		$this->_smrt->assign('aPraktijken', $aPraktijken);

		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->profileSelect);
    }
    
    
    function profilecontrol($aStock) 
    {
		$this->_smrt->assign('aStock', $aStock);

		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->profileControl);
        
    }
    

    /**
     * control
     *
     * control the scanned stock
     * second page in handling scan
     *
     * @access public
     * @param  array $aStock array of the stock
     * @return void
     */
    function control($aStock, $aTotal)
    {
		$this->_smrt->assign('aStock', $aStock);
		$this->_smrt->assign('aTotal', $aTotal);

		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->control);

    }

    /**
     * fini
     *
     * page to message that the reading of the scan of the stock is finished
     * third and last page in handling scan
     *
     * @access public
     * @return void
     */
    function fini()
    {
		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->fini);
    }

    /**
     * overviewProfileSelect
     *
     * show profiel selector
     *
     * @access public
     * @param  array $aProfile  list of all profiles in key=>value format
     * @return void
     */
    function overviewProfileSelect($aProfile)
    {
		$this->_smrt->assign('aProfile', $aProfile);
		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->overviewprofileselect);
    }

    /**
     * clienteleOverview
     *
     * page with overview of all cleantele of inkooporganisation
     *
     * @access public
     * @param  array    $aData  array with data of clientel
     * @param  array    $aDates dates to prefill the dateselector
     * @return void
     */
    function clienteleOverview($aData, $aDates)
    {
		$this->_smrt->assign('aData', $aData);
		$this->_smrt->assign('aDates', $aDates);
		$this->_smrt->assign('aIntval', array('wk' => 'Week', 'mn' => 'Maand', 'yr' => 'Jaar'));

		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->clienteleOverview);
    }

    /**
     * editRevenue
     *
     * page to edit revenues
     *
     * @access public
     * @param  array    $wyStart    array with week/year combi of startdate
     * @param  array    $wyEnd      array with week/year combi of enddate
     * @param  array    $aRevData   array with revenue data
     * @param  array    $aEnumerate enumeration of all weeks that should be on the page
     * @return void
     */
    function editRevenue($wyStart, $wyEnd, $aRevData, $aEnumerate)
    {
		$this->_smrt->assign('wyStart'   , $wyStart);
		$this->_smrt->assign('wyEnd'     , $wyEnd);
		$this->_smrt->assign('aRevData'  , $aRevData);
		$this->_smrt->assign('aEnumerate', $aEnumerate);
		// should we show the "next" button. Not if enddate is currentdate or in the future
		$this->_smrt->assign('showNext'  , !( $wyEnd['year'] >= date('Y') ||
		                                        (  $wyEnd['year'] == date('Y') &&
		                                           $wyEnd['week'] >= date('W')
		                                        )
		                                     )
		                     );

		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->editRevenue);
    }

    function editRevenueMonth($date, $customdate, $aRevData) 
    {
		$this->_smrt->assign('date', $date);  
		$this->_smrt->assign('customdate', $customdate);
		$this->_smrt->assign('info', $aRevData);  		
		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->editRevenueMonth);			
    }	

    function stockStatus($aDates, $aStock)
    {
		$this->assignTemplateGlobals();
		$this->_smrt->assign('aDates', $aDates);
		$this->_smrt->assign('aStock', $aStock);
		$this->_smrt->assign('aIntval', array('wk' => 'Week', 'mn' => 'Maand', 'yr' => 'Jaar'));

		$this->_smrt->display($this->_settings->templates->stockStatus);

    }

    function procurementStatus($aDates, $aProc, $aRev, $aPerc)
    {
        
		$this->assignTemplateGlobals();
		$this->_smrt->assign('aDates', $aDates);
		$this->_smrt->assign('aProc' , $aProc);
		$this->_smrt->assign('aRev'  , $aRev);
		$this->_smrt->assign('aPerc' , $aPerc);
		
		$this->_smrt->assign('aIntval', array('wk' => 'Week', 'mn' => 'Maand', 'yr' => 'Jaar'));

		$this->_smrt->display($this->_settings->templates->procurementStatus);
    }

    /**
     * orderhistory
     *
     * order histor main page
     *
     * @access public
     * @param  array $aHistList     list of all historical orders
     * @param  array $aNav          data neede d for navigation
     *                              array ('pages' => number of pages
     *                                     'pageOffset' => current page
     * @return void
     */
    function orderhistory($aHistList, $aNav, $showPrices)
    {

		$this->_smrt->assign('aHistList', $aHistList);
		$this->_smrt->assign('showPrices', $showPrices);		
		$this->_smrt->assign('aNav', $aNav);
		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->orderhistory);
    }

    /**
     * orderhistoryDetail
     *
     * shows orderhistory detail of order
     *
     * @access public
     * @param  array $aOrder list of orderlines
     * @return void
     */
    function orderhistoryDetail($aOrder, $showPrices)
    {
		$this->_smrt->assign('aOrder', $aOrder);
		$this->_smrt->assign('thisYear', date('Y'));
		$this->_smrt->assign('lastYear', date('Y')-1);
		$this->_smrt->assign('showPrices', $showPrices);
		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->orderhistoryDetail);
    }

}




?>
