<?php
	// orphan records as well
	function fo3_migrate_job_quotes( $db , $job_id , $oldid ) {
		$query = sprintf( "select * from fo_offer_sent where offerid=%d and userid in (select id from fo_user)" , $oldid );
		$data = FNTH_db_get_resultset( $query , $db );
		if (empty( $data )) return;
		$member = new MemberModel();
		foreach ($data as $row) {
			$member_id = $member->getMemberIdFromOldid( $row["userid"] );
			if (!$member_id) continue;
			$ins = array();
			$ins["job_id"]=$job_id;
		
			$ins["member_id"]=sprintf( "sp_get_member_id_from_oldid( %d )" , $row["userid"] );
			$ins["ctstamp"]=sprintf( "'%s'" , $row["ststamp"] );
			$ins["quote"]=sprintf( "'%s'",FNTH_db_addslashes( $row["message"] ) );
			FNTH_db_free_result( FNTH_db_query( FNTH_db_generate_insert_query( "job_quotes" , $ins ) ) );
		}
	}

?>
