| Quintiq file version 2.0 | 
| #parent: #root | 
| Method CanResequenceCampaign ( | 
|   Campaign_MP targetcampaign, | 
|   Unit targetunit, | 
|   DateTime droptime, | 
|   output String feedback_o | 
| ) declarative remote as Boolean | 
| { | 
|   TextBody: | 
|   [* | 
|     isvalid := true; | 
|      | 
|     //workaround to fix the webclient precondition issue when the ondroptarget is Transition | 
|     if( isnull( targetcampaign ) ) | 
|     { | 
|       targetcampaign := minselect( targetunit, Campaign_MP, campaign, | 
|                                    campaign.End() > droptime, | 
|                                    campaign.Start() ); | 
|     } | 
|      | 
|     if( not isnull( targetcampaign ) | 
|         and targetcampaign.CampaignType_MP() <> this | 
|         and not CampaignType_MP::CheckHasTransitionType( this, targetcampaign.CampaignType_MP() ) ) | 
|     { | 
|       isvalid := false; | 
|       feedback_o := Translations::MP_Campaign_CanResequence_CampaignTypeForbiddenTransition( this.Name(), | 
|                                                                                              targetcampaign.CampaignTypeName() ); | 
|     } | 
|      | 
|     if( not isnull( targetcampaign ) | 
|         and not isnull( targetcampaign.PreviousCampaign() ) | 
|         and targetcampaign.PreviousCampaign().CampaignType_MP() <> this | 
|         and not CampaignType_MP::CheckHasTransitionType( targetcampaign.PreviousCampaign().CampaignType_MP(), this ) ) | 
|     { | 
|       isvalid := false; | 
|       feedback_o := Translations::MP_Campaign_CanResequence_CampaignTypeForbiddenTransition( targetcampaign.PreviousCampaign().CampaignTypeName(),  | 
|                                                                                              this.Name() ); | 
|     } | 
|      | 
|     //target campaign is only null if it is dropped at the empty space after last campaign | 
|     //check if there is transition between the last campaign's campaign type and the source campaign type | 
|     if( isnull( targetcampaign ) | 
|         and not isnull( targetunit.LastCampaign() ) | 
|         and targetunit.LastCampaign().CampaignType_MP() <> this | 
|         and not CampaignType_MP::CheckHasTransitionType( targetunit.LastCampaign().CampaignType_MP(), this ) ) | 
|     { | 
|       isvalid := false; | 
|       feedback_o := Translations::MP_Campaign_CanResequence_CampaignTypeForbiddenTransition( targetunit.LastCampaign().CampaignTypeName(), | 
|                                                                                              this.Name() ); | 
|     } | 
|      | 
|     if( this.Unit() <> targetunit ) | 
|     { | 
|       isvalid := false; | 
|       feedback_o := Translations::MP_Campaign_CanResequence_SourceUnitAndTargetUnitAreDifferent( this.UnitID(), targetunit.ID() );  | 
|     } | 
|      | 
|     if( droptime < this.MacroPlan().StartOfPlanning() ) | 
|     { | 
|       isvalid := false; | 
|       feedback_o := Translations::MP_Campaign_CanResequence_DroptimeBeforePlanningHorizon();     | 
|     } | 
|      | 
|     return isvalid; | 
|   *] | 
| } |