| Quintiq file version 2.0 | 
| #parent: PanelOperation/ButtonProductionImport660 | 
| Response OnClick () id:Response_PanelOperation_ButtonProductionImport660_OnClick | 
| { | 
|   #keys: '[415136.0.1194549736]' | 
|   CanBindMultiple: false | 
|   DefinitionID: 'Responsedef_WebButton_OnClick' | 
|   Precondition: | 
|   [* | 
|     return not isnull( MacroPlan ); | 
|   *] | 
|   QuillAction | 
|   { | 
|     Body: | 
|     [* | 
|       try { | 
|         uploadJsonString := Application.GetFile(); | 
|         if ( uploadJsonString <> "" ) { | 
|           uploadJson := JSON::Parse( uploadJsonString ); | 
|           Archive::VerifyTheFileName( uploadJson ); | 
|                  | 
|           fileName := uploadJson.Get( "name" ).GetString(); | 
|           base64String := uploadJson.Get( "data" ).GetString(); | 
|                | 
|           webFileBinaryData := BinaryData::FromBase64EncodedString( base64String ).AsBinaryValue(); | 
|            | 
|           source := FinancialProductionSource::Upload( MacroPlan, webFileBinaryData, fileName ); | 
|           source.ReadStructure(); | 
|            | 
|           if( not source.IsExistFutureMonthData() or  | 
|               ( source.IsExistFutureMonthData() and WebMessageBox::Question( this, Translations::MP_FinancialProductionReport_Question(), 'Yes|No' ) = 0 ) ){ | 
|              FinancialProductionSource::Initialize( MacroPlan ); | 
|              source.AfterImport(); | 
|              productids              := selectuniquevalues( DataHolderProduct.Data(), Elements, product, exists( dhGenerations.Data(), Elements, e, e.Generation() = product.Generation() ) | 
|                                                        and exists( dhMQBMLBs.Data(), Elements, e, e.MLBMQB() = product.MQBMLB() ) | 
|                                                        and exists( dhPowers.Data(), Elements, e, e.Power() = product.Power() ), product.ID() ); | 
|          | 
|              table                   := selectobject( MacroPlan, FinancialProductionSource.FinancialProductionReport, table, table.IsShow() ); | 
|              table.Generate( dhSearch.Data(), dhFactorys.Data(), productids ); | 
|              DataHolderTable.Data( table ); | 
|           } | 
|            | 
|           WebMessageBox::Success( Translations::A_VWED_Success() ); | 
|           traverse( MacroPlan, FinancialProductionSource, psource, psource.IsImport() and psource <> source ){ | 
|             psource.Delete(); | 
|           } | 
|         } | 
|       } onerror { | 
|         WebMessageBox::Error( e.GeneralInformation() ); | 
|       } | 
|     *] | 
|     GroupServerCalls: false | 
|   } | 
| } |