
Dave Smith - 2018-03-03 12:31:16 -
In reply to message 1 from WAAAUH
The example provided is a basic management screen. It displays the immediate left and right legs for any selected rep and a breadcrumb working its way up the sponsors to the primary rep for that tree.
If you are asking how to add the next level to the management screen... it can be done, however it adds complexity to the management that can be confusing. I will explain how to display 3 levels and you can deal with the complex forms to manage that many levels from one screen.
If you are only asking how to display the levels, then here is how to get that data.
With three levels we need information on...
Current Rep
Sub L - Sub R
Sub L L - Sub L R - Sub R L - Sub R R
We would use the rRep method to get the data we needed, assuming we instantiated the class as $mbinary and are using the record ID to retrieve the data...
$curRep = $mbinary->rRep($curID);
The $curID will come from key value pair we choose to make available as a request. For example, if it is in the URL as ?id=4, then $curID = $_REQUEST['id'], which in this case will be 4.
The $curRep will be a json object containing the current rep and immediate left and right reps sponsored. What we will call Sub L and Sub R.
We would use this to get the next level down from the Subs...
if( !empty($curRep->reps) ){
if( $currentRep->reps[0]->leg ){
$subL = ( empty($curRep->reps[1]) ) ? null : $curRep->reps[1];
$subR = $curRep->reps[0];
}else{
$subL = $curRep->reps[0];
$subR = ( empty($curRep->reps[1]) ) ? null : $curRep->reps[1];
}
}
The logic above just tests that there are reps and places them on the proper leg. Now we can get the reps for each of those legs...
$dataL = $mbinary->rRep($subL->recordID);
$dataR = $mbinary->rRep($subR->recordID);
You would use the same logic above applied to the $dataL and then again to the $dataR object to assign the $subLL, $subLR, $subRL and $subRR. When it is all done, you will have an object for the current rep and 2 levels down as...
$curRep
$subL - $subR
$subLL - $subLR - $subRL - $subRR