<!-- Component Employee begin -->
<script type="text/javascript" language="javascript">
<!--
    function checkAll(el) {
        var objArray = document.getElementsByName("employee[]");
        if (objArray && objArray.length > 0) {
            for (i = 0; i < objArray.length; i++) {
                objArray[i].checked = el.checked;
            }
        }
    }

    function checkEmployee(id) {
        var objArray = document.getElementsByName("employee[]");
        if (objArray && objArray.length > 0) {
            for (i = 0; i < objArray.length; i++) {
                if (objArray[i].value == id) {
                    objArray[i].checked = (objArray[i].checked) 
                        ? false : true;
                }
            }
        }
    }

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

    function changeSort(sort) {
        var el  = document.getElementById("sort");
        var els = document.getElementById("order");
        if (el) {
            if (el.value == sort) {
                if (els) {
                    els.value = (els.value == "asc") ? "desc" : "asc";
                }
            } else {
                el.value = sort;
            }
            submitForm();
        }
    }

    function keyEvent(event) {
        if (event.keyCode == 13) submitForm();
    }

    var iMode = null;

    function importCheck(mode) {

        if (mode == 1 || isChecked()) {
            document.getElementById("iMode").value = 2;
            submitForm();
        } else {
            alert("[% $user->gettext('Bitte selektieren Sie min. einen Mitarbeiter.') %]");
        }
    }

    function isChecked() {
        var objArray = document.getElementsByName("employee[]");
        if (objArray && objArray.length > 0) {
            for (i = 0; i < objArray.length; i++) {
                if (objArray[i].checked) {
                    return true;
                }
            }
        }
        return false;
    }
// -->
</script>



