header("Content-type: text/html; charset=euc-jp"); ?>
////////////////////////////////////////////////////////////
//配列、変数宣言部
////////////////////////////////////////////////////////////
//入力フォームの数値チェック
if(chk_input()){
echo("戻るボタンを押して入力しなおしてください
");
exit;
}
else{
//業種配列
$Aind_code = array("01","02","03","04","05","06","07","08");
$Aind_name = array("小売業","卸売業","製造業","建設業","飲食業",
"ホテル業","その他の娯楽","パチンコ業");
$Aind_ave = array("4.5","1.8","4.2","2.6","9.7","4.6","10.9","3.6");
//変数宣言初期値設定
$intA = 0; //汎用ループカウンタ
$ind_type = "00"; //該当業種コード
$cost_sales = 0; //売上総利益
$sales_man_cost = 0; //販売管理費
$sales = 0; //売上高
$ope_profit = 0; //営業利益
$rate_ope_profit = 0.0; //売上高営業利益率
$ind_name = "00000000000000000000"; //該当業種名
$ave_rate_ope_profit = 0.0; //業種別率平均
$margin_rate_ope_profit = 0.0; //自社と平均との差異
//計算部
//業種コード
$ind_type = $_POST['Iind_type'];
//業種データ読込準備
$ind_name = "該当なし:4.5で計算";
$ave_rate_ope_profit = 4.5;
//業種データ読込み:業種名、業種平均値
for($intA = 0; $intA < 8; $intA++){
if($ind_type == $Aind_code[$intA]){
$ind_name = $Aind_name[$intA];
$ave_rate_ope_profit = $Aind_ave[$intA];
break;
}
}
//売上総利益
$cost_sales = $_POST['Icost_sales'];
//販売管理費
$sales_man_cost = $_POST['Isales_man_cost'];
//売上高
$sales = $_POST['Isales'];
//営業利益
$ope_profit = $cost_sales - $sales_man_cost;
//売上高営業利益率
$rate_ope_profit = $ope_profit / $sales;
//自社と平均との差異
$margin_rate_ope_profit = $rate_ope_profit - $ave_rate_ope_profit;
//変数表示テスト echo ("intA" . $intA . "
"); //汎用ループカウンタ
//変数表示テスト echo ("ind_type" . $ind_type . "
"); //該当業種コード
//変数表示テスト echo ("cost_sales" . $cost_sales . "
"); //売上総利益
//変数表示テスト echo ("sales_man_cost" . $sales_man_cost . "
"); //販売管理費
//変数表示テスト echo ("sales" . $sales . "
"); //売上高
//変数表示テスト echo ("ope_profit" . $ope_profit . "
"); //営業利益
//変数表示テスト echo ("rate_ope_profit" . $rate_ope_profit . "
"); //売上高営業利益率
//変数表示テスト echo ("ind_name" . $ind_name . "
"); //該当業種名
//変数表示テスト echo ("ave_rate_ope_profit" . $ave_rate_ope_profit . "
");
//変数表示テスト //業種別率平均
//変数表示テスト echo ("margin_rate_ope_profit" . $margin_rate_ope_profit . "
");
//変数表示テスト //自社と平均との差異
//変数表示テスト//}
}
////////////////////////////////////////////////////////////
//入力データの確認
////////////////////////////////////////////////////////////
function chk_input(){
$iErr = false;
if ($_POST["Iind_type"] == ""){
echo("業種コードが入力されていないか値が不正です
");
$iErr = ture;
}
if (($_POST["Icost_sales"] == "") || (is_numeric($_POST["Icost_sales"]) == false) || $_POST["Icost_sales"] == 0 ){
echo("売上総利益が入力されていないか値が不正です
");
$iErr = ture;
}
if (($_POST["Isales_man_cost"] == "") || (is_numeric($_POST["Isales_man_cost"]) == false)){
echo("販売管理費が入力されていないか値が不正です
");
$iErr = ture;
}
if (($_POST["Isales"] == "") || (is_numeric($_POST["Isales"]) == false) || $_POST["Isales"] == 0){
echo("売上高が入力されていないか値が不正です
");
$iErr = ture;
}
return $iErr;
}
?>
1 | 業種コード | echo($ind_type); ?> |
2 | 業種 | echo($ind_name); ?> |
3 | 売上高 | echo($sales); ?> |
4 | 売上総利益 | echo($cost_sales); ?> |
5 | 販売管理費 | echo($sales_man_cost) ?> |
6 | 営業利益 | echo($ope_profit) ?> |
7 | 売上高営業利益率 | echo($rate_ope_profit); ?> |
8 | 平均と差 | echo($margin_rate_ope_profit); ?> |