diff --git a/ajax/ajax_vue_requisitions.php b/ajax/ajax_vue_requisitions.php index 45cbda5..2221733 100644 --- a/ajax/ajax_vue_requisitions.php +++ b/ajax/ajax_vue_requisitions.php @@ -2297,4 +2297,17 @@ if($request == 'get_view_page'){ } +if($request == 'get_deal_by_req'){ + $req_id = intval($data->req_id); + $sql = "SELECT id FROM deals WHERE side_one_requisition_id = $req_id LIMIT 1"; + $q = $pdo->query($sql); + $deal_id = null; + if($q && $pdo->num_rows($q) > 0){ + $r = $pdo->fetch_assoc($q); + $deal_id = (int)$r['id']; + } + echo json_encode(['deal_id' => $deal_id]); + exit(); +} + ?> diff --git a/js/crm_vue.js b/js/crm_vue.js index 6dff298..f9b57d3 100644 --- a/js/crm_vue.js +++ b/js/crm_vue.js @@ -1377,6 +1377,20 @@ var ac = new Vue({ console.error('createDeal function not found'); } }, + initEditDeal(reqId) { + $.ajax({ + url: '/ajax/ajax_vue_requisitions.php', + type: 'POST', + contentType: 'application/json', + data: JSON.stringify({ request: 'get_deal_by_req', req_id: reqId }), + success: function(response) { + var res = typeof response === 'string' ? JSON.parse(response) : response; + if (res.deal_id) { + window.editDeal(reqId, res.deal_id); + } + } + }); + }, }, mounted() { this.$nextTick(() => { diff --git a/templates/footer.php b/templates/footer.php index f271d34..530bd8a 100644 --- a/templates/footer.php +++ b/templates/footer.php @@ -5330,17 +5330,24 @@ $user_id = $_SESSION['id']; ?>