require_once('../prepare.php');
require_once('lib/notebook_function.php');
//- メンバーチェック
/*
if("e" == $p['carrier']){
chdir(dirname(__FILE__) . "/authcheck");
require_once("../authcheck/authcheck.php");
chdir(dirname(__FILE__));
}
*/
$db = u4user_open();
if(!get_UserDetail_uid($db, $p['uid'], '0', '1') && MEMBER_CHECK){
header("Location: " . MEMBER_REGIST_URL . "?p[contents]=" . substr(strrchr(dirname( __FILE__ ) , '/'), 1));
exit;
}
u4user_close($db);
function nb_prof_list( $p )
{
$max_line = 7;
$user_goal = get_UserGoal($p);
$p['page'] = (empty($p['page'])) ? 1 : $p['page'];
if(1 < $p['page']){
$adjust = 1;
}else{
$adjust = 0;
}
$ymd = (empty($p['date'])) ? date("Ymd",mktime( 0, 0, 0, date("n"), date("j") - (($p['page'] - 1) * $max_line + $adjust), date("Y"))) : $p['date'];
$prev_ymd = (empty($p['date'])) ? date("Ymd",mktime( 0, 0, 0, date("n"), date("j") - ($p['page'] * $max_line + $adjust), date("Y"))) : ($p['date'] - $max_line);
if(NOTEBOOK_DEBUG_MODE){
print "
ymd => ".$ymd ."
";
print "
prev_ymd => ".$prev_ymd ."
";
}
$chk_next = $max_line + 1;
$profile = get_UserProf($p ,$ymd , '', $max_line );
$rest_profile = get_UserProf($p ,$ymd , '', $chk_next );
$prev_profile = get_UserProf($p ,$prev_ymd , '', 1 );
if(NOTEBOOK_DEBUG_MODE){
var_dump($rest_profile);
print "
rest_profile => ".count($rest_profile)."
";
var_dump($prev_profile);
print "
prev_profile => ".count($prev_profile)."
";
}
// テンプレート読み込み
$template =& loadTemplate( $p );
if(!empty($user_goal[0]['start_weight'])){
$start_date = sprintf("%d.%d.%d",substr($user_goal[0]['make_ymd'],0,4),substr($user_goal[0]['make_ymd'],4,2),substr($user_goal[0]['make_ymd'],6,2));
$diff = $profile[0]['weight'] - $user_goal[0]['start_weight'];
if($diff > 0){
$diff = sprintf("+%s",$diff);
}
$template->setCurrentBlock('__StartDiffer__');
$template->setVariable('start_date',$start_date);
$template->setVariable('diff',$diff);
$template->parseCurrentBlock();
}
if(!empty($user_goal[0]['goal_weight'])){
$rest = $profile[0]['weight'] - $user_goal[0]['goal_weight'];
$template->setCurrentBlock('__ShowGoal__');
$template->setVariable('rest',$rest);
$template->parseCurrentBlock();
}
for($i=0;$isetCurrentBlock('__List__');
$template->setVariable('ymd_val',$profile[$i]['measure_ymd']);
$template->setVariable('month',sprintf("%d",substr($profile[$i]['measure_ymd'],4,2)));
$template->setVariable('date',sprintf("%d",substr($profile[$i]['measure_ymd'],6,2)));
$template->setVariable('weight',$profile[$i]['weight']);
$template->setVariable('bmi_val',$profile[$i]['bmi']);
$template->parseCurrentBlock();
}
if(0 < count($prev_profile) && count($rest_profile) > $max_line){
$template->setCurrentBlock('__PageNext__');
$template->setVariable('page_next',($p['page'] + 1));
$template->parseCurrentBlock();
}
if(1 < $p['page']){
$template->setCurrentBlock('__PagePrev__');
$template->setVariable('page_prev',($p['page'] - 1));
$template->parseCurrentBlock();
}
$template->show();
}
nb_prof_list( $p );
?>