RCV3010.php 6.76 KB
<?PHP 
//*****************************************************************************
//* プログラム名:請求・入金管理
//* プログラムID:RCV3010.php
//* 機能        :請求管理画面
//*****************************************************************************
header("Content-type: text/html; charset=EUC-JP");
include("./inc/session_start.inc");
include("./inc/SessionChk.inc");
include("./inc/dbcon.inc");
include('./inc/smarty.conf');

$rcv_id          = $_POST["rcv_id"];
$div_id          = $_POST["div_id"];

//モード 1:売上 2:外注
$uriageMode = $uriageMode;

//*** 請求・入金初期情報 ***//
$strSQL = "SELECT * FROM rcv_kanri WHERE kanri_id=1";
$objRec = pg_exec($strSQL);
if($objRec==false){
		echo("SQL実行に失敗しました(SELECT)");
		exit;
}
if(pg_numrows($objRec)>0){
		$objData  = pg_fetch_object($objRec, 0);
		$RCV_MODE = $objData->kanri_data;
}else{
		$RCV_MODE = "0";
}

//*** 基本情報 ***//
$strSQL = "SELECT * FROM start_tbl";
$objRec = pg_exec($strSQL);
if($objRec==false){
	echo("SQL実行に失敗しました(SELECT)");
	exit;
}
if(pg_numrows($objRec)>0){
	$objData = pg_fetch_object($objRec, 0);
	$start_unit = $objData->start_unit;
}else{
	$start_unit = "0";
}

switch ($start_unit) {
case "0":
		$Money_Tani = "円";
		break;
case "1":
		$Money_Tani = "千円";
		break;
case "2":
		$Money_Tani = "万円";
		break;
}

switch ($uriageMode) {
case "1":
		$LstHead = "入金";
		break;

case "2":
		$LstHead = "支払";
		break;
}

if ($Reload==1){
		$cboInpArea      = $cboInpArea;
		$cboInpGyousya   = $cboInpGyousya;
		$cboInpGyoumu    = $cboInpGyoumu;

		$txtInpKigen     = $txtInpKigen;
		$txtInpMoney     = $txtInpMoney;

		$txtInpNDate     = $txtInpNDate;
		$txtInpNMoney    = $txtInpNMoney;

		$txtInpMemo      = $txtInpMemo;

		$txtCalKigen     = $txtInpKigen;
		$txtCalNDate     = $txtInpNDate;

}else if ($rcv_id !=""){
		//修正
		$strSQL = "SELECT * FROM rcv_tbl WHERE rcv_id = ".$rcv_id;
		$objRec = pg_exec($strSQL);
		if($objRec==false){
			echo("SQL実行に失敗しました(SELECT)");
			exit;
		}
		$objData = pg_fetch_object($objRec, 0);

		$cboInpArea      = $objData->rcv_area_id;
		$cboInpGyousya   = $objData->rcv_gyousya_id;
		$cboInpGyoumu    = $objData->rcv_gyoumu_id;

		if ($objData->rcv_seikyukbn=="1"){
				$optSeikyukbn[1] = "checked";
				$optSeikyukbn[2] = "";
		}else{
				$optSeikyukbn[1] = "";
				$optSeikyukbn[2] = "checked";
		}

		$txtInpKigen     = $objData->seikyu_kigen;
		$txtInpMoney     = $objData->seikyu_money;

		$txtInpNDate     = $objData->nyukin_date;
		$txtInpNMoney    = $objData->nyukin_money;

		$txtInpMemo      = $objData->memo_txt;

		$txtCalKigen     = $objData->seikyu_kigen;
		$txtCalNDate     = $objData->nyukin_date;

		if ($chkDisp==""){
				$chkDisp=0;
		}
}else{
		$cboInpArea      = "";
		$cboInpGyousya   = "";
		$cboInpGyoumu    = "";

		$optSeikyukbn[1] = "checked";
		$optSeikyukbn[2] = "";

		$txtInpMoney     = "";
		$txtInpKigen     = "";

		$txtInpNDate     = "";
		$txtInpNMoney    = "";
		$txtInpMemo      = "";

		$txtCalKigen     = date("Y/m/d");
		$txtCalNDate     = date("Y/m/d");

		if ($chkDisp==""){
				$chkDisp=1;
		}
}

if ($chkDisp==1){
		$chkSel = "checked";
}else{
		$chkSel = "";
}

//*** 拠点情報 ***//
$strSQL = "SELECT * FROM user_area WHERE user_seq = ".$PHP_USER_SEQ." ";
$objRec = pg_exec($strSQL);
if($objRec==false){
		echo("SQL実行に失敗しました(SELECT)");
		exit;
}
$User_Area[0] = "";
for ($intCnt = 0; $intCnt < pg_numrows($objRec); $intCnt++) {
		$objData = pg_fetch_object($objRec, $intCnt);
		$User_Area[$intCnt] = $objData->area_id;
}