<form action="" method="post" name="hm" onsubmit="return false" id="hm" enctype="multipart/form-data" style="margin:0;padding:0;" class="form-inline fcs-form-padding">
    <input type="hidden" name="pos" id="pos" value="[% $pos %]" />
    <input type="hidden" name="sort" id="sort" value="[% $sort %]" />
    <input type="hidden" name="order" id="order" value="[% $order %]" />
    <input type="hidden" name="iMode" id="iMode" value="" />

    
  <!-- ###CONTENT### begin -->
	<div class="card panel-fcs-border shadow-sm">
		<div class="card-header">
			<span class="fcs-card-title h2">[% $user->gettext('Mitarbeiterdaten aus Asset.Desk aktualisieren') %]</span> 
		</div>
		<div class="card-body">
			<div class="card panel-info shadow-sm rounded">
				<div class="card-body">
                                    <div class="row">
                                        <div class="col-lg-10">
                                            <div class="form-group row mb-3">
                                                <label class="control-label" for="filter">[% $user->gettext('Filter')%]:</label>
                                                <input type="text" class="form-control" id="filter" name="filter" value="[% $filter %]" onkeyup="keyEvent(event)" autocomplete="off" />          
                                            </div>

                                            <div class="form-group row mb-3">
                                                <label class="control-label">[%$user->gettext('Zu aktualisierende Felder')%]:</label>
                                                &nbsp;<input type="checkbox" name="fields[Name]" value="1"[% if $fields.Name == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Name') %]
                                                &nbsp;<input type="checkbox" name="fields[Email]" value="1" [% if $fields.Email == 1 %] checked="checked"[% /if %] /> [% $user->gettext('E-Mail') %]
                                                &nbsp;<input type="checkbox" name="fields[Telefon]" value="1" [% if $fields.Telefon == 1 %] checked="checked"[% /if %]  /> [% $user->gettext('Telefon') %]
                                                &nbsp;<input type="checkbox" name="fields[Fax]" value="1" [% if $fields.Fax == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Fax') %]
                                                &nbsp;<input type="checkbox" name="fields[Handy]" value="1" [% if $fields.Handy == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Handy') %]
                                                &nbsp;<input type="checkbox" name="fields[Personalnumber]" [% if $fields.Personalnumber == 1 %] checked="checked"[% /if %] value="1" /> [% $user->gettext('Personalnummer') %]
                                                &nbsp;<input type="checkbox" name="fields[Remark]" value="1" [% if $fields.Remark == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Bemerkung') %]
                                                &nbsp;<input type="checkbox" name="fields[Company]" value="1" [% if $fields.Company == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Firma') %]

                                                &nbsp;<input type="checkbox" name="fields[Building]" value="1" [% if $fields.Building == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Geb&auml;ude') %]
                                                &nbsp;<input type="checkbox" name="fields[Room]" value="1" [% if $fields.Room == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Raum') %]
                                                &nbsp;<input type="checkbox" name="fields[Department]" value="1" [% if $fields.Department == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Abteilung') %]
                                                &nbsp;<input type="checkbox" name="fields[CostCenter]" value="1" [% if $fields.CostCenter == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Kostenstelle') %]
                                                &nbsp;<input type="checkbox" name="fields[Image]" value="1" [% if $fields.Image == 1 %] checked="checked"[% /if %] /> [% $user->gettext('Bild') %]
                                            </div>                                                        
                                        </div>
                                        <div class="col-lg-2 text-end">
                                            <div class="btn-group">
                                                <input type="button" class="btn btn-outline-primary" value="[% $user->gettext('Auswahl aktualisieren') %]" onclick="importCheck(0);">
                                                <input type="button" class="btn btn-outline-primary" value="[% $user->gettext('Alle aktualisieren') %]" onclick="importCheck(1);" />
                                                [% if $updated %]<div style="text-align:center;"><strong>[% $user->gettext('Daten wurden aktualisiert') %]</strong></div>[% /if %]
                                            </div>
                                        </div>
                                    </div>			
				</div>
				<div class="card panel-info shadow-sm rounded">
					<div class="card-header">
						<span class="fcs-card-title h3">[%$user->gettext('Mitarbeiterliste')%]</span><span class="fcs-card-title h4">-[% $entries %] [% $user->gettext('Mitarbeiter gefunden') %]</span>
					</div>
					<div class="card-body">
						<div class="table-responsive">
							<table class="table table-striped">
								<thead>

                <tr class="fields">
                    <td style="text-align:center !important;">
                        <input type="checkbox" id="checkall" onclick="checkAll(this);" />
                    </td>
                    <td onclick="changeSort('Name');">
                        [% $user->gettext('Name') %]
                        [% if $sort == "Name" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>
                    <td onclick="changeSort('Username');">
                        [% $user->gettext('Benutzername') %]
                        [% if $sort == "Username" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>
                    <td onclick="changeSort('Email');">
                        [% $user->gettext('E-Mail') %]
                        [% if $sort == "Email" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>
                    <td onclick="changeSort('Telefon');">
                        [% $user->gettext('Telefon') %]
                        [% if $sort == "Telefon" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>
                    <td onclick="changeSort('Fax');">
                        [% $user->gettext('Fax') %]
                        [% if $sort == "Fax" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>
                    <td onclick="changeSort('Handy');">
                        [% $user->gettext('Handy') %]
                        [% if $sort == "Handy" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>
                    <td onclick="changeSort('Personalnumber');">
                        [% $user->gettext('Personalnummer') %]
                        [% if $sort == "Personalnumber" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>
                    <td onclick="changeSort('Company');">
                        [% $user->gettext('Firma') %]
                        [% if $sort == "Company" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>

                    <td onclick="changeSort('DepartmentName');">
                        [% $user->gettext('Abteilung') %]
                        [% if $sort == "DepartmentName" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>

                    <td onclick="changeSort('CostCenter');">
                        [% $user->gettext('Kostenstelle') %]
                        [% if $sort == "CostCenter" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>
                    
                    <td onclick="changeSort('Building');">
                        [% $user->gettext('Geb&auml;ude') %]
                        [% if $sort == "Building" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>
                    <td onclick="changeSort('Room');">
                        [% $user->gettext('Raum') %]
                        [% if $sort == "Room" %]&nbsp;<span class="fa fa-chevron-[% if $order == "desc" %]down[% else %]up[% /if %]"></span>[% /if %]
                    </td>
                </tr>
            </thead>
            <tbody>
                [% foreach from=$employees item=employee %]
                <tr>
                    <td style="text-align:center !important;"><input type="checkbox" name="employee[]" value="[% $employee.employeeid %]" /></td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.name %], [% $employee.prename %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);" [% if $employee.usernameerr %]title="[% $user->gettext('Benutzer vorhanden') %]"[% /if %] >[% if $employee.usernameerr %][% $employee.username %][% /if %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.email %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.telefon %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.fax %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.handy %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.personalnumber %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.company|truncate:20:"...":true %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.departmentname|truncate:20:"...":true %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.costcenterdescr|truncate:20:"...":true %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.buildingname %]&nbsp;</td>
                    <td onclick="checkEmployee([% $employee.employeeid %]);">[% $employee.roomname %]&nbsp;</td>
                </tr>
                [% foreachelse %]
                    <tr class="even"><td colspan="11" style="text-align:center !important;">[% $user->gettext('Keine Mitarbeiter zum importieren gefunden...') %]</td></tr>
                [% /foreach %]

                </tbody>
                
                <tfoot>
                    <tr>
                        <td colspan="15">
                            
                        </td>
                    </tr>
                </tfoot>
                
							</table>
							[% $Paging %]
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>
<!-- Component Employee end -->