$cached_plan = str_replace('IMGALT', $LDShowActualPlan, $cached_plan);
    $cached_plan = str_replace('SHOWBUTTON', $LDShow, $cached_plan);
    echo str_replace('URLREDIRECTAPPEND', URL_REDIRECT_APPEND, $cached_plan);
} else {
    $toggler = 0;
    # Start generating the NOC list
    $temp_out = '';
    while (list($x, $v) = each($dept_OC)) {
        if (in_array($v['nr'], $quicklist)) {
            if ($dutyplan = $pers_obj->getNOCDutyplan($v['nr'], $pyear, $pmonth)) {
                $a = unserialize($dutyplan['duty_1_txt']);
                $r = unserialize($dutyplan['duty_2_txt']);
                $ha = unserialize($dutyplan['duty_1_pnr']);
                $hr = unserialize($dutyplan['duty_2_pnr']);
                if ($ha['ha' . ($plan_day - 1)]) {
                    $OC_1 = $pers_obj->getPersonellInfo($ha['ha' . ($plan_day - 1)]);
                }
                if ($hr['hr' . ($plan_day - 1)]) {
                    $OC_2 = $pers_obj->getPersonellInfo($hr['hr' . ($plan_day - 1)]);
                }
            }
        } else {
            if (isset($a)) {
                unset($a);
            }
            if (isset($r)) {
                unset($r);
            }
            if (isset($ha)) {
                unset($ha);
            }
require './roots.php';
require $root_path . 'include/inc_environment_global.php';
/**
* CARE2X Integrated Hospital Information System Deployment 2.1 - 2004-10-02
* GNU General Public License
* Copyright 2002,2003,2004,2005 Elpidio Latorilla
* elpidio@care2x.org, 
*
* See the file "copy_notice.txt" for the licence notice
*/
define('LANG_FILE', 'doctors.php');
define('NO_2LEVEL_CHK', 1);
require_once $root_path . 'include/inc_front_chain_lang.php';
require_once $root_path . 'include/care_api_classes/class_personell.php';
$pers_obj = new Personell();
$person =& $pers_obj->getPersonellInfo($nr);
require_once $root_path . 'include/care_api_classes/class_department.php';
$dept_obj = new Department();
$dept =& $dept_obj->getPhoneInfo($dept_nr);
require_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$glob_obj->getConfig('person_%');
/* Check whether config foto path exists, else use default path */
$default_photo_path = 'fotos/registration';
$photo_filename = $person['photo_filename'];
$photo_path = is_dir($root_path . $GLOBAL_CONFIG['person_foto_path']) ? $GLOBAL_CONFIG['person_foto_path'] : $default_photo_path;
require_once $root_path . 'include/inc_photo_filename_resolve.php';
html_rtl($lang);
?>
<HEAD>
<?php 
    if ($result = $pers_obj->getDOCDutyplan($dept_nr, $pyear, $pmonth, $elem)) {
        $duty1 =& unserialize($result['duty_1_pnr']);
        if (SHOW_DOC_2) {
            $duty2 =& unserialize($result['duty_2_pnr']);
        }
        //echo $sql."<br>";
    }
    //echo $pers_obj->getLastQuery();
    # Adjust the day index. This is necessary since change of duty usually happens early morning  not midnight
    $offset_day = $pday - 1;
    # Consider the early morning hours to belong to the past day
    if (date('H.i') < DOC_CHANGE_TIME) {
        $offset_day--;
    }
    if ($pnr1 = $duty1['ha' . $offset_day]) {
        $person1 =& $pers_obj->getPersonellInfo($pnr1);
    }
    if (SHOW_DOC_2 && ($pnr2 = $duty2['hr' . $offset_day])) {
        $person2 =& $pers_obj->getPersonellInfo($pnr2);
    }
    #### End of routine to fetch doctors on duty
}
# Start Smarty templating here
/**
 * LOAD Smarty
 */
# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme
require_once $root_path . 'gui/smarty_template/smarty_care.class.php';
$smarty = new smarty_care('nursing');
# Title in toolbar