
<link rel="stylesheet" type="text/css" href="includes/js/select2/css/select2.min.css"/>
<script type="text/javascript" src="includes/js/select2/js/select2.full.min.js"></script>
<script type="text/javascript" src="includes/js/select2/js/i18n/de.js"></script>

<script type="text/javascript" src="includes/js/jquery-ui-timepicker-addon.js"></script>
<link rel="stylesheet" type="text/css" href="styles/[% $CSSTEMPLATE %]/css/jquery-ui-timepicker-addon.css" />
<style>
    .color-star{
        color:yellow;
    }
</style>
<!-- ###CONTENT### begin -->

<div class="card panel-fcs-border shadow-sm">
    <div class="card-header">
        <div class="row">
            <div class="col-sm-6">
                <span class="fcs-card-title h2">[%$user->gettext('Change Requests')%]</span>        
            </div>
            <div class="col-sm-6 text-end">
                <input type="button" class="btn btn-outline-primary" value="[% $user->gettext('Liste') %]" onclick="window.location.href = '?module=changerequest';" />                
            </div>
        </div>


    </div>
    <div class="card-body">
        <div class="col-lg-10 offset-md-1">
            <form action="index.php?module=changerequest&event=[% if $request[0].phase < 2 %]create[% else %]update[% /if %]" method="post" name="ChangeRequest" enctype="multipart/form-data" class="form-horizontal form-label-left">
                <input type="hidden" name="phase" value="1" />
                <input type="hidden" name="id" value="[% $request[0].changerequestid %]" />

                <div class="card panel-info shadow-sm rounded">

                    <div class="card-header">

                        <div class="row">
                            <a class="collapsed" role="tab" id="headingAntrag" data-toggle="collapse"  href="#application" aria-expanded="false">
                                <div class="col-lg-6">                                
                                    <span class="fcs-card-title h3">[% $user->gettext('Antrag') %] 
                                        [% if $request[0].phase > 1 && $request[0].phase != 77 && $request[0].phase != 88 %]anzeigen <span class="fa fa-check-circle" style="color:green;"></span>[% /if %]

                                        [% if $request[0].phase == 77  %] [% $user->gettext('abgelehnt') %][% /if %]
                                        [% if $request[0].phase < 2  || $error[0].denyreason %] <span class="fa fa-plus-sign"></span>[% /if %]
                                    </span>                               
                                </div>
                            </a>
                            <div class="col-lg-6 text-end">
                                <div class="btn-group">							
                                    [% if ($request[0].phase == 77 || $request[0].phase == 88) && $request[0].requesterid == $user->UserID %]<input type="button" class="btn btn-outline-primary" value="[% $user->gettext('Wiedervorlage') %]" onclick="document.location.href = 'index.php?module=changerequest&event=renew&id=[% $request[0].changerequestid %]'" />[% /if %]
                                    [% if $user->hasRight(301) && $request[0].phase == 2 && $Tools->FCS_Count($request[0]) %]<input type="button" class="btn btn-outline-secondary" value="[% $user->gettext('Ablehnen') %]" onclick="document.getElementById('DenyRequest').value = 1; document.ChangeRequest.submit();" />[% /if %]
                                    [% if $request[0].phase < 2 %]<input type="submit" class="btn btn-outline-primary" value="[% $user->gettext('Speichern') %]" />[% /if %]
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="application" class="panel-collapse collapse [% if $request[0].phase < 2 || $request[0].phase == 77 || $request[0].phase == 88  || $error[0].denyreason %]in[% /if %]" role="tabpanel" aria-labelledby="antrag" aria-expanded="false" style="">
                        <div class="card-body">

                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="form-group row mb-3">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Antragsteller') %]:
                                        </label>
                                        <div class="col-lg-9">
                                            <input type="text" value="[% $request[0].requester %]" class="form-control" readonly="readonly" />
                                        </div>
                                    </div>

                                    <div class="form-group row mb-3">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Initiator') %]:
                                            [% if $request[0].phase < 2 %]*
                                            [% /if %]
                                        </label>
                                        <div class="col-lg-9">
                                            [% if $request[0].phase < 2 %]
                                                <input type="text" name="Initiator" value="[% $request[0].initiator %]" class="form-control"  required="required"/>
                                            [% else %]
                                                <input type="text" value="[% $request[0].initiator %]" class="form-control"  style="width:360px;" readonly="readonly" />
                                            [% /if %]
                                        </div>
                                    </div>

                                    <div class="form-group row mb-3">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Betreff') %]:
                                            [% if $request[0].phase < 2 %]*
                                            [% /if %]
                                        </label>
                                        <div class="col-lg-9">
                                            [% if $request[0].phase < 2 %]
                                                <input type="text" name="Subject" value="[% $request[0].subject %]" class="form-control"  required="required"/>
                                            [% else %]
                                                <input type="text" value="[% $request[0].subject %]" class="form-control" readonly="readonly" />
                                            [% /if %]
                                        </div>
                                    </div>
                                    <div class="form-group row mb-3">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Betroffene<br />Systeme/Produkte') %]:
                                        </label>
                                        <div class="col-lg-9">
                                            [% if $request[0].phase < 2 %]
                                                <textarea class="form-control" rows="10" name="SystemsConcerned">[% $request[0].systemsconcerned %]</textarea>
                                            [% else %]
                                                <textarea class="form-control" rows="10" readonly="readonly">[% $request[0].systemsconcerned %]</textarea>
                                            [% /if %]
                                        </div>
                                    </div>


                                    <div class="form-group row mb-3" id="AntragAblehnen">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Zusammenfassende<br />Beschreibung') %]:
                                            [% if $request[0].phase < 2 %]*
                                            [% /if %]
                                        </label>
                                        <div class="col-lg-9">
                                            [% if $request[0].phase < 2 %]
                                                <textarea class="form-control" rows="10"   name="Summary" required="required">[% $request[0].summary %]</textarea>
                                            [% else %]
                                                <textarea class="form-control" rows="10"  readonly="readonly">[% $request[0].summary %]</textarea>
                                            [% /if %]
                                        </div>
                                    </div>


                                    [% if $request[0].phase == 77 || ($request[0].phase == 2 && $Tools->FCS_Count($request[0]) && $user->hasRight(301)) %]

                                        <div class="form-group row mb-3 [% if $error[0].denyreason %]has-error[% /if %]">
                                            <label class="col-lg-3 control-label">[% $user->gettext('Begr&uuml;ndung<br />der Ablehnung') %]</label>
                                            <div class="col-lg-9">
                                                [% if ($request[0].phase == 2 && $Tools->FCS_Count($request[0]) && $user->hasRight(301)) %]
                                                    [% if $error[0].denyreason %]<span class="help-block">[% $user->gettext('Geben Sie eine Begründung für die Ablehnung des Antrags an') %]</span>[% /if %] 
                                                    <input type="hidden" name="Deny" value="0" id="DenyRequest" />
                                                    <textarea class="form-control" rows="10" name="DenyReason">[% $request[77].denyreason %]</textarea>
                                                [% else %]
                                                    <textarea class="form-control" rows="10" readonly="readonly">[% $request[0].denyreason %]</textarea>
                                                [% /if %]

                                            </div>
                                        </div>
                                    [% /if %]

                                </div>
                                <div class="col-lg-6">
                                    <div class="form-group row mb-3">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Datum') %]:
                                        </label>
                                        <div class="col-lg-9">
                                            <input type="text" class="form-control" value="[% $request[0].dateofapplication|date_format:"%d.%m.%Y %H:%M" %]" readonly="readonly" />
                                        </div>
                                    </div>

                                    <div class="form-group row mb-3 [% if $error[0].category1 %]has-error[% /if %]">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Kategorie 1') %]:
                                            [% if $request[0].phase < 2 || ($request[0].phase == 2 && $Tools->FCS_Count($request[1]) && $user->hasRight(301)) %]
                                                *
                                            [% /if %]
                                        </label>
                                        <div class="col-lg-9">
                                            [% if $request[0].phase < 2 || ($request[0].phase == 2 && $Tools->FCS_Count($request[1]) && $user->hasRight(301)) %]
                                                <div class="input-group">
                                                    <input type="hidden" name="Category1ID" value="[% $request[0].category1id %]" id="CategoryID1"/>
                                                    <input type="text" class="form-control"  value="[% $request[0].category1 %]" readonly="readonly" id="CategoryDescr1" name="Category1" required="required"/>
                                                    <div class="input-group-text">
                                                        <a href="javascript:openCategory(1);" class="btn btn-outline-primary dialog" ><i class="fa  fa-folder-open"  title="[% $user->gettext('Kategorie ausw&auml;hlen') %]"></i></a>
                                                    </div>
                                                </div>	
                                            [% else %]
                                                <input type="text" class="form-control" value="[% $request[0].category1 %]" readonly="readonly" />
                                            [% /if %]
                                        </div>
                                    </div>

                                    <div class="form-group row mb-3 [% if $error[0].category2 %]has-error[% /if %]">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Kategorie 2') %]:
                                            [% if $request[0].phase < 2 || ($request[0].phase == 2 && $Tools->FCS_Count($request[1]) && $user->hasRight(301)) %]
                                                *
                                            [% /if %]
                                        </label>
                                        <div class="col-lg-9">
                                            [% if $request[0].phase < 2 || ($request[0].phase == 2 && $Tools->FCS_Count($request[1]) && $user->hasRight(301)) %]
                                                <div class="input-group">
                                                    <input type="hidden" name="Category2ID" value="[% $request[0].category2id %]" id="CategoryID2"/>
                                                    <input type="text" class="form-control"  value="[% $request[0].category2 %]" readonly="readonly" id="CategoryDescr2" name="Category2" required="required"/>
                                                    <div class="input-group-text">
                                                        <a href="javascript:openCategory(2);" class="btn btn-outline-primary dialog" ><i class="fa  fa-folder-open"  title="[% $user->gettext('Kategorie ausw&auml;hlen') %]"></i></a>
                                                    </div>
                                                </div>	
                                            [% else %]
                                                <input type="text" class="form-control" value="[% $request[0].category2 %]" readonly="readonly" />
                                            [% /if %]
                                        </div>
                                    </div>

                                    <div class="form-group row mb-3">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Nr. Wiedervorlage') %]:
                                        </label>
                                        <div class="col-lg-9">
                                            <input type="text" class="form-control" value="[% $request[0].reminderno %]" readonly="readonly" />
                                        </div>
                                    </div>

                                    <div class="form-group row mb-3">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Priorität') %]:
                                        </label>
                                        <div class="col-lg-9">
                                            [% if $request[0].phase < 2 || ($request[0].phase == 2 && $Tools->FCS_Count($request[1]) && $user->hasRight(301)) %]
                                                <input type="radio" name="Priority" value="4"[% if $request[0].priority == 4 %] checked="checked"[% /if %] /> [% $user->gettext('Sofort/Dringend') %]<br />
                                                <input type="radio" name="Priority" value="3"[% if $request[0].priority == 3 %] checked="checked"[% /if %] /> [% $user->gettext('Hoch') %]<br />
                                                <input type="radio" name="Priority" value="2"[% if $request[0].priority == 2 %] checked="checked"[% /if %] /> [% $user->gettext('Mittel') %]<br />
                                                <input type="radio" name="Priority" value="1"[% if $request[0].priority < 2 || $request[0].priority > 5 %] checked="checked"[% /if %] /> [% $user->gettext('Niedrig') %]
                                            [% else %]
                                                <input type="text" class="form-control" value="[% if $request[0].priority == 4 %][% $user->gettext('Sofort/Dringend') %][% /if %][% if $request[0].priority == 3 %][% $user->gettext('Hoch') %][% /if %][% if $request[0].priority == 2 %][% $user->gettext('Mittel') %][% /if %][% if $request[0].priority < 2 %][% $user->gettext('Niedrig') %][% /if %]" readonly="readonly" />
                                            [% /if %]
                                        </div>
                                    </div>
                                    <div class="form-group row mb-3">
                                        <label class="control-label col-lg-3">
                                            [% $user->gettext('Folgen') %]:
                                        </label>
                                        <div class="col-lg-9">
                                            [% if $request[0].phase < 2 || ($request[0].phase == 2 && $Tools->FCS_Count($request[1]) && $user->hasRight(301)) %]
                                                <input type="radio" name="Consequences" value="3"[% if $request[0].consequences == 3 %] checked="checked"[% /if %] /> [% $user->gettext('Signifikant') %]<br />
                                                <input type="radio" name="Consequences" value="2"[% if $request[0].consequences == 2 %] checked="checked"[% /if %] /> [% $user->gettext('Erheblich') %]<br />
                                                <input type="radio" name="Consequences" value="1"[% if $request[0].consequences < 2 || $request[0].consequences > 4 %] checked="checked"[% /if %] /> [% $user->gettext('Geringfügig') %]<br />
                                                <input type="radio" name="Consequences" value="4"[% if $request[0].consequences == 4 %] checked="checked"[% /if %] /> [% $user->gettext('Standard') %]
                                            [% else %]
                                                <input type="text" class="form-control" value="[% if $request[0].consequences == 4 %][% $user->gettext('Standard') %][% /if %][% if $request[0].consequences == 3 %][% $user->gettext('Signifikant') %][% /if %][% if $request[0].consequences == 2 %][% $user->gettext('Erheblich') %][% /if %][% if $request[0].consequences <= 1 %][% $user->gettext('Geringfügig') %][% /if %]" readonly="readonly" />
                                            [% /if %]
                                        </div>

                                    </div>
                                    [% if $Tools->FCS_Count($Projects) %]
                                        <div class="form-group row mb-3">
                                            <label class="col-lg-3 control-label">[% $user->gettext('Projekt') %]</label>
                                            <div class="col-lg-9">

                                                

                                                    <select id="selectProject" class="form-control" name="ProjectID" >
                                                        [% html_options options=$Projects selected=$request[0].projectid %]
                                                    </select>
                                                    [% if $request[0].projectid > 0 && $user->hasRight(500) %]
                                                        <br/><br/>
                                                        <a class="btn btn-outline-secondary" href="index.php?module=project&event=edit&id=[% $request[0].projectid %]">[% $user->gettext('Projekt aufrufen') %]</a>
                                                    [% /if %]

                                                

                                            </div>
                                        </div>
                                    [% /if %]


                                    [% if $request[0].phase > 2 || (!$user->hasRight(301) && $request[0].phase == 2) %]
                                        <div class="form-group row mb-3">
                                            <label class="control-label col-lg-3">
                                                [% $user->gettext('Fortschritt') %]:
                                            </label>
                                            <div class="col-lg-9">
                                                [% if $request[0].phase < 2 %]
                                                    <span class="fa-regular fa-star"></span> <span class="fa-regular fa-star"></span><span class="fa-regular fa-star"></span><span class="fa-regular fa-star"></span><span class="fa-regular fa-star"></span>([% $user->gettext('Antrag') %])
                                                    [% /if %]
                                                    [% if $request[0].phase == 2 %]
                                                    <span class="fa-regular fa-star color-star"></span> <span class="fa-regular fa-star"></span><span class="fa-regular fa-star"></span><span class="fa-regular fa-star"></span><span class="fa-regular fa-star"></span> ([% $user->gettext('Auswertung') %])
                                                    [% /if %]
                                                    [% if $request[0].phase == 3 %]
                                                    <span class="fa-solid fa-star color-star"></span> <span class="fa-solid fa-star color-star"></span><span class="fa-solid fa-star color-star"></span><span class="fa-regular fa-star"></span><span class="fa-regular fa-star"></span> ([% $user->gettext('Bewertung') %])
                                                    [% /if %]
                                                    [% if $request[0].phase == 4 %]
                                                    <span class="fa-solid fa-star color-star"></span> <span class="fa-solid fa-star color-star"></span><span class="fa-solid fa-star color-star"></span><span class="fa-solid fa-star color-star"></span><span class="fa-regular fa-star"></span> ([% $user->gettext('Bewertung') %])
                                                    [% /if %]
                                                    [% if $request[0].phase == 5 %]
                                                    <span class="fa-solid fa-star color-star"></span> <span class="fa-solid fa-star color-star"></span><span class="fa-solid fa-star color-star"></span><span class="fa-solid fa-star color-star"></span><span class="fa-solid fa-star color-star"></span>  ([% $user->gettext('Review') %])
                                                    [% /if %]
                                                    [% if $request[0].phase == 77 %]
                                                    <span class="fa fa-circle-minus" style="color:red;"></span> ([% $user->gettext('abgelehnt') %])
                                                [% /if %]
                                                [% if $request[0].phase == 88 %]
                                                    <span class="fa fa-circle-minus" style="color:red;"></span> ([% $user->gettext('fehlgeschlagen') %])
                                                [% /if %]
                                                [% if $request[0].phase == 99 %]
                                                    <span class="fa-solid fa-star color-star"></span> <span class="fa-solid fa-star color-star"></span><span class="fa-solid fa-star color-star"></span><span class="fa-solid fa-star color-star"></span><span class="fa-solid fa-star color-star"></span> ([% $user->gettext('fertig') %])
                                                    [% /if %]
                                            </div>
                                        </div>
                                    [% /if %]
                                </div>

                            </div>
                        </div>
                    </div>

                </div>
            </form>

            [% if $user->hasRight(301) && $Tools->FCS_Count($request[1]) %]
                <form action="index.php?module=changerequest&event=update" method="post" name="Analysis" class="form-horizontal form-label-left">
                    <input type="hidden" name="phase" value="2" />
                    <input type="hidden" name="id" value="[% $request[0].changerequestid %]" />
                    <div class="card panel-info shadow-sm rounded">

                        <div class="card-header">

                            <div class="row">
                                <a class="collapsed" role="tab" id="headingAnalysis" data-toggle="collapse" href="#analysis">
                                    <div class="col-lg-6">                                    
                                        <span class="fcs-card-title h3">[% $user->gettext('Auswertung') %][% if $request[0].phase != 2 %] [% $user->gettext('anzeigen') %][% /if %][% if $request[0].phase > 2 %] <span class="fa fa-check-circle" style="color:green;"></span>[% /if %] 
                                            [% if $request[0].phase == 2 %] <span class="fa fa-plus-sign"></span>[% /if %]                                        
                                        </span>                                    
                                    </div>
                                </a>
                                <div class="col-lg-6 text-end">
                                    <div class="btn-group">                                        
                                        [% if $request[0].phase == 2 %]
                                            [%* <a class="collapsed btn btn-outline-secondary" role="tab" id="headingAntrag" data-toggle="collapse"  href="#application" aria-expanded="false">[% $user->gettext('Ablehnen') %]</a>*%]
                                            <input type="submit" class="btn btn-outline-primary" value="[% $user->gettext('Speichern') %]" />
                                        [% /if %]
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="analysis" class="panel-collapse collapse [% if $request[0].phase == 2 %]in[% /if %]" role="tabpanel" aria-labelledby="auswertung" aria-expanded="false" style="">
                            <div class="card-body">
                                [% if $Tools->FCS_Count($error[1]) %]
                                    <div class="alert alert-danger">
                                        [% if $error[1].create %]
                                            [% $user->gettext('Die Auswertung konnte aus unbekannten Gründen nicht gespeichert werden. Bitte versuchen Sie es erneut') %]
                                        [% else %]
                                            [% $user->gettext('Bitte füllen Sie alle markierten Felder korrekt aus.') %]
                                        [% /if %]
                                    </div>
                                [% /if %]


                                <div class="row">
                                    <div class="col-lg-6">
                                        <div class="form-group row mb-3">
                                            <label class="control-label col-lg-3">
                                                [% $user->gettext('Betroffene Kunden<br />(intern/extern)') %]:
                                                [% if $request[0].phase == 2 %]*[% /if %]
                                            </label>
                                            <div class="col-lg-9">
                                                [% if $request[0].phase == 2 %]
                                                    <textarea class="form-control" rows="5" name="CustomerConcerned" required="required">[% $request[1].customerconcerned %]</textarea>
                                                [% else %]
                                                    <textarea class="form-control" rows="5"  readonly="readonly">[% $request[1].customerconcerned %]</textarea>
                                                [% /if %]
                                            </div>
                                        </div>
                                        <div class="form-group row mb-3">
                                            <label class="control-label col-lg-3">
                                                [% $user->gettext('Betroffene Prozesse') %]:
                                                [% if $request[0].phase == 2 %]*[% /if %]
                                            </label>
                                            <div class="col-lg-9">
                                                [% if $request[0].phase == 2 %]
                                                    <textarea class="form-control" rows="5"  [% if $request[0].phase == 2 %]required[% /if %]  name="ProcessesConcerned">[% $request[1].processesconcerned %]</textarea>
                                                [% else %]
                                                    <textarea class="form-control" rows="5" readonly="readonly">[% $request[1].processesconcerned %]</textarea>
                                                [% /if %]
                                            </div>
                                        </div>

                                        <div class="form-group row mb-3 [% if $error[1].realizationdate %]has-error[% /if %]">
                                            <label class="control-label col-lg-3">
                                                [% $user->gettext('Erwarteter <br> Umsetzungstermin') %]:
                                                [% if $request[0].phase == 2 %]*[% /if %]
                                            </label>
                                            <div class="col-lg-9">
                                                [% if $request[0].phase == 2 %]
                                                    <input type="text" class="form-control datetimepicker" name="RealizationDate" [% if $request[0].phase == 2 %]required[% /if %]  value="[% $request[1].realizationdate|strtotime|date_format:"%d.%m.%Y %H:%M" %]" required="required"/>
                                                [% else %]
                                                    <input type="text" class="form-control" value="[% $request[1].realizationdate|strtotime|date_format:"%d.%m.%Y %H:%M" %]" readonly="readonly" />
                                                [% /if %]
                                            </div>
                                        </div>

                                        <div class="form-group row mb-3">
                                            <label class="control-label col-lg-3">
                                                [% $user->gettext('Geschätzte<br />Investition') %]:
                                                [% if $request[0].phase == 2 %]*[% /if %]
                                            </label>
                                            <div class="col-lg-9">
                                                <div class="input-group">
                                                    [% if $request[0].phase == 2 %]
                                                        <input type="text" class="form-control"  [% if $request[0].phase == 2 %]required[% /if %]  value="[% if $request[1].expectinvestment > 0 %][% $request[1].expectinvestment|number_format:"2":",":"." %][% /if %]" name="ExpectInvestment" />
                                                    [% else %]
                                                        <input type="text" class="form-control"  value="[% if $request[1].expectinvestment > 0 %][% $request[1].expectinvestment|number_format:"2":",":"." %][% /if %]" readonly="readonly" />
                                                    [% /if %]
                                                    <div class="input-group-text">
                                                [% if $hmcompany == 'OTTO FISCHER AG' %][% $user->gettext('CHF') %][% else %][% $user->getCurrency() %][% /if %]
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group row mb-3">
                                    <label class="control-label col-lg-3">
                                        [% $user->gettext('Verrechnung') %]:
                                        [% if $request[0].phase == 2 %]*[% /if %]
                                    </label>
                                    <div class="col-lg-9">
                                        [% if $request[0].phase == 2 %]
                                            <input type="radio" name="Clearing" value="1"[% if $request[1].clearing == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Ja') %]<br />
                                            <input type="radio" name="Clearing" value="0"[% if $request[1].clearing != 1 %] checked="checked"[% /if %] /> [% $user->gettext('Nein') %]
                                        [% else %]
                                            <input type="text" class="form-control" value="[% if $request[1].clearing == 1 %][% $user->gettext('Ja') %][% else %][% $user->gettext('Nein') %][% /if %]" readonly="readonly" />
                                        [% /if %]
                                    </div>
                                </div>

                                <div class="form-group row mb-3">
                                    <label class="control-label col-lg-3">
                                        [% $user->gettext('CAB notwendig') %]:
                                        [% if $request[0].phase == 2 %]*[% /if %]
                                    </label>
                                    <div class="col-lg-9">
                                        [% if $request[0].phase == 2 %]
                                            <input type="radio" name="CABRequired" value="1"[% if $request[1].cabrequired == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Ja') %]<br />
                                            <input type="radio" name="CABRequired" value="0"[% if $request[1].cabrequired != 1 %] checked="checked"[% /if %] /> [% $user->gettext('Nein') %]
                                        [% else %]
                                            <input type="text" class="form-control" value="[% if $request[1].cabrequired == 1 %][% $user->gettext('Ja') %][% else %][% $user->gettext('Nein') %][% /if %]" readonly="readonly" />
                                        [% /if %]
                                    </div>
                                </div>

                                <div class="form-group row mb-3 [% if $error[1].cabdeadline %]has-error[% /if %]">
                                    <label class="control-label col-lg-3">
                                        [% $user->gettext('CAB-Deadline') %]:
                                        [% if $request[0].phase == 2 %]*[% /if %]
                                    </label>
                                    <div class="col-lg-9">
                                        [% if $request[0].phase == 2 %]
                                            <input type="text" class="form-control datetimepicker" name="CABDeadline" [% if $request[0].phase == 2 %]required[% /if %] value="[% $request[1].cabdeadline|strtotime|date_format:"%d.%m.%Y %H:%M" %]" />
                                        [% else %]
                                            <input type="text" class="form-control" value="[% $request[1].cabdeadline|strtotime|date_format:"%d.%m.%Y %H:%M" %]" readonly="readonly" />
                                        [% /if %]
                                    </div>
                                </div>

                                <div class="form-group row mb-3">
                                    <label class="control-label col-lg-3">
                                        [% $user->gettext('CAB-Benachrichtigung') %]:
                                        [% if $request[0].phase == 2 %]*[% /if %]
                                    </label>
                                    <div class="col-lg-9">
                                        [% if $request[0].phase == 2 %]
                                            <input type="radio" name="CABNotify" value="1"[% if $request[1].cabnotify == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Ja') %]<br />
                                            <input type="radio" name="CABNotify" value="0"[% if $request[1].cabnotify != 1 %] checked="checked"[% /if %] /> [% $user->gettext('Nein') %]
                                        [% else %]
                                            <input type="text" class="form-control" value="[% if $request[1].cabnotify == 1 %][% $user->gettext('Ja') %][% else %][% $user->gettext('Nein') %][% /if %]" readonly="readonly" />
                                        [% /if %]
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-6">
                                <div class="form-group row mb-3">
                                    <label class="control-label col-lg-3">
                                        [% $user->gettext('Betroffene Systeme') %]:
                                        [% if $request[0].phase == 2 %]*[% /if %]
                                    </label>
                                    <div class="col-lg-9">
                                        [% if $request[0].phase == 2 %]
                                            <textarea class="form-control" rows="5" [% if $request[0].phase == 2 %]required[% /if %] name="SystemsConcerned">[% $request[1].systemsconcerned %]</textarea>
                                        [% else %]
                                            <textarea class="form-control" rows="5"  readonly="readonly">[% $request[1].systemsconcerned %]</textarea>
                                        [% /if %]
                                    </div>
                                </div>

                                <div class="form-group row mb-3">
                                    <label class="control-label col-lg-3">
                                        [% $user->gettext('Auswirkungen falls<br />Antrag nicht<br />durchgeführt wird (Risiken)') %]:
                                        [% if $request[0].phase == 2 %]*[% /if %]
                                    </label>
                                    <div class="col-lg-9">
                                        [% if $request[0].phase == 2 %]
                                            <textarea class="form-control" rows="5"  name="DenyConsequences">[% $request[1].denyconsequences %]</textarea>
                                        [% else %]
                                            <textarea class="form-control" rows="5"  readonly="readonly">[% $request[1].denyconsequences %]</textarea>
                                        [% /if %]
                                    </div>
                                </div>

                                <div class="form-group row mb-3">
                                    <label class="control-label col-lg-3">
                                        [% $user->gettext('Geschätzte Umsetzungsdauer') %]:
                                        [% if $request[0].phase == 2 %]*[% /if %]
                                    </label>
                                    <div class="col-lg-9">
                                        <div class="input-group">
                                            [% if $request[0].phase == 2 %]
                                                <input type="text" class="form-control" [% if $request[0].phase == 2 %]required[% /if %] value="[% $request[1].realizationperiod %]" name="RealizationPeriod" />
                                            [% else %]
                                                <input type="text" class="form-control"  value="[% $request[1].realizationperiod %]" readonly="readonly" />
                                            [% /if %]
                                            <div class="input-group-text">
                                                [% $user->gettext('(HHH:MM)') %]
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group row mb-3">
                                    <label class="control-label col-lg-3">
                                        [% $user->gettext('CAB Namen') %]:
                                    </label>
                                    <div class="col-lg-9">
                                        <select id="contact" name="CABUsers[]" class="form-control"  multiple="multiple">
                                            [% html_options options=$Contacts selected=$request[1].selected_cabusers %]
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </form>

    [% /if %]
    [% if $user->hasRight(301) && $Tools->FCS_Count($request[2]) && $request[1].cabrequired == 1 %]
        <form action="index.php?module=changerequest&event=update" method="post" name="Rating" class="form-horizontal form-label-left">
            <div class="card panel-info shadow-sm rounded">
                <input type="hidden" name="phase" value="3" />
                <input type="hidden" name="id" value="[% $request[0].changerequestid %]" />
                <div class="card-header">

                    <div class="row">
                        <a data-toggle="collapse" href="#rating">
                            <div class="col-lg-6">                            
                                <span class="fcs-card-title h3">
                                    [% $user->gettext('Bewertung') %]
                                    [% if $request[0].phase != 3 %] [% $user->gettext('anzeigen') %][% /if %][% if $request[0].phase > 3 %] <span class="fa fa-check-circle" style="color:green;"></span>[% /if %]                                     
                                    [% if $request[0].phase == 3 %] <span class="fa fa-plus-sign"></span>[% /if %]
                                </span>                            
                            </div>
                        </a>
                        <div class="col-lg-6 text-end">
                            <div class="btn-group">
                                [% if $request[0].phase == 3 %]
                                    <input type="submit" value="[% $user->gettext('Speichern') %]" class="btn btn-outline-primary"/>
                                [% /if %]
                            </div>
                        </div>
                    </div>
                </div>
                <div id="rating" class="panel-collapse collapse [% if $request[0].phase == 3 %]in[% /if %]">
                    <div class="card-body">
                        [% if $Tools->FCS_Count($error[2]) %]
                            <div class="alert alert-danger">
                                [% if $error[2].create %]
                                    [% $user->gettext('Die Auswertung konnte aus unbekannten Gründen nicht gespeichert werden. Bitte versuchen Sie es erneut') %]
                                [% else %]
                                    [% $user->gettext('Bitte füllen Sie alle markierten Felder korrekt aus.') %]
                                [% /if %]
                            </div>
                        [% /if %]

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Genehmigung') %]:
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 3 %]
                                    <input type="radio" value="1" name="Accepted"[% if $request[2].accepted == 1 %] checked="checked"[% /if %] /> [% $user->gettext('ja') %]
                                    <input type="radio" value="0" name="Accepted"[% if $request[2].accepted != 1 %] checked="checked"[% /if %] /> [% $user->gettext('nein') %]
                                [% else %]
                                    <input type="text" class="form-control" value="[% if $request[2].accepted == 1 %][% $user->gettext('Ja') %][% else %][% $user->gettext('Nein') %][% /if %]" readonly="readonly"/>
                                [% /if %]
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Kommentar') %]:
                                [% if $request[0].phase == 3 %]*[% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 3 %]
                                    <textarea class="form-control" rows="5" name="Comment" [% if $request[0].phase == 3 %]required[% /if %] style="width:100%;height:5em;">[% $request[2].comment %]</textarea>
                                [% else %]
                                    <textarea class="form-control" rows="5" readonly="readonly">[% $request[2].comment %]</textarea>
                                [% /if %]
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Release') %]:
                                [% if $request[0].phase == 3 %]*[% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 3 %]
                                    <textarea class="form-control" rows="5"  [% if $request[0].phase == 3 %]required[% /if %] name="Release">[% $request[2].release %]</textarea>
                                [% else %]
                                    <textarea class="form-control" rows="5"  readonly="readonly">[% $request[2].release %]</textarea>
                                [% /if %]
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Wiederherstellungsplan nötig') %]:
                                [% if $request[0].phase == 3 %]*[% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 3 %]
                                    <input type="radio" value="1" name="Recovery"[% if $request[2].recovery == 1 %] checked="checked"[% /if %] /> [% $user->gettext('ja') %]
                                    <input type="radio" value="0" name="Recovery"[% if $request[2].recovery != 1 %] checked="checked"[% /if %] /> [% $user->gettext('nein') %]
                                [% else %]
                                    <input type="text" class="form-control" value="[% if $request[2].recovery == 1 %][% $user->gettext('Ja') %][% else %][% $user->gettext('Nein') %][% /if %]" readonly="readonly"/>
                                [% /if %]
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Betroffene Systeme') %]:
                                [% if $request[0].phase == 3 %]*[% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 3 %]
                                    <textarea class="form-control" rows="5"  [% if $request[0].phase == 3 %]required[% /if %] name="SystemsConcerned">[% $request[2].systemsconcerned %]</textarea>
                                [% else %]
                                    <textarea class="form-control" rows="5"  readonly="readonly">[% $request[2].systemsconcerned %]</textarea>
                                [% /if %]
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Benötigte Systemausfallzeit') %]:
                                [% if $request[0].phase == 3 %]*[% /if %]
                            </label>
                            <div class="col-lg-2">
                                <div class="input-group">
                                    [% if $request[0].phase == 3 %]
                                        <input type="text" class="form-control" maxlength="10" [% if $request[0].phase == 3 %]required[% /if %] value="[% $request[2].systemperiod %]" name="SystemPeriod"/>
                                    [% else %]
                                        <input type="text" class="form-control readonly" maxlength="10" value="[% $request[2].systemperiod %]" readonly="readonly" />
                                    [% /if %]
                                    <span class="input-group-text">[% $user->gettext('(HHH:MM)') %]</span>
                                </div>
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Geschätzte Umsetzungsdauer') %]:
                                [% if $request[0].phase == 3 %]*[% /if %]
                            </label>
                            <div class="col-lg-2">
                                <div class="input-group">
                                    [% if $request[0].phase == 3 %]
                                        <input type="text" class="form-control"  [% if $request[0].phase == 3 %]required[% /if %] value="[% $request[2].realizationperiod %]" name="RealizationPeriod"/>
                                    [% else %]
                                        <input type="text" class="form-control"  value="[% $request[2].realizationperiod %]" name="RealizationPeriod" readonly="readonly" />
                                    [% /if %]
                                    <span class="input-group-text">[% $user->gettext('(HHH:MM)') %]</span>
                                </div>
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Ausfallzeit an Betroffene kommunizieren') %]:
                                [% if $request[0].phase == 3 %]*[% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 3 %]
                                    <input type="radio" value="1" name="BriefDowntime"[% if $request[2].briefdowntime == 1 %] checked="checked"[% /if %] /> [% $user->gettext('ja') %]
                                    <input type="radio" value="0" name="BriefDowntime"[% if $request[2].briefdowntime != 1 %] checked="checked"[% /if %] /> [% $user->gettext('nein') %]
                                [% else %]
                                    <input type="text" class="form-control" value="[% if $request[2].briefdowntime == 1 %][% $user->gettext('Ja') %][% else %][% $user->gettext('Nein') %][% /if %]" readonly="readonly"/>
                                [% /if %]
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </form>

    [% /if %]
    [% if $user->hasRight(301) && $Tools->FCS_Count($request[3]) %]
        <form action="index.php?module=changerequest&event=update" method="post" name="Implementation">
            <input type="hidden" name="phase" value="4" />
            <input type="hidden" name="id" value="[% $request[0].changerequestid %]" />
            <div class="card panel-info shadow-sm rounded">

                <div class="card-header">

                    <div class="row">
                        <a data-toggle="collapse" href="#implementation">
                            <div class="col-lg-6">                            
                                <span class="fcs-card-title h3">
                                    [% $user->gettext('Implementation') %]
                                    [% if $request[0].phase != 4 %] [% $user->gettext('anzeigen') %][% /if %][% if $request[0].phase > 4 %] <span class="fa fa-check-circle" style="color:green;"></span>[% /if %]                                                                         
                                    [% if $request[0].phase == 4 %] <span class="fa fa-plus-sign"></span>[% /if %]
                                </span>
                            </div>
                        </a>
                        <div class="col-lg-6 text-end">
                            <div class="btn-group">
                                [% if $request[0].phase == 4 %]
                                    <input type="submit" value="[% $user->gettext('Speichern') %]" class="btn btn-outline-primary"/>
                                [% /if %]
                            </div>
                        </div>
                    </div>
                </div>
                <div id="implementation" class="panel-collapse collapse [% if $request[0].phase == 4 %]in[% /if %]">
                    <div class="card-body">
                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Projektmanagementphase abgeschlossen') %]:
                                [% if $request[0].phase == 4%]*
                                [% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 4 %]
                                    <input type="radio" value="1" name="Accepted"[% if $implementation.accepted == 1%] checked="checked"[% /if %] /> [% $user->gettext('ja') %]
                                    <input type="radio" value="0" name="Accepted"[% if $implementation.accepted != 1%] checked="checked"[% /if %] /> [% $user->gettext('nein') %]
                                [% else %]
                                    <input type="text" class="form-control" value="[% if $request[3].accepted == 1 %][% $user->gettext('Ja') %][% else %][% $user->gettext('Nein') %][% /if %]" readonly="readonly" />
                                [% /if %]
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    [% /if %]

    [% if $user->hasRight(301) && $Tools->FCS_Count($request[4]) %]
        <form action="index.php?module=changerequest&event=update" method="post" name="Review" class="form-horizontal form-label-left">
            <input type="hidden" name="phase" value="5" />
            <input type="hidden" name="id" value="[% $request[0].changerequestid %]" />
            <div class="card panel-info shadow-sm rounded">

                <div class="card-header">

                    <div class="row">
                        <a data-toggle="collapse" href="#review">
                            <div class="col-lg-6">                            
                                <span class="fcs-card-title h3">
                                    [% $user->gettext('Review') %]
                                    [% if $request[0].phase != 5 %] [% $user->gettext('anzeigen') %][% /if %][% if $request[0].phase > 5 %] <span class="fa fa-check-circle" style="color:green;"></span>[% /if %]                                                                         
                                    [% if $request[0].phase == 5 %]  <span class="fa fa-plus-sign"></span>[% /if %]                                    
                                </span>                            
                            </div>
                        </a>
                        <div class="col-lg-6 text-end">
                            <div class="btn-group">
                                [% if $request[0].phase == 5 %]
                                    <input type="submit" value="[% $user->gettext('Speichern') %]" class="btn btn-outline-primary"/>
                                [% /if %]
                            </div>
                        </div>
                    </div>
                </div>
                <div id="review" class="panel-collapse collapse [% if $request[0].phase == 5 || $request[0].phase == 99 %]in[% /if %] ">
                    <div class="card-body">
                        <div class="form-group row mb-3 [% if $error[4].builder %]has-error[% /if %]">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Change Builder') %]:
                                [% if $request[0].phase == 5 %]*[% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 5 %]

                                    <select id="builder_contact" class="form-control select2" name="builderid" >
                                        [% html_options options=$Contacts selected=$request[4].builderid %]
                                    </select>

                                [% else %]
                                    <input type="text"  class="form-control" readonly="readonly" value="[% $request[4].builder %]" />
                                [% /if %]
                            </div>
                        </div>

                        <div class="form-group row mb-3 [% if $error[4].realizationdate %]has-error[% /if %]">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Umsetzungstermin') %]:
                                [% if $request[0].phase == 5%]*
                                [% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 5 %]
                                    <input type="text" class="form-control datetimepicker"  name="RealizationDate" value="[% $request[4].realizationdate|strtotime|date_format:"%d.%m.%Y %H:%M" %]" required="required"/>
                                [% else %]
                                    <input type="text" class="form-control" readonly="readonly" value="[% $request[4].realizationdate|strtotime|date_format:"%d.%m.%Y %H:%M" %]" />
                                [% /if %]
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Umsetzungsdauer') %]:
                                [% if $request[0].phase == 5%]*
                                [% /if %]
                            </label>
                            <div class="col-lg-9">
                                <div class="input-group">
                                    [% if $request[0].phase == 5 %]
                                        <input type="text" class="form-control"  value="[% $request[4].realizationperiod %]" name="RealizationPeriod" />
                                    [% else %]
                                        <input type="text" class="form-control" value="[% $request[4].realizationperiod %]" readonly="readonly" />
                                    [% /if %]
                                    <span class="input-group-text">
                                        [% $user->gettext('(HHH:MM)') %]
                                    </span>
                                </div>
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Detailierte Beschreibung') %]:
                                [% if $request[0].phase == 5%]*
                                [% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 5 %]
                                    <textarea class="form-control" name="Summary" required="required">[% $request[4].summary %]</textarea>
                                [% else %]
                                    <textarea class="form-control" readonly="readonly">[% $request[4].summary %]</textarea>
                                [% /if %]
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Change erfolgreich') %]:
                                [% if $request[0].phase == 5%]*
                                [% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 5 %]
                                    <input type="radio" value="1" name="Successful" onclick="if (this.checked)document.getElementById('ReviewSuccessful').style.display = 'none';"[% if $request[4].successful == 1 %] checked="checked"[% /if %] /> [% $user->gettext('ja') %]
                                    <input type="radio" value="0" name="Successful" onclick="if (this.checked)document.getElementById('ReviewSuccessful').style.display = 'block';"[% if $request[4].successful != 1 %] checked="checked"[% /if %] /> [% $user->gettext('nein') %]
                                    <div id="ReviewSuccessful" [% if $request[4].successful == 1 %]style="display:none;"[% /if %]>
                                        <textarea class="form-control" rows="10"  name="FailedReason" placeholder="[% $user->gettext('Begründung')%]">[% $request[4].failedreason %]</textarea>
                                    </div>
                                [% else %]
                                    <input type="text" class="form-control" value="[% if $request[4].successful == 1 %][% $user->gettext('Ja') %][% else %][% $user->gettext('Nein') %][% /if %]" readonly="readonly" />
                                    [% if $request[4].successful != 1 %]
                                        <div id="ReviewSuccessful" >
                                            <textarea class="form-control" rows="10"  readonly="readonly" placeholder="[% $user->gettext('Begründung')%]">[% $request[4].failedreason %]</textarea>
                                        </div>
                                    [% /if %]
                                [% /if %]
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Wiederherstellungsplan erfolgreich') %]:
                                [% if $request[0].phase == 5%]*
                                [% /if %]
                            </label>
                            <div class="col-lg-9">
                                [% if $request[0].phase == 5 %]
                                    <input type="radio" value="1" name="Recovery" onclick="if (this.checked) document.getElementById('ReviewRecovery').style.display = 'none';"[% if $request[4].recovery == 1 %] checked="checked"[% /if %] /> [% $user->gettext('ja') %]
                                    <input type="radio" value="0" name="Recovery" onclick="if (this.checked) document.getElementById('ReviewRecovery').style.display = 'block';"[% if $request[4].recovery != 1 %] checked="checked"[% /if %] /> [% $user->gettext('nein') %]
                                    <div id="ReviewRecovery"  [% if $request[4].recovery == 1 %]style="display:none;"[% /if %]>
                                        <textarea class="form-control" rows="10"  name="RecoveryReason" placeholder="[% $user->gettext('Begründung') %]">[% $request[4].recoveryreason %]</textarea>
                                    </div>
                                [% else %]
                                    <input type="text" class="form-control" value="[% if $request[4].recovery == 1 %][% $user->gettext('Ja') %][% else %][% $user->gettext('Nein') %][% /if %]" readonly="readonly" />
                                    [% if $request[4].recovery != 1 %]
                                        <div id="ReviewRecovery">
                                            <textarea class="form-control" rows="10"  readonly="readonly" placeholder="[% $user->gettext('Begründung') %]">[% $request[4].recoveryreason %]</textarea>
                                        </div>
                                    [% /if %]
                                [% /if %]
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="control-label col-lg-3">
                                [% $user->gettext('Tester') %]:
                                [% if $request[0].phase == 5%]*[% /if %]
                            </label>
                            <div class="col-lg-9">
                                <select id="selectTester" name="TesterIDs[]" class="form-control select2"  multiple="multiple">
                                    [% html_options options=$Contacts selected=$request[4].selected_cabusers %]
                                </select>
                            </div>
                        </div>


                    </div>
                </div>
            </div>
        </form>
    [% /if %]
    [% if ( $user->hasRight(10) || $user->hasRight(301) ) && $request[0].phase > 1 %] %]
        [% if $doccount > 0 || ($user->hasRight(301) ) %]
            <div class="card panel-info shadow-sm rounded">

                <div class="card-header">

                    <div class="row">
                        <a data-toggle="collapse" href="#document">
                            <div class="col-lg-6">                            
                                <span class="fcs-card-title h3">
                                    [% $user->gettext('Dokumente') %]
                                </span>                            
                            </div>
                        </a>
                        <div class="col-lg-6 text-end">
                            [% if $request[0].phase <= 5 %]
                                <div class="btn-group">
                                    <a href="javascript:callDocForm('[% $request[0].changerequestid %]')" data-fancybox-type="iframe" class="btn btn-outline-primary">[% $user->gettext('Neues Dokument') %]</a>
                                </div>
                            [% /if %]
                        </div>
                    </div>
                </div>
                <div id="document" class="panel-collapse collapse in">
                    <div class="card-body" id="AttachmentList">
                        <img src="images/ajax-loader.gif" alt="[% $user->gettext('...lade Dokumente') %]" title="[% $user->gettext('...lade Dokumente') %]" >
                    </div>
                </div>
            </div>
            <script>

                function getAttachments() {
                $("#AttachmentList").load("index.php?module=changerequest&class=attachments&event=getDocs&id=[% $request[0].changerequestid %]");
                //makeHttpRequest("index.php?module=changerequest&class=attachments&id=[% $request[0].changerequestid %]&view=xml", "buildAttachmentCount", true);
                }

                function buildAttachmentList(xmldoc) {
                var result = xmldoc.getElementsByTagName("result");
                if (result.length == 1) {
                objAttachmentList = document.getElementById("AttachmentList");
                if (objAttachmentList) objAttachmentList.innerHTML = result[0].firstChild.nodeValue;
                }
                }

                function buildAttachmentCount(xmldoc) {
                var result = xmldoc.getElementsByTagName("result");
                if (result.length == 1) {
                objAttachmentCount = document.getElementById("AttachmentCount");
                if (objAttachmentCount) objAttachmentCount.innerHTML = "(" + result[0].firstChild.nodeValue + ")";
                }
                }

                function removeAttachment(id) {
                makeHttpRequest("index.php?module=changerequest&class=attachments&event=remove&id=[% $request[0].changerequestid %]&aid=" + id, "buildAttachmentList", false);
                getAttachments();
                }

                getAttachments();
            </script>
        [% /if %]

    [% /if %]
    [% if FALSE && ($user->hasRight(301) && ($request[0].phase == 2 || $request[0].phase == 5) ) %]


        <script type="text/javascript" language="javascript">


            [% if $request[0].phase == 2 %]
            var cabusers = [[% foreach from=$request[1].cabusers item=cabuser %][[% $cabuser.contact_id %], "[% $cabuser.name|htmlspecialchars %] [% if $cabuser.company != "" %]([% $cabuser.company|htmlspecialchars %])[% /if %]"],[% /foreach %]];
            [% else %]
                var cabusers = [[% foreach from=$request[4].cabusers item=cabuser %][[% $cabuser.contact_id %], "[% $cabuser.name|htmlspecialchars %] [% if $cabuser.company != "" %]([% $cabuser.company|htmlspecialchars %])[% /if %]"],[% /foreach %]];
            [% /if %]

                    function getContact(contactid, contact) {
                    var exists = false;
                    for (i = 0; i < cabusers.length; i++) {
                    if (contactid == cabusers[i][0]) {
                    exists = true;
                    break;
                    }
                    }
                    if (!exists) {
                    var user = [contactid, contact];
                    cabusers[cabusers.length] = user;
                    buildCABList();
                    }
                    }

                    function buildCABList() {
                    var HTMLOutput = "";
                    var CABList = document.getElementById("CABList");
                    var CABUsers = document.getElementById("CABUsers");
                    var users = [];
                    for (i = 0; i < cabusers.length; i++) {
                    HTMLOutput += "<div class=\"employee_active\" onmouseover=\"this.className=\'employee_hover\'\" onmouseout=\"this.className=\'employee_active\'\">";
                    HTMLOutput += "  <div style=\"white-space:normal;\">" + cabusers[i][1] + "&nbsp;";
                    HTMLOutput += "    <a href=\"JavaScript:void(0);\" onclick=\"removeCABUser(" + cabusers[i][0] + ");\" title=\"[% $user->gettext('Kontakt entfernen') %]\"><img src=\"images/user_delete.gif\" align=\"absmiddle\" border=\"0\" alt=\"\" height=\"16\" width=\"16\" title=\"[% $user->gettext('Mitarbeiter entfernen') %]\"></a>";
                    HTMLOutput += "  </div>&nbsp;&nbsp;";
                    HTMLOutput += "</div>";
                    users[users.length] = cabusers[i][0];
                    }
                    CABUsers.value = users.join(",");
                    CABList.innerHTML = HTMLOutput;
                    }

                    function removeCABUser(id) {
                    var change = false;
                    var tmp = [];
                    for (i = 0; i < cabusers.length; i++) {
                    if (cabusers[i][0] == id) {
                    change = true;
                    } else {
                    tmp[tmp.length] = cabusers[i];
                    }
                    }
                    if (change) {
                    cabusers = tmp;
                    buildCABList();
                    }
                    }

            [% if $Tools->FCS_Count($request[1]) %]buildCABList();[% /if %]

        </script>
    [% /if %]
</div>
</div>
</div>




<div id="dialog-category" style="display:none;" width="500" hight="500">

</div>

<div class="modal fade" id="cRModal" tabindex="-1" role="dialog" aria-labelledby="cRModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body modalContent">
                loading...
            </div>
        </div>
    </div>
</div>

<script>

    $('.select2').select2(
    {
    language: "[% $user->language_type %]",
    }
    );
    $('#contact').select2({theme: 'bootstrap-5',
    language: "[% $user->language_type %]"
    [% if $request[0].phase != 2 %], disabled: true[% /if %]
    });
    $('#selectTester').select2({theme: 'bootstrap-5',
    language: "[% $user->language_type %]"
    [% if $request[0].phase != 5 %], disabled: true[% /if %]
    });
    $('#selectProject').select2({theme: 'bootstrap-5',
    language: "[% $user->language_type %]"
    [% if $request[0].phase > 1 %], disabled: true[% /if %]
    });
    $(".dialog").fancybox({
    maxWidth: 800,
            maxHeight: 600,
            closeClick: false
    });
    $(".datepicker").datepicker();
    $(".datetimepicker").datetimepicker({
    currentText :   'Jetzt',
            closeText   :   'OK',
            timeText    :   'Zeit',
            hourText    :   'Stunde'
    });
    $(".multiple").multiselect({
        buttonClass: 'form-select',
    templates: {
        button: '<button type="button" class="multiselect dropdown-toggle" data-bs-toggle="dropdown"><span class="multiselect-selected-text"></span></button>',
    },
    checkAllText: '[% $user->gettext("Alle") %]',
            uncheckAllText: '[% $user->gettext("Keine") %]',
            noneSelectedText: '[% $user->gettext("Wählen Sie") %]',
            selectedText: '# [% $user->gettext("gewählt") %]',
            selectedList: 1,
            header: true,
            multiple:false
    });
    function openCategory(nr) {
    var url = "index.php?module=category&class=select&id=" + nr;
    $("#dialog-category").fancybox({
    title: 'Kategorie wählen',
            href: url,
            type: 'ajax',
            minWidth: 300,
            minHeight: 200,
            autoResize: true
    }).trigger("click");
    }
 
    function callDocForm(id){
    //console.log("index.php?module=changerequest&class=attachments&event=create&id="+id);
    $(".modalContent").load("index.php?module=changerequest&class=attachments&event=create&id=" + id + " " + "#docContent");
    $('#cRModal').modal('show');
    }

    $(".ImageDialog").fancybox();
</script>

<!-- Component Change Request end -->

