<?php
class items_base extends myQuicty {

function __construct() {
	parent::__construct();
	require_once 'includes/myAmazon.class.php';
	$myAmazon = new myAmazon();
	$this->amazon = $myAmazon->amazon;
}

function pre_dispatch_index() {
	parent::pre_dispatch_index();
	$this->caching = 0; // caching page flag: 0 = none; 1 = simple; 2 = each query
	$this->cache_lifetime = 1800; // cache life time by seconds
	$this->cache_id = get_query_id();
	$this->page['base_url'] = quicty_base_url();
	$this->page['data_name'] = 'items';

	return true;
}

function assign_search_form($page_obj=NULL) {
	if($page_obj) {
		$my = $page_obj;
	} else {
		$my = $this;
	}
	$search_form = $my->new_search_obj('items_search',array('action'=>$my->page['base_url'].'<!--{$folder_name}-->/items/','method'=>'get'));
	$search_option = $this->amazon->search_kind_array;
	$dmy = array_pop($search_option);
	array_unshift($search_option,'指定なし');
	$search_form->form_element['search_option']->loadArray($search_option);
	$my->assign_form('search_form',$search_form);
}

function list_records($condition='') {
	require_once 'list_options.class.php';
	$this->list = $this->new_data_set('items');
	$options = new items_list_options($this);
	$pager_option = $options->get_pager_option($condition);
	$this->list->bind_pager($pager_option);
	
	$fields = $options->make_select_fields();
	$sort_condition = $options->make_sort_condition();
	$list_table = $this->list->select_table_with_pager($sort_condition,$fields);
	return $list_table;
}


function display_record($condition='') {
	require_once 'form_options.class.php';
	$this->form = $this->new_data_set('items');
	$options = new items_form_options($this);
	$options->set_form_options();
	$this->form->validate_and_freeze();
	$this->form->bind_button_control();
	
	$result = $this->form->automatic_form_handler($condition);
	$this->items = $result['items'] ? $result['items'] : $result['values'];
	return $result;
}


function assign_page_and_pathlist() {
	$upper_path = '一覧ページ';
	$this->add_pathlist('<!--{$folder_name}-->/items/',$upper_path,false);
	$this->add_pathlist('',$this->page['name']);
	$this->assign('page',$this->page);
}

function batch_update($condition='') {
	require_once 'list_options.class.php';
	$this->list = $this->new_data_set('items');
	$options = new items_list_options($this);
	$pager_option = $options->get_pager_option($condition);
	$this->list->form_element['search_option']->loadArray($this->amazon->search_kind_array);
	$this->list->bind_pager($pager_option);
	$fields = $options->make_select_fields();
	$sort_condition = $options->make_sort_condition();
	$options->set_batch_list_option();
	
	$this->list->set_button_status('use_confirm',false);
	$this->list->bind_button_control();
	$list_table = $this->list->automatic_batch_handler($sort_condition,$fields);
	return $list_table;
}



} // end of items_base class
?>