| Quintiq file version 2.0 | 
| #parent: #root | 
| Method ExtendCombiWithNextSubPeriod | 
| { | 
|   Description: 'Determine if the combi needs to be extended with an additional sub period. This is the case if there is only one element type in the combi and the (min/max)end time of the element extend beyond the subperiod.' | 
|   TextBody: | 
|   [* | 
|     lastelement := this.LastCombiElement(); | 
|     if( isnull( lastelement.OptCampaignUnitSubPeriod().NextSubPeriod() ) ) | 
|     { | 
|       /////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 
|       //There are no periods to extend to so close the combi to make it does not end in an endless loop.  | 
|       /////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 
|       this.IsCompleteCombi( true ); | 
|     } | 
|     else | 
|     { | 
|       /////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 
|       //Extend the combi with the same element in the next subperiod | 
|       /////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 
|       if( lastelement.istype( OptCampaignCombiElementCampaign ) ) | 
|       { | 
|         OptCampaignCombiElementCampaign::Create( this, lastelement.astype( OptCampaignCombiElementCampaign ).CampaignType_MP(), lastelement.OptCampaignUnitSubPeriod().NextSubPeriod() ); | 
|       } | 
|       else | 
|       { | 
|         OptCampaignCombiElementTransition::Create( this, lastelement.astype( OptCampaignCombiElementTransition ).TransitionType_MP(), lastelement.OptCampaignUnitSubPeriod().NextSubPeriod() ); | 
|       } | 
|     } | 
|   *] | 
| } |