Fix close funnel req
This commit is contained in:
parent
b8881e2aad
commit
e6d644a663
@ -4836,20 +4836,21 @@ class Requisitions{
|
|||||||
$sql = "SELECT * FROM `requisitions` WHERE id = $id";
|
$sql = "SELECT * FROM `requisitions` WHERE id = $id";
|
||||||
$requisistion = $this->db->fetch_assoc($this->db->query($sql));
|
$requisistion = $this->db->fetch_assoc($this->db->query($sql));
|
||||||
|
|
||||||
|
// ИСПРАВЛЕНО: Определяем $lastStepId в начале, до всех условий
|
||||||
// последний этап воронки
|
$lastStepId = 8; // значение по умолчанию для обычной воронки
|
||||||
$lastStage = 8; // значение по умолчанию
|
|
||||||
$funnelId = intval($requisistion['funnel_id']);
|
$funnelId = intval($requisistion['funnel_id']);
|
||||||
|
|
||||||
if ($funnelId > 0) {
|
if ($funnelId > 0) {
|
||||||
|
// Для кастомной воронки
|
||||||
$q_step = $this->db->query("SELECT MAX(order_number) as last_stage FROM funnel_steps WHERE funnel_id = $funnelId AND deleted = 0");
|
$q_step = $this->db->query("SELECT MAX(order_number) as last_stage FROM funnel_steps WHERE funnel_id = $funnelId AND deleted = 0");
|
||||||
if ($q_step && $this->db->num_rows($q_step) > 0) {
|
if ($q_step && $this->db->num_rows($q_step) > 0) {
|
||||||
$r_step = $this->db->fetch_assoc($q_step);
|
$r_step = $this->db->fetch_assoc($q_step);
|
||||||
if ($r_step['last_stage'] !== null) {
|
if ($r_step['last_stage'] !== null) {
|
||||||
$lastStage = intval($r_step['last_stage']);
|
$lastStepId = intval($r_step['last_stage']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// funnel_id = 0
|
// funnel_id = 0 — дефолтная воронка, берём по agency_id
|
||||||
$agencyId = $this->user->agencyId;
|
$agencyId = $this->user->agencyId;
|
||||||
$q_default = $this->db->query("SELECT id FROM funnel_default WHERE agency_id = $agencyId LIMIT 1");
|
$q_default = $this->db->query("SELECT id FROM funnel_default WHERE agency_id = $agencyId LIMIT 1");
|
||||||
if ($q_default && $this->db->num_rows($q_default) > 0) {
|
if ($q_default && $this->db->num_rows($q_default) > 0) {
|
||||||
@ -4860,7 +4861,7 @@ class Requisitions{
|
|||||||
if ($q_step && $this->db->num_rows($q_step) > 0) {
|
if ($q_step && $this->db->num_rows($q_step) > 0) {
|
||||||
$r_step = $this->db->fetch_assoc($q_step);
|
$r_step = $this->db->fetch_assoc($q_step);
|
||||||
if ($r_step['last_stage'] !== null) {
|
if ($r_step['last_stage'] !== null) {
|
||||||
$lastStage = intval($r_step['last_stage']);
|
$lastStepId = intval($r_step['last_stage']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4876,12 +4877,20 @@ class Requisitions{
|
|||||||
], false, false);
|
], false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE requisitions SET reason='".$select_text.". ".$post['reason']."', who_delete = '$user_id', deleted=1, stage=$lastStage, denial = $post[denial] WHERE id=$id";
|
if ($funnelId > 0) {
|
||||||
|
$sql = "UPDATE requisitions SET reason='".$select_text.". ".$post['reason']."', who_delete = '$user_id', deleted=1, step_id=$lastStepId, denial = $post[denial] WHERE id=$id";
|
||||||
|
} else {
|
||||||
|
$sql = "UPDATE requisitions SET reason='".$select_text.". ".$post['reason']."', who_delete = '$user_id', deleted=1, stage=$lastStepId, denial = $post[denial] WHERE id=$id";
|
||||||
|
}
|
||||||
if(isset($post['summa']) && $post['luck']){
|
if(isset($post['summa']) && $post['luck']){
|
||||||
if($dop_text != '') $dop_text .= " ";
|
if($dop_text != '') $dop_text .= " ";
|
||||||
$commission = isset($post['commission']) ? intval($post['commission']) : 0;
|
$commission = isset($post['commission']) ? intval($post['commission']) : 0;
|
||||||
$dop_text1 = "Совершена сделка на ".$commission." руб. ".$formatted_dateZajavki;
|
$dop_text1 = "Совершена сделка на ".$commission." руб. ".$formatted_dateZajavki;
|
||||||
$sql = "UPDATE requisitions SET reason='".$dop_text1."', who_delete = '$user_id', deleted=1, summa='$post[summa]', confirm='$post[luck]' WHERE id=$id";
|
if ($funnelId > 0) {
|
||||||
|
$sql = "UPDATE requisitions SET reason='".$dop_text1."', who_delete = '$user_id', deleted=1, step_id=$lastStepId, summa='$post[summa]', confirm='$post[luck]' WHERE id=$id";
|
||||||
|
} else {
|
||||||
|
$sql = "UPDATE requisitions SET reason='".$dop_text1."', who_delete = '$user_id', deleted=1, stage=$lastStepId, summa='$post[summa]', confirm='$post[luck]' WHERE id=$id";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->query($sql)) {
|
if ($this->db->query($sql)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user