function db_entry($gc) {

	set_time_limit(600);

	$gc->db->begin_tran();

	$file_name = C_TMP_PATH.$gc->tmp_company_area_file;

	if ( ($gc->tmp_company_area_file != "") and file_exists($file_name)) {

		$fp = fopen($file_name, 'r');
		$cnt = 0;
		while(($line=f_mb_fgetcsv($fp)) !== false){
			if(count($line) > 1){
				if(implode("",$line)!=""){
					if($cnt >0){

						$todoufuken_no = $line[0];	//都道府県コード
						$todoufuken_nm = $line[1];	//都道府県名
						$shikucyouson_no = $line[2];	//市区町村コード
						$shikucyouson_nm = $line[3];	//市区町村名

						for ($i=5; $i<count($line); $i=$i+2) {
							$company_no = $line[$i];	//提携会社コード
							$shikucyouson_kingaku = $line[$i+1];	//金額
							$delete_flg = 0;
							$edit_flg = 0;
							$sql = "";

							if($shikucyouson_kingaku > 0){
								if($gc->company_no > 0){
									if($gc->company_no == $company_no){
										$edit_flg = 1;
									}
								}else{
									$edit_flg = 1;
								}
							}else{
								if($gc->company_no > 0){
									if($gc->company_no == $company_no){
										$delete_flg = 1;
									}
								}else{
									$delete_flg = 1;
								}
							}

							if($edit_flg == 1){
								if(checkinsert($gc, $company_no, $shikucyouson_no)){
									$sql =" INSERT INTO m_company_area( ";
									$sql.="  company_no";
									$sql.=" , shikucyouson_no";
									$sql.=" , shikucyouson_kingaku";
									$sql.=" ) VALUES ( ";
									$sql.= f_num_edit_db($company_no).",";
									$sql.= f_num_edit_db($shikucyouson_no).",";
									$sql.= f_num_edit_db($shikucyouson_kingaku);
									$sql.= ")";
								}else{
									$sql =" UPDATE m_company_area SET ";
									$sql.="  company_no='".f_num_edit_db($company_no)."'";
									$sql.=" , shikucyouson_no='".f_num_edit_db($shikucyouson_no)."'";
									$sql.=" , shikucyouson_kingaku='".f_num_edit_db($shikucyouson_kingaku)."'";
									$sql.= " WHERE company_no='".f_num_edit_db($company_no)."' AND shikucyouson_no='".f_num_edit_db($shikucyouson_no)."'";
								}
								$ret = $gc->db->execute($sql, true);
								if($ret["errno"] > 0){
									$gc->db->rollback();
									if(db_set_errmsg($gc, $ret["errno"], $ret["error"])){
										//echo $sql;
										return false;
									}else{
										die('system error1');
									}
									return false;
								}
							}elseif($delete_flg == 1){
								if(!checkinsert($gc, $company_no, $shikucyouson_no)){
									$sql =" DELETE from m_company_area";
									$sql.= " WHERE company_no='".f_num_edit_db($company_no)."' AND shikucyouson_no='".f_num_edit_db($shikucyouson_no)."'";
									$ret = $gc->db->execute($sql, true);
									if($ret["errno"] > 0){
										$gc->db->rollback();
										if(db_set_errmsg($gc, $ret["errno"], $ret["error"])){
											//echo $sql;
											return false;
										}else{
											die('system error1');
										}
										return false;
									}
								}
							}

						}
					}
					$cnt++;
				}
			}
		}

		fclose($fp);

	}

	$gc->db->commit();

	return true;

}
function db_entry($gc) {

	set_time_limit(600);

	$gc->db->begin_tran();

	$file_name = C_TMP_PATH.$gc->tmp_buken_file;

	if ( ($gc->tmp_buken_file != "") and file_exists($file_name)) {

		$fp = fopen($file_name, 'r');
		$cnt = 0;
		while(($line=f_mb_fgetcsv($fp)) !== false){
			if(count($line) > 1){
				if(implode("",$line)!=""){
					if($cnt >0){

						$todoufuken_nm = $line[0];	//都道府県
						$shikucyouson_nm = $line[1];	//市区町村
						$town_nm = $line[2];	//町名
						$address = mb_substr($line[3],1);	//番地
						$property_nm = mb_convert_kana($line[4],Kas,"UTF-8");	//物件名
						$railroad = $line[5];	//沿線
						$station = $line[6];	//駅名
						$rent = $line[7];	//賃料
						$unit_price = $line[8];	//㎡単価
						$kouzou = $line[9];	//建物構造
						$tijyokaisu = $line[10];	//地上階数
						$tikakaisu = $line[11];	//地下階数
						$comment = trim($line[12]);	//コメント

						$addressinfo = getaddressinfo($gc, $property_nm, $todoufuken_nm, $shikucyouson_nm, $town_nm, $address, $comment);

						if($addressinfo["return"] == false){
							$gc->msg->add("第".$cnt."行目 物件名:".$property_nm." ".$addressinfo["errmsg"]);
							$gc->db->rollback();
							return false;
						}
						if(checkinsert($gc, $property_nm, $todoufuken_nm, $shikucyouson_nm, $town_nm, $address, $rent)){
							$sql =" INSERT INTO propertydetail( ";
							$sql.="  property_no";
							$sql.=" , property_nm";
							$sql.=" , todoufuken_no";
							$sql.=" , todoufuken_nm";
							$sql.=" , shikucyouson_no";
							$sql.=" , shikucyouson_nm";
							$sql.=" , town_nm";
							$sql.=" , address";
							$sql.=" , railroad";
							$sql.=" , station";
							$sql.=" , kouzou";
							$sql.=" , tijyokaisu";
							$sql.=" , tikakaisu";
							$sql.=" , rent";
							$sql.=" , unit_price";
							$sql.=" , ltime";
							$sql.=" ) VALUES ( ";
							$sql.= f_num_edit_db($addressinfo["property_no"]).",";
							$sql.= "'".f_dbs($property_nm)."',";
							$sql.= f_num_edit_db($addressinfo["todoufuken_no"]).",";
							$sql.= "'".f_dbs($todoufuken_nm)."',";
							$sql.= f_num_edit_db($addressinfo["shikucyouson_no"]).",";
							$sql.= "'".f_dbs($shikucyouson_nm)."',";
							$sql.= "'".f_dbs($town_nm)."',";
							$sql.= "'".f_dbs($address)."',";
							$sql.= "'".f_dbs($railroad)."',";
							$sql.= "'".f_dbs($station)."',";
							$sql.= f_num_edit_db($kouzou).",";
							$sql.= f_num_edit_db($tijyokaisu).",";
							$sql.= f_num_edit_db($tikakaisu).",";
							$sql.= f_num_edit_db($rent).",";
							$sql.= f_num_edit_db($unit_price).",";
							$sql.= "CURRENT_TIMESTAMP)";

							$ret = $gc->db->execute($sql, true);

							if($ret["errno"] > 0){
								$gc->db->rollback();
								if(db_set_errmsg($gc, $ret["errno"], $ret["error"])){
									//echo $sql;
									return false;
								}else{
									die('system error1');
								}
								return false;
							}
						}
					}
					$cnt++;
				}
			}
		}

		fclose($fp);

	}

	$gc->db->commit();

	return true;

}