<div class="card panel-fcs-border shadow-sm">
    <div class="card-header">
        <h2 class="card-title-fcs">[% $user->gettext('Projektliste') %]</h3>
    </div>
    <div class="card-body">
        <div class="card panel-info shadow-sm rounded">
            <div class="card-body">
                <div class="btn-group">
                    [% if $user->hasRight(501) %]
                        <a href="index.php?module=project&event=newProject" class="btn btn-outline-primary">[% $user->gettext('Neues Projekt') %]</a>
                    [% /if %]
                    [% if $user->hasRight(503) %]
                        <a href="index.php?module=project&class=projecttype&event=newtype&pos=[% $pos %]" class="btn btn-outline-primary">[% $user->gettext('Neuer Projekttyp') %]</a>
                        <a href="index.php?module=project&class=projecttype" class="btn btn-outline-secondary">[% $user->gettext('Projekttypen') %]</a>
                    [% /if %]
                    <a href="#inline" class="btn btn-outline-primary dialog">[% $user->gettext('Suchformular') %][% if $ListeGefiltert %] <span class="fa fa-info" title="[% $user->gettext('Projektliste gefiltert') %]"></span>[% /if %]</a>
                </div>
            </div>

            <div class="card panel-info shadow-sm rounded">
                <div class="card-header">
                    <h3 class="card-title">[% $entries %] [% $user->gettext('Projekte gefunden') %]</h3>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-striped table-hover">
                            <thead>
                                <tr class="fields">
                                    <th [% if $ref_level1_name|trim != "" %]colspan="8"[% else %]colspan="7"[% /if %]>[% $user->gettext('Projekt') %]</th>
                                    <th colspan="4">[% $user->gettext('Budget') %]</th>
                                    <th colspan="2">[% $user->gettext('Projekttyp') %]</th>
                                    <th colspan="2">[% $user->gettext('Ansprechpartner') %]</th>
                                    <th colspan="2">[% $user->gettext('Erstellt') %]</th>
                                    <th colspan="2">[% $user->gettext('Aktualisiert') %]</th>
                                </tr>

                                <tr style="cursor:pointer;">
                                    <th [% if $sort == "ProjectID" %]
                                        onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                submitForm();"
                                        [% else %]
                                            onclick="document.getElementById('sort').value = 'ProjectID';
                    submitForm();"
                                            [% /if %]>
                                                [% $user->gettext('#') %]
                                            [% if $sort == "ProjectID" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                        </th>
                                        <th [% if $sort == "ProjectName" %]
                                            onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                        submitForm();"
                                            [% else %]
                                                onclick="document.getElementById('sort').value = 'ProjectName';
                            submitForm();"
                                                [% /if %]>
                                                    [% $user->gettext('Name') %]
                                                [% if $sort == "ProjectName" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                            </th>
                                            [% if $ref_level1_name|trim != "" %]
                                                <th [% if $sort == "RefLevel1" %]
                                                    onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                    submitForm();"
                                                [% else %]
                                                    onclick="document.getElementById('sort').value = 'RefLevel1';
                                    submitForm();"
                                                [% /if %]>
                                                [% $user->gettext($ref_level1_name) %]
                                            [% if $sort == "RefLevel1" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                        </th>
                                        [% /if %]
                                            <th [% if $sort == "TicketCount" %]
                                                onclick="document.getElementById('sortorder').value = '[% $orderneg %]';submitForm();"
                                                [% else %]
                                                    onclick="document.getElementById('sort').value = 'TicketCount';
                                        submitForm();"
                                                    [% /if %]>
                                                        [% $user->gettext('Tickets') %]
                                                    [% if $sort == "TicketCount" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                </th>
                                                <th [% if $sort == "ProjectActive" %]
                                                    onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                            submitForm();"
                                                    [% else %]
                                                        onclick="document.getElementById('sort').value = 'ProjectActive';
                                                submitForm();"
                                                        [% /if %]>
                                                            [% $user->gettext('Aktiv') %]
                                                        [% if $sort == "ProjectActive" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                    </th>
[%*                                                    
                                                    <th [% if $sort == "ProjectRunning" %]
                                                        onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                    submitForm();"
                                                        [% else %]
                                                            onclick="document.getElementById('sort').value = 'ProjectRunning';
                                                        submitForm();"
                                                            [% /if %]>
                                                                [% $user->gettext('Laufend') %]
                                                            [% if $sort == "ProjectRunning" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                        </th>
                                                        
*%]                                                        
                                                    <th [% if $sort == "PStatus" %]
                                                        onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                    submitForm();"
                                                        [% else %]
                                                            onclick="document.getElementById('sort').value = 'PStatus';
                                                        submitForm();"
                                                            [% /if %]>
                                                                [% $user->gettext('Status') %]
                                                            [% if $sort == "PStatus" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                        </th>

                                                        <th [% if $sort == "StartDate" %]
                                                            onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                    submitForm();"
                                                            [% else %]
                                                                onclick="document.getElementById('sort').value = 'StartDate';
                                                                        submitForm();"
                                                                [% /if %]>
                                                                    [% $user->gettext('Start') %]
                                                                [% if $sort == "StartDate" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                            </th>
                                                            <th class="last" [% if $sort == "EndDate" %]
                                                                onclick="document.getElementById('sortorder').value = '[% $orderneg %]';submitForm();"
                                                                [% else %]
                                                                    onclick="document.getElementById('sort').value = 'EndDate';
                                                                            submitForm();"
                                                                    [% /if %]>
                                                                        [% $user->gettext('Ende') %]
                                                                    [% if $sort == "EndDate" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                </th>                                                                
                                                                <th [% if $sort == "EstimatedBudget" %]
                                                                    onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                            submitForm();"
                                                                    [% else %]
                                                                        onclick="document.getElementById('sort').value = 'EstimatedBudget';
                                                                                submitForm();"
                                                                        [% /if %]>
                                                                            [% $user->gettext('BUDGET') %]
                                                                        [% if $sort == "EstimatedBudget" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                    </th>
                                                                    <th>
                                                                            [% $user->gettext('SOLL') %]
                                                                    </th>
                                                                    <th [% if $sort == "UsedBudget" %]
                                                                        onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                                submitForm();"
                                                                        [% else %]
                                                                            onclick="document.getElementById('sort').value = 'UsedBudget';
                                                                                    submitForm();"
                                                                            [% /if %]>
                                                                                [% $user->gettext('IST') %]
                                                                            [% if $sort == "UsedBudget" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                        </th>
                                                                        <th class="last">&nbsp;</th>
                                                                        <th [% if $sort == "TypeName" %]
                                                                            onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                                    submitForm();"
                                                                            [% else %]
                                                                                onclick="document.getElementById('sort').value = 'TypeName';
                                                                                        submitForm();"
                                                                                [% /if %]>
                                                                                    [% $user->gettext('Name') %]
                                                                                [% if $sort == "TypeName" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                            </th>
                                                                            <th class="last" [% if $sort == "TypeActive" %]
                                                                                onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                                        submitForm();"
                                                                                [% else %]
                                                                                    onclick="document.getElementById('sort').value = 'TypeActive';
                                                                                            submitForm();"
                                                                                    [% /if %]>
                                                                                        [% $user->gettext('Aktiv') %]
                                                                                    [% if $sort == "TypeActive" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                                </th>
                                                                                <th [% if $sort == "EmployeeName" %]
                                                                                    onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                                            submitForm();"
                                                                                    [% else %]
                                                                                        onclick="document.getElementById('sort').value = 'EmployeeName';
                                                                                                submitForm();"
                                                                                        [% /if %]>
                                                                                            [% $user->gettext('Name') %]
                                                                                        [% if $sort == "EmployeeName" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                                    </th>
                                                                                    <th class="last" [% if $sort == "Company" %]
                                                                                        onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                                                submitForm();"
                                                                                        [% else %]
                                                                                            onclick="document.getElementById('sort').value = 'Company';
                                                                                                    submitForm();"
                                                                                            [% /if %]>
                                                                                                [% $user->gettext('Firma') %]
                                                                                            [% if $sort == "Company" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                                        </th>
                                                                                        <th [% if $sort == "CreateUser" %]
                                                                                            onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                                                    submitForm();"
                                                                                            [% else %]
                                                                                                onclick="document.getElementById('sort').value = 'CreateUser';
                                                                                                        submitForm();"
                                                                                                [% /if %]>
                                                                                                    [% $user->gettext('Benutzer') %]
                                                                                                [% if $sort == "CreateUser" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                                            </th>
                                                                                            <th class="last" [% if $sort == "CreateDate" %]
                                                                                                onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                                                        submitForm();"
                                                                                                [% else %]
                                                                                                    onclick="document.getElementById('sort').value = 'CreateDate';
                                                                                                            submitForm();"
                                                                                                    [% /if %]>
                                                                                                        [% $user->gettext('Datum') %]
                                                                                                    [% if $sort == "CreateDate" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                                                </th>
                                                                                                <th [% if $sort == "UpdateUser" %]
                                                                                                    onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                                                            submitForm();"
                                                                                                    [% else %]
                                                                                                        onclick="document.getElementById('sort').value = 'UpdateUser';
                                                                                                                submitForm();"
                                                                                                        [% /if %]>
                                                                                                            [% $user->gettext('Benutzer') %]
                                                                                                        [% if $sort == "UpdateUser" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                                                    </th>
                                                                                                    <th class="last"  [% if $sort == "UpdateDate" %]
                                                                                                        onclick="document.getElementById('sortorder').value = '[% $orderneg %]';
                                                                                                                submitForm();"
                                                                                                        [% else %]
                                                                                                            onclick="document.getElementById('sort').value = 'UpdateDate';
                                                                                                                    submitForm();"
                                                                                                            [% /if %]>
                                                                                                                [% $user->gettext('Datum') %]
                                                                                                            [% if $sort == "UpdateDate" %]&nbsp;[% if $ordering == "DESC" %]<span class="fa fa-sort-amount-desc"></span>[% else %]<span class="fa fa-sort-amount"></span>[% /if %][% /if %]
                                                                                                        </th>
                                                                                                    </tr>
                                                                                                </thead>
                                                                                                <tbody>

                                                                                                    [% foreach from=$projects item=project %]
                                                                                                        <tr style="cursor:pointer;" onclick="window.location.href = 'index.php?module=project&event=edit&id=[% $project.projectid %]';" >
                                                                                                            <td class="right">[% $project.projectid %]</td>
                                                                                                            <td>[% $project.projectname %]</td>
                                                                                                            [% if $ref_level1_name|trim != "" %]
                                                                                                                <td>[% $project.ref1label %]</td>
                                                                                                            [% /if %]
                                                                                                            <td class="right">[% $project.ticketcount %]</td>
                                                                                                            <td class="center">
                                                                                                                [% if $project.projectactive == 1 %]
                                                                                                                    <span class="fa fa-check" style="color:green"></span>
                                                                                                                [% else %]
                                                                                                                    <span class="fa fa-times" style="color:red"></span>
                                                                                                                [% /if %]
                                                                                                            </td>
                                                                                                            [%*
                                                                                                            <td class="center">
                                                                                                                [% if $project.projectrunning == 1 && $project.projectactive == 1 %]
                                                                                                                    <span class="fa fa-check" style="color:green" title="[% $user->gettext('Projekt aktiv') %]"></span>
                                                                                                                [% else %]
                                                                                                                    <span class="fa fa-times" title="[% $user->gettext('Projekt nicht aktiv') %]" style="color:red"></span>
                                                                                                                [% /if %]
                                                                                                            </td>
                                                                                                            *%]
                                                                                                            <td class="center">
                                                                                                                [% $project.pstatus %]
                                                                                                            </td>                                                                                                            
                                                                                                            <td class="center">[% $project.startdate|date_format:"%d.%m.%Y" %]</td>
                                                                                                            <td class="center">[% $project.enddate|date_format:"%d.%m.%Y" %]</td>
                                                                                                            <td class="right">[% $project.estimatedbudget %] [% if $hmcompany == 'OTTO FISCHER AG' %]CHF[% else %][% $user->getCurrencyDescr() %][% /if %]</td>
                                                                                                            <td class="right">[% $project.runningcosts %] [% if $hmcompany == 'OTTO FISCHER AG' %]CHF[% else %][% $user->getCurrencyDescr() %][% /if %]</td>
                                                                                                            <td class="right">[% $project.usedbudget %] [% if $hmcompany == 'OTTO FISCHER AG' %]CHF[% else %][% $user->getCurrencyDescr() %][% /if %]</td>
                                                                                                            <td class="center">
                                                                                                                [% if $project.estimatedbudget >= $project.usedbudget %]
                                                                                                                    <span class="fa fa-thumbs-up" style="color:green" title="[% $user->gettext('Projekt im Budget') %]"></span>
                                                                                                                [% else %]
                                                                                                                    <span class="fa fa-thumbs-down" style="color:red" title="[% $user->gettext('Projekt nicht im Budget') %]"></span>
                                                                                                                [% /if %]
                                                                                                            </td>
                                                                                                            <td>[% $project.typename %]</td>
                                                                                                            <td class="center">
                                                                                                                [% if $project.typeactive == 0 %]
                                                                                                                    <span class="fa fa-times" style="color:red"></span>
                                                                                                                [% else %]
                                                                                                                    <span class="fa fa-check" style="color:green"></span>
                                                                                                                [% /if %]
                                                                                                            </td>
                                                                                                            <td>
                                                                                                                [% $project.employeename %][% if $project.employeename != "" && $project.employeeprename != "" %], [% /if %]
                                                                                                                [% $project.employeeprename %]
                                                                                                                [% if $project.employeename == "" && $project.employeeprename == "" %]&nbsp;[% /if %]
                                                                                                            </td>
                                                                                                            <td>[% if $project.employeecompany %][% $project.employeecompany %][% else %]&nbsp;[% /if %]</td>
                                                                                                            <td>[% $project.createuser %]</td>
                                                                                                            <td class="center">[% $project.createdate|date_format:"%d.%m.%Y %H:%M" %]</td>
                                                                                                            <td>[% $project.updateuser %]</td>
                                                                                                            <td class="center">[% $project.updatedate|date_format:"%d.%m.%Y %H:%M" %]</td>
                                                                                                        </tr>
                                                                                                    [% foreachelse %]
                                                                                                        <tr class="even"><td colspan="[% if $ref_level1_name|trim != "" %]19[% else %]18[% /if %]" class="center">[% $user->gettext('Keine Projekte gefunden') %]</td></tr>
                                                                                                        [% /foreach %]
                                                                                                </tbody>
                            <tfoot>
                                <tr>
                                    <td colspan="20">
                                        [% $Paging %]
                                    </td>
                                </tr>
                            </tfoot>
                        </table>
                    </div>

                    <div id="inline" style="display:none;">
                        [% include file=$modulePath|cat:"/project_search.tpl" %]
                    </div>

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


<script>


    $(".dialog").fancybox({
        maxWidth: 800,
        maxHeight: 600,
        closeClick: false
    });

    function switchPage(page)
    {
        document.getElementById('pos').value = page;
        submitForm();
    }

</script>
<!-- Component Project end -->
