<?php 
/***
Auth: Vastvikta Nishad
Date: 11 Feb 2024
Description:Update Existing  Escalation 
*/
$msg = '';
$id = base64_decode($_GET['id']);
$escalationData = getEscalationData($link,$id);
$escalation_to = $escalationData['escalation_to'];  
$escalation_media = $escalationData['escalation_media'];  
$escalation_list = $escalationData['escalation_list']; 
?>
<div id="success"><?php echo $msg; ?></div>
<form id="mastersrcat" method="post" action="">
    <input name="id" id="id" type="hidden" value="<?php echo  $id ?>">
        <span class="breadcrumb_head" style="height:37px;padding:9px 16px">Edit Status </span>
            <div class="style2-table">
                <div class="table">
                    <table class="tableview tableview-2 main-form">
                        <tbody>
                            <?php if($msg!=''){?>
                                <tr>
                                    <td colspan="2" style="color:#ffffff; width:100%; background:#00CC66; padding:5px; border:1px solid #02944b; text-align:center;">
                                    <?php echo$msg?>
                                    </td>
                                </tr>
                                <?php } ?>
                                <tr>
                                    <td class="left">
                                        <label>Escalation To</label>
                                        <div class="form-check form-check-inline">
                                            Customer
                                            <input class="form-check-input" id="escalation_to_customer" type="radio" name="escalation_to" value="1" <?php echo ($escalation_to == '1') ? 'checked' : ''?>>
                                        </div>
                                        <div class="form-check form-check-inline">
                                            Department
                                            <input class="form-check-input"  id="escalation_to_department" type="radio" name="escalation_to" value="2" <?php echo($escalation_to == '2') ? 'checked' : ''?>>
                                        </div>
                                        <div class="form-check form-check-inline">
                                            Both
                                            <input class="form-check-input" id="escalation_to_both"  type="radio" name="escalation_to" value="3" <?php echo($escalation_to == '3') ? 'checked' : ''?>>
                                        </div>
                                    </td>
                                    <td class="left">
                                        <label>Escalation Media</label>
                                            <div class="form-check form-check-inline">
                                                Email
                                                <input class="form-check-input" id="escalation_media_email" type="radio" name="escalation_media" value="1" <?php echo($escalation_media == '1') ? 'checked' : ''?>>
                                            </div>
                                            <div class="form-check form-check-inline">
                                                SMS
                                                <input class="form-check-input"  id="escalation_media_sms_both" type="radio" name="escalation_media" value="2" <?php echo($escalation_media == '2') ? 'checked' : ''?>>
                                            </div>
                                            <div class="form-check form-check-inline">
                                                Both
                                                <input class="form-check-input"  id="escalation_media" type="radio" name="escalation_media" value="3" <?php echo($escalation_media == '3') ? 'checked' : ''?>>
                                            </div>
                                    </td>
                                </tr>
                                    <tr>
                                        <td class="left">
                                            <?php
                                                $sqlagent="select AtxUserID,AtxUserName from $db.uniuserprofile where AtxUserStatus='1'";
                                                $result=mysqli_query($link,$sqlagent);
                                            ?>
                                            <label>User List</label>
                                            <div class="log-case">
                                            <select name="escalation_list[]" id="escalation_list" class="input-style1" multiple="multiple" data-placeholder="Select User">   <option value="">None</option>
                                                        <?php
                                                        while($row=mysqli_fetch_array($result)) {                                                        
                                                        $AtxUserID=$row['AtxUserID']; 
                                                        $AtxUserName=$row['AtxUserName'];                                                        
                                                        $val= explode(",",$escalation_list);
                                                        if(in_array($AtxUserID, $val))
                                                        {
                                                        $sel = ' selected';
                                                        }
                                                        else
                                                        {
                                                        $sel = '';
                                                        }
                                                        ?>
                                                    <option value='<?php echo $AtxUserID?>' <?php echo $sel?>><?php echo $AtxUserName?></option>
                                                        <?php } ?>
                                                </select>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                        <center>
                                            <input name="Update" type="submit" value="Update" class="button-orange1" id="submitclkescalation" style="float:inherit">
                                        </center>
                                        </td>                                        
                                    </tr>                                    
                                </tr>
                        </tbody>
                    </table>
                </div>
            </div>
</form>
