Preorder fix attribute statusflag

This commit is contained in:
Luca Haid
2025-01-21 13:18:50 +00:00
parent eaa885e97d
commit ee7c1469f5
3 changed files with 52 additions and 5 deletions

View File

@@ -502,6 +502,28 @@ $pagination_entity_name = "Vorbestellungen";
"json"
);
// if attribute is inhouse_cabling_supplied and is checked or unchecked send an api request
// api
// do: setStatusFlag, preorder_id, flag_id: 1, value (0 or 1)
if (attrib == "inhouse_cabling_supplied") {
var flag_id = 1;
$.post("<?=self::getUrl("Preorder", "Api")?>", {
do: "setStatusFlag",
preorder_id: preorder_id,
flag_id: flag_id,
value: value
},
function(success) {
if(success.status == "OK") {
attributeSuccess(success.result);
} else {
attributeError(success.result.id, success.result.attribute);
}
},
"json"
);
}
});
});
});

View File

@@ -56,7 +56,7 @@ class WarehouseOrderRequestController extends TTCrud {
'delete' => 'Bestellwunsch wurde gelöscht',
'noChanges' => 'Keine Änderungen',];
protected array $additionalJSVariables = ['BASE_URL' => '/WarehouseOrderRequest'];
protected array $additionalJSVariables = ['BASE_URL' => '/WarehouseOrderRequest', 'WAREHOUSE_ADMIN' => true];
public function permissionCheck(): bool {
return $this->user->can(["WarehouseUser"]);
@@ -89,6 +89,9 @@ class WarehouseOrderRequestController extends TTCrud {
}
$this->additionalJSVariables['user_id'] = $this->user->id;
if (!$this->user->can('WarehouseAdmin')) {
$this->additionalJSVariables['WAREHOUSE_ADMIN'] = false;
}
}
protected function customAutoCompleteWare($value) {

View File

@@ -1,8 +1,24 @@
window.localStorage.setItem('tt-table-WarehouseOrderRequest', JSON.stringify({
filters: {
takeOverBy: null
}
}));
Vue.component('warehouse-order-request', {
//language=Vue
template: `
<tt-card>
<tt-table-crud @openHistory="historyModal = true; historyModalId = $event.id" ref="crud">
<!-- <slot name="table-top-buttons"></slot> add checkbox "Ausgeblendete Bestellungen anzeigen-->
<template v-slot:table-top-buttons>
<div class="d-flex">
<tt-button @click="showHiddenRequests = !showHiddenRequests"
:text="showHiddenRequests ? 'Erledigte Bestellungen ausblenden' : 'Erledigte Bestellungen anzeigen'"
:additional-class="showHiddenRequests ? 'btn-danger' : 'btn-primary'"/>
</div>
</template>
<template v-slot:create="{ row }">
{{ row.create ? window.moment(row.create * 1000).format('DD.MM.YYYY') : '' }}
</template>
@@ -12,7 +28,7 @@ Vue.component('warehouse-order-request', {
</template>
<template v-slot:takeover="{ row }">
{{ row.takeover ? window.moment(row.takeover * 1000).format('DD.MM.YYYY') : '' }}
{{ row.takeOver ? window.moment(row.takeOver * 1000).format('DD.MM.YYYY') : '' }}
</template>
<template v-slot:note="{ row }">
@@ -25,14 +41,14 @@ Vue.component('warehouse-order-request', {
</tt-card>
`, data() {
return {
window: window, historyModal: false, historyModalId: null,
window: window, historyModal: false, historyModalId: null, showHiddenRequests: false
}
},
async mounted() {
// set a watch to ref.crud crudModal and if crudModal and then log ref crudModalData
if (this.window.TT_CONFIG.WAREHOUSE_ADMIN !== '1') return
this.$refs.crud.$watch('crudModal', (value) => {
if (value) {
console.log(this.$refs.crud.crudModalData)
// if id is not 'create' then check if order is set and if not set it to current date
// if order is set then check if takeover is set and if not set it to current date
if (!this.$refs.crud.crudModalData.id) return
@@ -53,5 +69,11 @@ Vue.component('warehouse-order-request', {
}
})
},
watch: {
showHiddenRequests(value) {
// set filter data inside table takeOverBy to !NULL
this.$refs.crud.$refs.table.$set(this.$refs.crud.$refs.table.filters, 'takeOverBy', value ? '' : null)
}
}
})