<?php
require_once ‘html_util/BaseSmarty.php’;
require_once ‘db_access/db_class_商品統合管理.php’;
//require_once ‘user_info_util/session_info.php’;
HTME::form_trim_all();
//HTME::https_needs();
//session_info::login_needs();
form_load();
/**
* 画面からの入力処理を行う
*/
function form_load()
{
// $user_info = session_info::is_login();
$o_smarty = new BaseSmarty();
HTME::form_post_set($o_smarty);
switch($_POST[“form_name”])
{
case ‘商品統合管理_list.html’:
switch($_POST[‘action_cmd’])
{
case ‘search’:
$_POST[‘page_no’] = page_no(1,0);
search_list($o_smarty);
break;
case ‘next’:
$_POST[‘page_no’] = page_no($_POST[‘page_no’],1);
search_list($o_smarty);
break;
case ‘jump’:
$_POST[‘page_no’] = page_no($_POST[‘page_no’],0);
search_list($o_smarty);
break;
case ‘prior’:
$_POST[‘page_no’] = page_no($_POST[‘page_no’],-1);
search_list($o_smarty);
break;
case ‘sort’:
$_POST[‘page_no’] = page_no($_POST[‘page_no’],0);
search_list($o_smarty);
break;
case ‘clear’:
form_clear($o_smarty);
break;
}
$o_smarty->display(“商品統合管理_list.html”);
break;
default:
HTME::form_get_set($o_smarty);
form_init($o_smarty);
$o_smarty->display(“商品統合管理_list.html”);
break;
}
}
/**
* 最初の画面を表示する
* @param $o_smarty SMARTYのインスタンスを渡す
* @param $action_cmd 画面のアクションコマンド
* @return なし
*/
function form_init($o_smarty)
{
$_POST[‘sort_key’] = ‘商品コード’; /* 初回のソートキーを入れる*/
$_POST[‘sort_order’] = ‘asc’;
search_list($o_smarty);
}
/**
* フィールドをクリアする
* @param $o_smarty SMARTYのインスタンスを渡す
* @return なし
*/
function form_clear($o_smarty)
{
$o_smarty->txtput(‘_商品コード’,”);
}
/**
* 検索する
* @param $o_smarty SMARTYのインスタンスを渡す
* @param $action_cmd 画面のアクションコマンド
* @return なし
*/
function search_list($o_smarty)
{
$sort_key = sort_key($o_smarty);
$class = new db_class_商品統合管理();
$class->_商品コード = $_POST[‘_商品コード’];
$line_len = line_len($_POST[‘line_len’]);
$page_no = $_POST[‘page_no’];
$max_page_no = 0;
$record_count = 0;
$list_data = db_class_商品統合管理::db_select_list($class,$line_len,$sort_key,$page_no,$max_page_no,$record_count);
$o_smarty->txtput(‘line_len’,$line_len);
$o_smarty->txtput(‘page_no’,$page_no);
$o_smarty->txtput(‘max_page_no’,$max_page_no);
$o_smarty->txtput(‘record_count’,$record_count);
$o_smarty->htmput(‘list_data’,$list_data);
}
/**
* ソート順番を求める
* @param $o_smarty SMARTYのインスタンスを渡す
* @return ソート順を格納した配列を返す
*/
function sort_key($o_smarty)
{
$sort_key = ”; /* この配列にソートキーとソートオーダーを入れる*/
if(!$_POST[‘sort_key’] && !$_POST[‘sort_key_old’]) return null;
$key = $_POST[‘sort_key’];
if(!$key) $key = $_POST[‘sort_key_old’];
if($_POST[‘sort_key’]==$_POST[‘sort_key_old’])
{
if($_POST[‘sort_order’]==’desc’)
{
$sort_key[$key] = ‘asc’;
}
else
{
$sort_key[$key] = ‘desc’;
}
}
else
{
if($_POST[‘sort_key’])
{
$sort_key[$key] = ‘asc’;
}
else
{
if($_POST[‘sort_order’]==’asc’)
{
$sort_key[$key] = ‘asc’;
}
else
{
$sort_key[$key] = ‘desc’;
}
}
}
$o_smarty->txtput(‘sort_key_old’,$key);
$o_smarty->txtput(‘sort_order’,$sort_key[$key]);
return $sort_key;
}
/**
* ページ番号を加算減算する
* @param $page_no 現在のページ番号
* @param $add 加算減算する値
* @return 結果のページを返す
*/
function page_no($page_no,$add)
{
if(!is_numeric($page_no)) $page_no=0;
if(!is_numeric($add)) $add=0;
$page_no = intval($page_no) + intval($add);
if($page_no<1) $page_no=1;
return $page_no;
}
/**
* 表示行数を求める
* @param $line_len 表示行数
* @return 表示行数を返す
*/
function line_len($line_len)
{
if(!is_numeric($line_len)) $line_len=10;
if($line_len<1) $line_len = 10;
$line_len = intval($line_len);
return $line_len;
}
?>