<!-- Component Change Request begin -->
<script type="text/javascript" src="includes/js/jquery-ui-timepicker-addon.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" />

<!-- ###CONTENT### begin -->
<div class="card panel-fcs-border shadow-sm">
    <div class="card-header">
        <span class="fcs-card-title h2">[% $user->gettext('Antrag') %] (#[% $request[0].changerequestid %]) - [% $user->gettext('Wiedervorlage') %]</span>

    </div>
    <div class="card-body">
        <div class="col-lg-10 offset-md-1">

            [% if $Tools->FCS_Count($error[0]) %]


                [% if $error[0].create %]
                    <span class="col-sm-12 alert alert-danger">[% $user->gettext('Der Request konnte aus unbekannten Gründen nicht gespeichert werden.') %]</span>
                [% else %]
                    <span class="col-sm-12 alert alert-warning">[% $user->gettext('Bitte füllen Sie alle markierten Felder aus.') %]</span>
                [% /if %]                        




            [% /if %]
            <form action="index.php?module=changerequest&event=renew" 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">
                            <div class="col-sm-6">
                                <span class="fcs-card-title h4">[% $user->gettext('Antrag') %]</span>
                            </div>
                            <div class="col-sm-6 text-end">
                                <div class="btn-group">
                                    <input type="button" class="btn btn-outline-primary" value="[% $user->gettext('Liste') %]" onclick="window.location.href = '?module=changerequest';" />
                                    <input type="submit" class="btn btn-outline-secondary" value="[% $user->gettext('Speichern') %]" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <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') %]:
                                    </label>
                                    <div class="col-lg-9">
                                        [% if $request[0].phase < 2 %]
                                            <input type="text" name="Initiator" value="[% $request[0].initiator %]" class="form-control"  readonly="readonly"/>
                                        [% 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') %]
                                    </label>
                                    <div class="col-lg-9">
                                        [% if $request[0].phase < 2 %]
                                            <input type="text" name="Subject" value="[% $request[0].subject %]" class="form-control"  readonly="readonly"/>
                                        [% else %]
                                            <input type="text" value="[% $request[0].subject %]" class="form-control" readonly="readonly" />
                                        [% /if %]
                                    </div>
                                </div>



                                <div class="form-group row mb-3 [% if $error[0].systemsconcerned %]has-error[% /if %]">
                                    <label class="control-label col-lg-3">
                                        [% $user->gettext('Betroffene<br />Systeme/Produkte') %]:
                                    </label>
                                    <div class="col-lg-9">
                                        <textarea class="form-control" rows="10" name="SystemsConcerned">[% $request[0].systemsconcerned %]</textarea>

                                    </div>
                                </div>

                                <div class="form-group row mb-3 [% if $error[0].summary %]has-error[% /if %]" 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">
                                        <textarea class="form-control" rows="10"   name="Summary" required="required">[% $request[0].summary %]</textarea>
                                    </div>
                                </div>

                                [% if $request[0].phase == 77 %]

                                    <div class="form-group row mb-3">
                                        <label class="col-lg-3 control-label">[% $user->gettext('Begr&uuml;ndung<br />der Ablehnung') %]:</label>
                                        <div class="col-lg-9">
                                            <textarea class="form-control" rows="10" readonly="readonly">[% $request[0].denyreason %]</textarea>
                                        </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') %]:                                 
                                    </label>
                                    <div class="col-lg-9">
                                        <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>	                                
                                    </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">

                                        <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>	

                                    </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+1 %]" 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 %]                                    

                                <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>

                            </div>

                        </div>


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

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

</div>

<script>

    function changeRequestTab(tab) {
        var list = document.getElementById("ChangeRequestTabs");
        var items = document.getElementsByTagName("li");
        var tabform = null;

        for (i = 0; i < items.length; i++) {
            var id = items[i].id;
            items[i].className = (id == "Tab" + tab) ? "active" : "";
            if (id == "Tab" + tab) {
                if ((tabform = document.getElementById(id + "Form")))
                    tabform.style.display = "block";
            } else {
                if ((tabform = document.getElementById(id + "Form")))
                    tabform.style.display = "none";
            }
        }
    }


    $(".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");
    }

</script>
<!-- Component Change Request end -->