$AreaData = '';
if ($User_Area[0]!=""){
		$strSQL  = "SELECT * FROM bumon_tbl WHERE ";
		for ($intI = 0; $intI < count($User_Area); $intI++) {
				if ($intI!="0"){
						$strSQL  .= " OR ";
				}
				$strSQL .= " bumon_seq = ".$User_Area[$intI];
		}
		$strSQL .= " ORDER BY disp_rank";
		$objRec = pg_exec($strSQL);
		if($objRec==false){
				echo("SQL実行に失敗しました(SELECT)");
				exit;
		}
		for ($intCnt = 0; $intCnt < pg_numrows($objRec); $intCnt++) {
				$objData = pg_fetch_object($objRec, $intCnt);

				if (($intCnt==0) && ($cboInpArea=="")){
						$cboInpArea = $objData->bumon_seq;
				}

				$AreaData .= '<OPTION value="'.$objData->bumon_seq.'" ';
				if ($cboInpArea==$objData->bumon_seq){
					$AreaData.="selected";
				}
				$AreaData .='>'.$objData->bumon_name.'</OPTION>';
		}
}


//*** 業者情報 ***//
$GyousyaData = '';
$strSQL  = "SELECT * FROM mst_gyousya ";
switch ($uriageMode) {
case "1":
		$strSQL .= "WHERE disp_mode1=1 ";
		break;
case "2":
		$strSQL .= "WHERE disp_mode2=1 ";
		break;
}
$strSQL .= "ORDER BY gyousya_name";
$objRec = pg_exec($strSQL);
if($objRec==false){
		echo("SQL実行に失敗しました(SELECT)");
		exit;
}
for ($intCnt = 0; $intCnt < pg_numrows($objRec); $intCnt++) {
		$objData = pg_fetch_object($objRec, $intCnt);
		$GyousyaData .= '<OPTION value="'.$objData->gyousya_id.'" ';
		if ($cboInpGyousya==$objData->gyousya_id){
			$GyousyaData.="selected";
		}
		$GyousyaData .='>'.$objData->gyousya_name.'</OPTION>';
}

//*** 業務情報 ***//
$GyoumuData = '';
$strSQL = "SELECT * FROM mst_gyoumu WHERE gyoumu_area=".$cboInpArea;
if ($chkDisp==1){
		$strSQL .= " AND gyoumu_ed_term>='".$Kijyun_Year."/".$Kijyun_Month."/01' ";
}

$strSQL .= " ORDER BY gyoumu_name";
$objRec = pg_exec($strSQL);
if($objRec==false){
		echo("SQL実行に失敗しました(SELECT)");
		exit;
}
for ($intI = 0; $intI < pg_numrows($objRec); $intI++) {
		$objData = pg_fetch_object($objRec, $intI);
		$GyoumuData .= '<OPTION value="'.$objData->gyoumu_id.'" ';
		if ($cboInpGyoumu==$objData->gyoumu_id){
			$GyoumuData.="selected";
		}
		$koban="";
		if(trim($objData->gyoumu_koban)!=""){
			$koban=trim($objData->gyoumu_koban)." ";
		}
		
		$GyoumuData .='>'.$koban.$objData->gyoumu_name.'</OPTION>';
}


$o_smarty->assign('Money_Tani' , $Money_Tani);		//金額単位
$o_smarty->assign('RCV_MODE'   , $RCV_MODE);			//請求管理モード

$o_smarty->assign('LstHead'    , $LstHead);						//一覧タイトル

$o_smarty->assign('rcv_id'    ,  $rcv_id);						// キー
$o_smarty->assign('div_id'    ,  $div_id);						// DIVの場所

$o_smarty->assign('AreaData'    ,  $AreaData);				// 拠点情報
$o_smarty->assign('GyousyaData' ,  $GyousyaData);			// 業者情報

$o_smarty->assign('GyoumuData',    $GyoumuData);			// 業務情報
$o_smarty->assign('chkSel'    ,    $chkSel);			// 業務情報

$o_smarty->assign('optSeikyukbn',  $optSeikyukbn);		// 業務情報

$o_smarty->assign('txtInpKigen' ,  $txtInpKigen);			// 支払い期限
$o_smarty->assign('txtInpMoney' ,  $txtInpMoney);			// 請求金額

$o_smarty->assign('txtInpNDate'  , $txtInpNDate);			// 入金日
$o_smarty->assign('txtInpNMoney' , $txtInpNMoney);		// 入金額

$o_smarty->assign('txtCalSeikyu' , $txtCalSeikyu);		// 入金額
$o_smarty->assign('txtCalKigen'  , $txtCalKigen);			// 入金額
$o_smarty->assign('txtCalNDate'  , $txtCalNDate);			// 入金額
;
$o_smarty->assign('txtInpMemo'  , $txtInpMemo);				// メモ

$o_smarty->display('RCV3010.tpl');

?>