From which "Angebot" does "Lieferschein" come from?

I am the predecessor of a routined programmer and understand the code but have some difficulties in finding the right syntax for the code and where to write in what way.

I have two forms (Lieferschein) and (Angebot) and can create a Lieferschein from Angebot. For this I copied

public function actionLieferscheinerstellen($id){…}

out of the LieferscheinController into AngebotController

When I want to create a Lieferschein out of an Angebot I click the corresponding button in the Indexview and a new actionLieferscheinerstellen is executed.
I would like to link Angebot with Lieferschein, so it is possible to say from which Angebot Lieferschein with (e.g.) lieferscheinNr = ‘17’ was generated.

For this I created a column in the table “lieferscheine” with the name angebotNrlieferschein.
I need a method which puts the corresponding angebotNr from the table “angebote” in angebotNrlieferschein so i can use theese numbers to show on the formulars from which Angebot said Lieferschein was generated.

lieferscheinNr is generated whith looking up max lieferscheinnr and adding 1 on it. This wouldnt work for angebotNr because there can be an old Angebot from which I want to generate a Lieferschein.

This is the code

public function actionLieferscheinerstellen($id)
	if (($model = Recangeboten::findOne($id)) !== null) 
		$_max_plus_1=reclieferscheine::find()->select('Max(lieferscheinNr)+1 as nrxxx ')->asArray()->one();
		$models = Recwarenangebot::find()
		->where(" angeboten_id_angebot=".$id)
		$modeleinstellung = Receinstellungen::findOne(['art' => 'Lieferschein']);

		if($modeleinstellung !==null)

		echo $_datum=Yii::$app->formatter->asDate(date('Y-m-d'));
		$modelLieferschein = new Reclieferscheine();
		$modelLieferschein->datum=new yii\db\Expression('NOW()');


			return Yii::$app->response->redirect(['reclieferscheine/update', 'id' => $lieferscheineid]);
			echo "Not save"; 

I tried something like this

$modelRecverlinkung = new Recverlinkung();
$modelRecverlinkung->angebotNr_lieferscheinNr =$_mx;

didnt work though :wink:

Am thankful for any suggestions.
Best regards,

anyone? :pleading_face: