Add cancel deal button in funnel
This commit is contained in:
parent
c7a10511cc
commit
d69faee418
@ -1913,6 +1913,16 @@ if($request == 'openPrevStep'){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$r['steps'] = $arr_steps;
|
$r['steps'] = $arr_steps;
|
||||||
|
|
||||||
|
// Проверяем, есть ли сделка у заявки
|
||||||
|
$r['has_deal'] = false;
|
||||||
|
if ($reqId > 0) {
|
||||||
|
$sql_deal_check = mysql_query("SELECT id FROM deals WHERE (side_one_requisition_id = {$reqId} OR side_two_requisition_id = {$reqId}) AND status != 2 LIMIT 1");
|
||||||
|
if ($sql_deal_check && mysql_num_rows($sql_deal_check) > 0) {
|
||||||
|
$r['has_deal'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
echo json_encode($r);
|
echo json_encode($r);
|
||||||
} catch (Exception $ex){
|
} catch (Exception $ex){
|
||||||
echo $ex->getMessage();
|
echo $ex->getMessage();
|
||||||
@ -2295,6 +2305,22 @@ if($request == 'saveOpenPrevStep'){
|
|||||||
|
|
||||||
}
|
}
|
||||||
mysql_query($sql_in);
|
mysql_query($sql_in);
|
||||||
|
|
||||||
|
// Отмена сделки при возврате этапа
|
||||||
|
$is_cancel_deal = isset($data->is_cancel_deal) ? (int)$data->is_cancel_deal : 0;
|
||||||
|
if ($is_cancel_deal && $reqId > 0) {
|
||||||
|
// Находим сделку, связанную с заявкой
|
||||||
|
$sql_deal = mysql_query("SELECT id FROM deals WHERE (side_one_requisition_id = {$reqId} OR side_two_requisition_id = {$reqId}) AND status != 2 LIMIT 1");
|
||||||
|
if ($sql_deal && mysql_num_rows($sql_deal) > 0) {
|
||||||
|
$row_deal = mysql_fetch_assoc($sql_deal);
|
||||||
|
$dealId = (int)$row_deal['id'];
|
||||||
|
// Ставим статус 2 (отменена)
|
||||||
|
mysql_query("UPDATE deals SET status = 2 WHERE id = {$dealId}");
|
||||||
|
// Запись в историю
|
||||||
|
mysql_query("INSERT INTO user_client_events (user_id, req_id, type, name, comment, create_date) VALUES ({$userId}, {$reqId}, 'deal', 'Отмена сделки', 'Сделка отменена при возврате на предыдущий этап', NOW())");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($clientId > 0){
|
if($clientId > 0){
|
||||||
if((int)$funnelId == 0){
|
if((int)$funnelId == 0){
|
||||||
$sql_f = "SELECT funnel_id FROM clients WHERE id = {$clientId}";
|
$sql_f = "SELECT funnel_id FROM clients WHERE id = {$clientId}";
|
||||||
|
|||||||
@ -128,6 +128,8 @@ var ac = new Vue({
|
|||||||
dealCloseObjects: [],
|
dealCloseObjects: [],
|
||||||
dealCloseAgentCommission: 0,
|
dealCloseAgentCommission: 0,
|
||||||
dealCloseSumma: 0,
|
dealCloseSumma: 0,
|
||||||
|
isOpenPrevDeal: false,
|
||||||
|
cancelDealOnPrev: false,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
closedStep: function(id, clientId) {
|
closedStep: function(id, clientId) {
|
||||||
@ -1210,8 +1212,8 @@ var ac = new Vue({
|
|||||||
this.errorTextPrevStep = "Не выбран этап для открытия";
|
this.errorTextPrevStep = "Не выбран этап для открытия";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.data.res && typeof response.data.res.has_deal !== 'undefined') {
|
if (response.data && typeof response.data.has_deal !== 'undefined') {
|
||||||
this.isRequisitionHasDeal = response.data.res.has_deal === true;
|
this.isRequisitionHasDeal = response.data.has_deal === true;
|
||||||
} else {
|
} else {
|
||||||
this.isRequisitionHasDeal = false;
|
this.isRequisitionHasDeal = false;
|
||||||
}
|
}
|
||||||
@ -1252,7 +1254,7 @@ var ac = new Vue({
|
|||||||
now_step_id: now_step_id,
|
now_step_id: now_step_id,
|
||||||
is_Other_prev_step: this.is_Other_prev_step,
|
is_Other_prev_step: this.is_Other_prev_step,
|
||||||
stepInfo: stepInfo,
|
stepInfo: stepInfo,
|
||||||
is_cancel_deal: this.isRequisitionHasDeal ? this.is_cancel_deal : 0
|
is_cancel_deal: this.isRequisitionHasDeal ? this.cancelDealOnPrev : 0
|
||||||
}, )
|
}, )
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
|
|||||||
@ -5673,6 +5673,14 @@ $user_id = $_SESSION['id'];
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
<?php if (in_array((int)$_SESSION['id'], $allowed_users_deal)) { ?>
|
||||||
|
<div v-if="isRequisitionHasDeal" class="form-block" style="margin-top: 10px;">
|
||||||
|
<div class="checkbox">
|
||||||
|
<input id="cancel_deal_prev" type="checkbox" v-model="cancelDealOnPrev">
|
||||||
|
<label for="cancel_deal_prev">Отменить созданную сделку</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-submit">
|
<div class="modal-submit">
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user