<?php
define('YUKEY', true);
require(str_replace('sicms','',dirname(__FILE__)) . '/includes/init.php');
check_login();
require(ROOT_PATH . 'includes/lib_schedule.php');
$active=!empty($_GET['active']) ? intval($_GET['active']) : 0;
$start_year=!empty($_POST['start_year']) ? intval($_POST['start_year']) : date('Y');
$start_month=!empty($_POST['start_month']) ? intval($_POST['start_month']) : date('m');
$start_day=!empty($_POST['start_day']) ? intval($_POST['start_day']) : '1';
	if($start=!empty($_REQUEST['start'])){
	   $start=$_REQUEST['start'];
	}else{
	   $start=$start_year.'-'.$start_month.'-'.$start_day;
	}
$end_year=!empty($_POST['end_year']) ? intval($_POST['end_year']) : date('Y');
$end_month=!empty($_POST['end_month']) ? intval($_POST['end_month']) : date('m');
$end_day=!empty($_POST['end_day']) ? intval($_POST['end_day']) : '31';
    if($end=!empty($_REQUEST['end'])){
	   $end=$_REQUEST['end'];
	}else{
	   $end=$end_year.'-'.$end_month.'-'.$end_day;
	}

if($act=='ready')
{
	$smarty->assign('active',$active);
	$smarty->assign('pre',$pre);
	$smarty->assign('factory_list',get_rows('si','tbCompanyID,tbType,tbNickName','tbType=2','companys','tbNickName'));
	//�������ƣ����Թ���finance�ĺ���
	$list=get_schedule_list('','',$start,$end);
		foreach($list as $k=> $v)
		{
			array_push($list[$k],get_rows('',"tbPN,tbPONumber,tbReportNumber,tbProductName,tbClientID,tbFactoryID,tbModelNO,tbClientPONo,tbShippingQty,tbSerialNO,tbRemark,tbCTNQty,tbSampleSize","`tbPONumber`='".$v['tbPONumber']."' ","reports","tbPN"));
			//print_r($list[$k]);
			//echo "<br><br><br><br>";
		}
	$smarty->assign('list',$list);
	$smarty->display('schedule.dwt');
}
?>