AddessLink WIP
This commit is contained in:
@@ -256,6 +256,71 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4>Verknüpfte Adressen</h4>
|
||||
<div class="card">
|
||||
<div class="card-body" id="link-container">
|
||||
|
||||
<table class="table table-striped table-sm">
|
||||
<tr>
|
||||
<th>Typ</th>
|
||||
<th>Firma</th>
|
||||
<th>Vorname</th>
|
||||
<th>Nachname</th>
|
||||
<th>Telefon</th>
|
||||
<th>Mobil</th>
|
||||
<th>Email</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach(['techcontact'] as $type): ?>
|
||||
<?php if(array_key_exists($type, $address->links)): ?>
|
||||
<?php foreach($address->links[$type] as $addr): ?>
|
||||
<tr>
|
||||
<td class="font-weight-bold"><?=__($type)?></td>
|
||||
<td><?=$addr->address->company?></td>
|
||||
<td><?=$addr->address->firstname?></td>
|
||||
<td><?=$addr->address->lastname?></td>
|
||||
<td><?=$addr->address->phone?></td>
|
||||
<td><?=$addr->address->mobile?></td>
|
||||
<td><?=$addr->address->email?></td>
|
||||
<td>
|
||||
<a class="mr-2" href="<?=self::getUrl("Address", "edit", ["id" => $address->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Address", "deleteLink", ["id" => $address->id])?>" onclick="if(!confirm('Verknüpgung wirklich löschen?')) return false;" class="text-danger" title="Verknüpfung löschen"><i class="fas fa-xmark-large"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php $linknum = 1; ?>
|
||||
|
||||
<h5>Neue Verknüpfung</h5>
|
||||
<div class="form-group row" id="link-<?=$linknum?>">
|
||||
<div class="col-lg-2"></div>
|
||||
<div class="col-lg-6">
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<select class="form-control" name="links[<?=$linknum?>][type]">
|
||||
<option value="techcontact">Technischer Kontakt</option>
|
||||
</select>
|
||||
</div>
|
||||
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[<?=$linknum?>][address_id]" id="links_<?=$linknum?>_address_id" data-linknum="<?=$linknum?>" data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1&role=techcontact" placeholder="Name, Kundennummer, ID" data-noresults-text="Keine Suchergebnisse">
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-danger" onclick="clearNewLink(<?=$linknum?>)"><i class="fas fa-xmark-large mr-1"></i> Entfernen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
@@ -344,6 +409,106 @@
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* link autocomplete
|
||||
*/
|
||||
|
||||
$('.link-autocomplete').autoComplete();
|
||||
$('.link-autocomplete').keydown(function() {
|
||||
if(event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Links autocomplete
|
||||
*/
|
||||
$('.link-autocomplete').on("autocomplete.select", function(evt, item) {
|
||||
autocompleteSelect(evt,item);
|
||||
});
|
||||
|
||||
function autocompleteSelect(evt, item) {
|
||||
if(item && item.value === 0) {
|
||||
$('.link-autocomplete').autoComplete('set', null);
|
||||
return;
|
||||
}
|
||||
|
||||
var match = evt.currentTarget.id.match(/links_(\d+)_address_id/);
|
||||
var link_num = match[1];
|
||||
if(!link_num) {
|
||||
console.log("Couldn't find selected Address");
|
||||
}
|
||||
addLink(Number(link_num) + 1);
|
||||
}
|
||||
|
||||
function addLink(linknum) {
|
||||
if(!linknum) {
|
||||
console.log("no linknum");
|
||||
return false;
|
||||
}
|
||||
|
||||
if($("#links_" + linknum + "_address_id").length) {
|
||||
console.log("gibs scho");
|
||||
return false;
|
||||
}
|
||||
|
||||
var new_link = '<div class="form-group row" id="link-' + linknum + '"> \
|
||||
<label class="col-lg-2 col-form-label" for="links_' + linknum + '_address_id"></label> \
|
||||
<div class="col-lg-6"> \
|
||||
<div class="input-group mb-3"> \
|
||||
<div class="input-group-prepend"> \
|
||||
<select class="form-control" name="links[' + linknum + '][type]"> \
|
||||
<option value="techcontact">Technischer Kontakt</option> \
|
||||
</select> \
|
||||
</div> \
|
||||
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[' + linknum + '][address_id]" id="links_' + linknum + '_address_id" data-linknum="' + linknum + '" data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1" placeholder="Name, Kundennummer, ID" data-noresults-text="Keine Suchergebnisse"> \
|
||||
<option></option> \
|
||||
</select> \
|
||||
<div class="input-group-append"> \
|
||||
<button type="button" class="btn btn-danger" onclick="clearNewLink(' + linknum + ')"><i class="fas fa-xmark-large mr-1"></i> Entfernen</button> \
|
||||
</div> \
|
||||
</div> \
|
||||
</div> \
|
||||
</div>';
|
||||
|
||||
$('#link-container').append(new_link);
|
||||
//$('#links_' + linknum + '_address_id').autocomplete();
|
||||
$('#links_' + linknum + '_address_id').autoComplete();
|
||||
$('#links_' + linknum + '_address_id').keydown(function() {
|
||||
if(event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#links_' + linknum + '_address_id').on("autocomplete.select", function(evt, item) {
|
||||
autocompleteSelect(evt,item);
|
||||
});
|
||||
}
|
||||
|
||||
function clearNewLink(linknum) {
|
||||
if(!$("#link-" + linknum).length) {
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// only remove is not the only one
|
||||
if($('#link-container').find('div.row').length > 1) {
|
||||
$("#link-" + linknum).remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -58,6 +58,7 @@
|
||||
<option value="customer" <?=(in_array("customer", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("customer")?></option>
|
||||
<option value="supplier" <?=(in_array("supplier", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("supplier")?></option>
|
||||
<option value="contact" <?=(in_array("contact", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("contact")?></option>
|
||||
<option value="techcontact" <?=(in_array("techcontact", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("techcontact")?></option>
|
||||
</select>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user