<?php $__env->startSection('title', 'Edit DID'); ?>
<?php $__env->startSection('content'); ?>


<section class="content">
			<div class="row">
				<div class="col-lg-12 col-12">
					  <div class="box">

						<!-- /.box-header -->
                        <form enctype="multipart/form-data" class="form-horizontal" method="post" action="<?php echo e(url('did/saveEditDid')); ?>">
                        <?php echo csrf_field(); ?>
                                <input type="hidden" name="operator_check" value="0" />
                                <input type="hidden" name="operator" value="0" />
                                <input type="hidden" class="form-control" name="did_id" value="<?php echo e($didData->id); ?>"id="did_id" required="">
							 <div class="box-body">
								<h4 class="box-title text-info mb-0"><i class="fa fa-edit me-15"></i> Edit Phone Number</h4>
                                <a href="<?php echo e(url('/did')); ?>" type="button" style="float:right" class="waves-effect waves-light btn btn-rounded btn-primary btn-bitbucket btn-sm mb-5"><i class="fa fa-eye fa-sx"></i> Show Phone Number</a>

								<hr class="my-15">
							    <div class="row">
								  <div class="col-md-6">
                                    <div class="form-group">
									    <label class="form-label">Phone Number</label>
                                        <div class="input-group mb-3">
                                            <span class="input-group-text"><i class="ti-user"></i></span>
                                            <input type="text" maxlength="12" onkeypress="return isNumberKey($(this));" class="form-control" name="cli" value="<?php echo e($didData->cli); ?>"
                                            id="cli" required="" onkeyup="check(); return false;"  placeholder="Enter Phone Number" <?php echo e($didData->cli != '' ? "readonly='true'" : ""); ?>>									
                                        </div>
                                        </div>
								    </div>
								    <div class="col-md-6">
                                        <div class="form-group">
                                        <label class="form-label">Caller Name </label>
                                            <div class="input-group mb-3">
                                                <span class="input-group-text <?php $__errorArgs = ['caller_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> text-danger border-danger <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"><i class="ti-user"></i></span>

                                                <input type="text" maxlength="13" class="form-control" name="cnam" value="<?php echo e($didData->cnam); ?>" id="cnam" required=""
                                            placeholder="Enter Caller Name">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group <?php $__errorArgs = ['description'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> has-error <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                                        <label class="form-label">Set this number as your mainline ?</label>
                                            <div class="input-group mb-3">
                                                    <span class="input-group-text <?php $__errorArgs = ['caller_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> text-danger border-danger <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"><i class="ti-user"></i></span>
                                                    <select class="form-select"  id="default_did" name="default_did" >
                                                        <option <?php if(1 == $didData->default_did): ?> selected <?php endif; ?> value="1">Yes</option>
                                                        <option <?php if(0 == $didData->default_did): ?> selected <?php endif; ?> value="0">No</option>
                                                    </select>
                                                </div>
                                            </div>
                                    </div>
								  <div class="col-md-6">
									<div class="form-group">
									  <label class="form-label">Redirect to Last Spoke Agent</label>
                                        <div class="input-group mb-3">
                                            <span class="input-group-text <?php $__errorArgs = ['caller_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> text-danger border-danger <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"><i class="ti-user"></i></span>

                                            <select class="form-select"  id="redirect_last_agent" name="redirect_last_agent" >
                                            <option <?php if(1 == $didData->redirect_last_agent): ?> selected <?php endif; ?> value="1">Yes</option>
                                            <option <?php if(0 == $didData->redirect_last_agent): ?> selected <?php endif; ?> value="0">No</option>
                                        </select>
                                        </div>
								  </div>
								  </div>

                                  </div>

                            <div class="row"id="showRow">
								<div class="col-md-6">
                                    <div class="form-group">
                                        <label id="label_id"class="form-label">Destination Type</label>
                                        <div class="input-group mb-3">
                                            <span class="input-group-text"><i class="ti-user"></i></span>
                                            <select class="form-select"  name="dest_type" id="dest_type" onchange="return showData(this.value)">
                                                <?php if(!empty($dest_type)): ?>
                                                <?php $__currentLoopData = $dest_type; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option value=<?php echo e($item->dest_id); ?> <?php if($item->dest_id ==
                                                        $didData->dest_type): ?>
                                                        <?php echo e('selected="selected"'); ?>

                                                        <?php endif; ?>
                                                        > <?php echo e($item->dest_type); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6 hideMe inner_div" id="0_div"<?php if(0==$didData->dest_type): ?>
                                        style='display: block' <?php endif; ?>>
                                    <div class="form-group">
                                        <label id="label_id_duration" class="form-label">Destination </label>
                                        <div class="input-group mb-3">
                                            <span class="input-group-text"><i class="ti-user"></i></span>
                                                <select class="form-select"  name="ivr_id" id="ivr_id">
                                                    <?php if(isset($ivr_list) && !empty($ivr_list)): ?>
                                                    <?php $__currentLoopData = $ivr_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ivr_lst): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option <?php if($didData->ivr_id ==
                                                        $ivr_lst->id): ?>
                                                        <?php echo e('selected="selected"'); ?>

                                                        <?php endif; ?> value=<?php echo e($ivr_lst->id); ?>><?php echo e($ivr_lst->ivr_desc); ?> - <?php echo e($ivr_lst->ivr_id); ?>>
                                                    </option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    <?php endif; ?>
                                                </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6 hideMe inner_div"id="1_div"<?php if(1==$didData->dest_type): ?>
                                        style='display: block' <?php endif; ?> >
                                        <div class="form-group">
                                            <label class="form-label">Destination</label>
                                            <div class="input-group mb-3">
                                                <span class="input-group-text"><i class="ti-user"></i></span>
                                                <select class="form-select"  name="extension" id="extension">
                                                        <?php if(is_array($extension_list) && !empty($extension_list)): ?>
                                                        <?php $__currentLoopData = $extension_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ext_lst): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <option <?php if($didData->extension == $ext_lst->id ): ?> selected <?php endif; ?> value=<?php echo e($ext_lst->id); ?>><?php echo e($ext_lst->first_name); ?> <?php echo e($ext_lst->last_name); ?> - <?php echo e($ext_lst->extension); ?>

                                                        </option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        <?php endif; ?>
                                                    </select>
                                            </div>
                                        </div>
                                </div>
                                <div id="2_div" class="col-md-6 hideMe inner_div" <?php if(2==$didData->dest_type): ?>
                                        style='display: block' <?php endif; ?> >
                                  <div class="form-group">
									<label class="form-label">Destination </label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <select class="form-select"  name="voicemail_id" id="voicemail_id">
                                                <?php if(is_array($extension_list) && !empty($extension_list)): ?>
                                                <?php $__currentLoopData = $extension_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ext_lst): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option <?php if($didData->voicemail_id == $ext_lst->id ): ?> selected <?php endif; ?> value=<?php echo e($ext_lst->id); ?>><?php echo e($ext_lst->first_name); ?> <?php echo e($ext_lst->last_name); ?> - <?php echo e($ext_lst->extension); ?>

                                                </option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </select>
                                	</div>
								</div>
                            </div>
                            <div class="col-md-3 hideMe inner_div 4_div" id="4_div"<?php if(4==$didData->dest_type): ?>
                                        style='display: block' <?php endif; ?> >
                                  <div class="form-group">
									<label class="form-label">Country Phone Code </label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                            <select class="form-select"  name="country_code" id="country_code">
                                                <?php if(is_array($phone_country) && !empty($phone_country)): ?>
                                                <?php $__currentLoopData = $phone_country; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $code): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option <?php if($didData->country_code == $code->phone_code ): ?> selected <?php endif; ?> value=<?php echo e($code->phone_code); ?>><?php echo e($code->country_name); ?> (+<?php echo e($code->phone_code); ?>)
                                                </option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </select>
                                	</div>
								</div>
                                </div>
                                <?php
                                    $newstring = substr($didData->forward_number, -10);
                                    ?>
                                <div class="col-md-3 hideMe inner_div 4_div" id="4_div"  <?php if(4==$didData->dest_type): ?>
                                        style='display: block' <?php endif; ?>>
                                  <div class="form-group">
									<label class="form-label">Phone Number  </label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <input type="text" class="form-control" value="<?php echo e($newstring); ?>"  name="forward_number" id="forward_number" placeholder="(999) 999-9999">

                                	</div>
								</div>
                            </div>
                                <div class="col-md-6 hideMe inner_div" id="5_div"<?php if(5==$didData->
                                        dest_type): ?> style='display: block' <?php endif; ?>>
                                    <div class="form-group">
                                        <label class="form-label">Destination </label>
                                        <div class="input-group mb-3">
                                            <span class="input-group-text"><i class="ti-user"></i></span>
                                            <select class="form-select"  name="conf_id" id="conf_id">
                                                    <?php if(is_array($conferencing) && !empty($conferencing)): ?>
                                                    <?php $__currentLoopData = $conferencing; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $conf): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option <?php if($didData->conf_id == $conf->id ): ?> selected <?php endif; ?> value=<?php echo e($conf->id); ?>><?php echo e($conf->title); ?> - <?php echo e($conf->conference_id); ?></option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    <?php endif; ?>
                                                </select>

                                        </div>
                                    </div>
                                </div>
                                <div id="8_div"class="col-md-6 hideMe inner_div"<?php if(8==$didData->
                                        dest_type): ?> style='display: block' <?php endif; ?>>
                                  <div class="form-group">
									<label class="form-label">Destination</label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <select class="form-select"  name="ingroup" id="ingroup">
                                                <?php if(isset($ring_group_list)  && !empty($ring_group_list)): ?>
                                                <?php $__currentLoopData = $ring_group_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rgroup_lst): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option <?php if($didData->ingroup == $rgroup_lst->id ): ?> selected <?php endif; ?> value=<?php echo e($rgroup_lst->id); ?>><?php echo e($rgroup_lst->description); ?> - <?php echo e($rgroup_lst->title); ?>

                                                </option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </select>>
                                	</div>
								</div>
                            </div>
                                <?php
                                    $did_fax_array = array();
                                    if($fax_did_list)
                                    {
                                        foreach($fax_did_list as $ky=>$vl)
                                        {
                                            $did_fax_array[] = $vl->userId;
                                        }
                                    }
                                    // print_r($did_fax_array);exit;
                                ?>
                                <div class="col-md-6 hideMe inner_div" id="6_div" <?php if(6==$didData->dest_type): ?>
                                        style='display: block' <?php endif; ?> >
                                        <div class="form-group">
                                            <label class="form-label">Destination </label>
                                            <div class="input-group mb-3">
                                                    <select class="form-select select2" multiple  name="fax_did[]" id="fax_did" style="width:100%">
                                                        <?php if(is_array($extension_list) && !empty($extension_list)): ?>
                                                        <?php $__currentLoopData = $extension_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ext_lst_1): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <option <?php if($did_fax_array){  if (in_array($ext_lst_1->id, $did_fax_array)){  echo "selected='selected'"; }else{ echo ''; } } ?> value=<?php echo e($ext_lst_1->id); ?> ><?php echo e($ext_lst_1->first_name); ?> <?php echo e($ext_lst_1->last_name); ?> - <?php echo e($ext_lst_1->email); ?> - <?php echo e($ext_lst_1->extension); ?>

                                                        </option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        <?php endif; ?>
                                                    </select>
                                            </div>
                                        </div>
                                </div>
                            
                                   <div class="col-md-6 hideMe inner_div" id="12_div" <?php if(12==$didData->dest_type): ?>
                                        style='display: block' <?php endif; ?>>
                                        <div class="form-group">
                                            <label class="form-label">Voice Ai</label>
                                            <div class="input-group mb-3">
                                                <span class="input-group-text"><i class="ti-user"></i></span>
                                                    <select class="form-select"  name="voice_ai" id="voice_ai">

                                                   <option>Select Prompt</option>
                                                        <!-- <?php if(isset($prompts) && is_array($prompts) && !empty($prompts)): ?>
                                                            <?php $__currentLoopData = $prompts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prompt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option value=<?php echo e($prompt->id); ?>><?php echo e($prompt->title); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        <?php endif; ?> -->
                                               <?php if(isset($prompts) && is_array($prompts) && !empty($prompts)): ?>
                                                        <?php $__currentLoopData = $prompts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prompt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option value="<?php echo e($prompt->id); ?>"
                                                    <?php echo e((isset($didData->voice_ai) && $didData->voice_ai == $prompt->id) ? 'selected' : ''); ?>>
                                                    <?php echo e($prompt->title); ?>

                                                </option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    <?php endif; ?>
                                                    </select>
                                            </div>
                                        </div>
                                </div>
                                    </div>
                                                            
                                <div class="row">
                                <div class="col-md-3">
                                    <div class="form-group">
                                      <label class="form-label">Enable SMS</label>
                                        <div class="input-group mb-3">
                                          <span class="input-group-text"><i class="ti-user"></i></span>
                                            <select class="form-select"  id="chk_sms" name="chk_sms" >
                                                <option <?php if('' !=$didData->sms_phone || ''!=$didData->sms_email): ?>
                                                    selected <?php endif; ?> value="">No</option>
                                                <option  <?php if($didData->sms == 1): ?>
                                                    selected <?php endif; ?>  value="1">Yes</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="form-group">
                                      <label class="form-label">Enable SMS AI</label>
                                        <div class="input-group mb-3">
                                          <span class="input-group-text"><i class="ti-user"></i></span>
                                            <select class="form-select"  id="sms_type" name="sms_type">
                                                <option <?php if($didData->sms_type == '0'): ?> selected <?php endif; ?> value="0">No</option>
                                                <option <?php if($didData->sms_type == '1'): ?> selected <?php endif; ?> value="1">Yes</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6 sms_grid">
                                    <div class="form-group">
                                      <label class="form-label">Assign To User  </label>
                                        <div class="input-group mb-3">
                                          <span class="input-group-text"><i class="ti-user"></i></span>
                                            <select class="form-select"  name="sms_email" id="sms_email">
                                                <?php if(is_array($extension_list) && !empty($extension_list)): ?>
                                                <?php $__currentLoopData = $extension_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ext_lst_1): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option <?php if($ext_lst_1->id == $didData->sms_email): ?> <?php echo e('selected="selected"'); ?>

                                                <?php endif; ?> value=<?php echo e($ext_lst_1->id); ?> ><?php echo e($ext_lst_1->first_name); ?> <?php echo e($ext_lst_1->last_name); ?> - <?php echo e($ext_lst_1->extension); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                            <?php

                                            $phone_no = substr($didData->sms_phone, -10);
                                            $country_code = substr($didData->sms_phone, 0, -10);
                                            if(empty($didData->sms_phone))
                                            {
                                                $country_code = 1;
                                                $phone_no = $didData->sms_phone;
                                            }

                                            ?>
                                <div class="col-md-6">
                                    <div class="form-group">
                                      <label class="form-label">Set Exclusive For User </label>
                                        <div class="input-group mb-3">
                                          <span class="input-group-text"><i class="ti-user"></i></span>
                                          <select class="form-select"  name="set_exclusive_for_user" id="set_exclusive_for_user">
                                                <option value="1" <?php echo e($didData->set_exclusive_for_user == 1 ? 'selected' : ''); ?>>Yes</option>
                                                <option value="0" <?php echo e($didData->set_exclusive_for_user == 0 ? 'selected' : ''); ?>>No</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                              <div class="col-md-6" >
                                    <div class="form-group">
                                      <label class="form-label">Apply Call Times  </label>
                                        <div class="input-group mb-3">
                                          <span class="input-group-text"><i class="ti-user"></i></span>
                                            <select class="form-select"  name="call_time_department_id" id="call_time_department">
                                                    <option value="0" >No</option>
                                                    <?php if(isset($department_list->data) && !empty($department_list->data)): ?>
                                                        <?php $__currentLoopData = $department_list->data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($item->id); ?>" <?php echo e(isset($didData->call_time_department_id) && $didData->call_time_department_id == $item->id ? 'selected' : ''); ?>> <?php echo e($item->name); ?></option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    <?php endif; ?>
                                            </select>
                                        </div>
                                    </div>
                              </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                      <label class="form-label">Apply Holiday Calendar  </label>
                                      <div class="input-group mb-3">
                                          <span class="input-group-text"><i class="ti-user"></i></span>
                                          <select class="form-select"  name="call_time_holiday" id="holiday">
                                                <option value="0" <?php echo e(isset($didData->call_time_holiday) && $didData->call_time_holiday == 0 ? 'selected' : ''); ?>>No</option>
                                                <option value="1" <?php echo e(isset($didData->call_time_holiday) && $didData->call_time_holiday == 1 ? 'selected' : ''); ?>>Yes</option>
                                            </select>
                                      </div>
                                    </div>
                                </div>
                                  </div>

                                    <div class="row"id="OutOfHours" style="<?php echo e($didData->call_time_holiday > 0 || $didData->call_time_department_id > 0  ? '' : 'display: none;'); ?>">
                                        <div class="col-md-6" >
                                            <div class="form-group">
                                                <label class="form-label">Destination Type (Out Of Hours)</label>
                                                <div class="input-group mb-3">
                                                    <span class="input-group-text"><i class="ti-user"></i></span>
                                                    <select class="form-select"  name="dest_type_ooh" id="dest_type_ooh" onchange="return showDataOoh(this.value)">
                                                        <?php if(!empty($dest_type)): ?>
                                                        <?php $__currentLoopData = $dest_type; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($item->dest_id); ?>" <?php echo e($didData->dest_type_ooh == $item->dest_id ? 'selected' : ''); ?> > <?php echo e($item->dest_type); ?></option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        <?php endif; ?>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-md-6 hideMe ooh_div" id="0_div_ooh" <?php if(0==$didData->dest_type_ooh): ?>
                                                style='display: block;' <?php endif; ?>>
                                            <div class="form-group">
                                                    <label class="form-label">Destination (Out Of Hours) </label>
                                                    <div class="input-group mb-3" >
                                                        <span class="input-group-text"><i class="ti-user"></i></span>
                                                            <select class="form-select"   name="ivr_id_ooh" id="ivr_id">
                                                                <?php if(isset($ivr_list) && !empty($ivr_list)): ?>
                                                                <?php $__currentLoopData = $ivr_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ivr_lst): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option value=<?php echo e($ivr_lst->id); ?> <?php echo e($didData->ivr_id_ooh == $ivr_lst->id ? 'selected' : ''); ?> ><?php echo e($ivr_lst->ivr_desc); ?> - <?php echo e($ivr_lst->ivr_id); ?>

                                                                </option>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                <?php endif; ?>
                                                            </select>
                                                    </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6 hideMe ooh_div" id="1_div_ooh"<?php if(1==$didData->dest_type_ooh): ?>
                                        style='display: block' <?php endif; ?> >
                                            <div class="form-group">
                                                <label class="form-label">Destination (Out Of Hours)</label>
                                                    <div class="input-group mb-3">
                                                        <span class="input-group-text"><i class="ti-user"></i></span>
                                                        <select class="form-select"  name="extension_ooh" id="extension">
                                                            <?php if(is_array($extension_list) && !empty($extension_list)): ?>
                                                            <?php $__currentLoopData = $extension_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ext_lst): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option <?php echo e($didData->extension_ooh == $ext_lst->id ? 'selected' : ''); ?>  value=<?php echo e($ext_lst->id); ?>><?php echo e($ext_lst->first_name); ?> <?php echo e($ext_lst->last_name); ?> - <?php echo e($ext_lst->extension); ?>

                                                            </option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                            <?php endif; ?>
                                                        </select>
                                                    </div>
                                            </div>
                                         </div>
                                <div class="col-md-6 hideMe ooh_div" id="2_div_ooh" <?php if(2==$didData->dest_type_ooh): ?>
                                        style='display: block' <?php endif; ?> >
                                  <div class="form-group">
									<label class="form-label">Destination (Out Of Hours)</label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <select class="form-select"  name="voicemail_id_ooh" id="voicemail_id">
                                                <?php if(is_array($extension_list)  && !empty($extension_list)): ?>
                                                <?php $__currentLoopData = $extension_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ext_lst): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option <?php echo e($didData->voicemail_id_ooh == $ext_lst->id ? 'selected' : ''); ?> value=<?php echo e($ext_lst->id); ?>><?php echo e($ext_lst->first_name); ?> <?php echo e($ext_lst->last_name); ?> - <?php echo e($ext_lst->extension); ?>

                                                </option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </select>
                                	</div>
								</div>
                              </div>

                              <div id="5_div_ooh" class="col-md-6 hideMe ooh_div" <?php if (5 == $didData->dest_type_ooh) echo "style='display: block;'"; else echo "style='display: none;'"; ?>>
                                  <div class="form-group">
									<label class="form-label">Destination (Out Of Hours) </label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <select class="form-select"  name="conf_id_ooh" id="conf_id">
                                                <?php if(is_array($conferencing)  && !empty($conferencing)): ?>
                                                <?php $__currentLoopData = $conferencing; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $conf): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option <?php echo e($didData->conf_id == $conf->id ? 'selected' : ''); ?>  value=<?php echo e($conf->id); ?>><?php echo e($conf->title); ?> - <?php echo e($conf->conference_id); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </select>
                                	</div>
								</div>
                                </div>

                              <div class="col-md-3 hideMe inner_div ooh_div"id="4_div_ooh"<?php if(3==$didData->dest_type_ooh): ?>
                                        style='display: block' <?php endif; ?>>
                                  <div class="form-group">
									<label class="form-label">Country Phone Code</label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <select class="form-select"  name="country_code_ooh" id="country_code_ooh">
                                                <?php if(is_array($phone_country) && !empty($phone_country)): ?>
                                                <?php $__currentLoopData = $phone_country; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $code): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option <?php if($didData->country_code_ooh == $code->phone_code ): ?> selected <?php endif; ?> value=<?php echo e($code->phone_code); ?>><?php echo e($code->country_name); ?> (+<?php echo e($code->phone_code); ?>)
                                                </option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </select>
                                	</div>
								</div>
                                </div>
                                <?php
                                    $newstring = substr($didData->forward_number, -10);
                                    ?>
                                <div id="4_div_ooh"class="col-md-3 hideMe ooh_div 4_div_ooh" <?php if(3==$didData->dest_type_ooh): ?>
                                        style='display: block' <?php endif; ?> >
                                  <div class="form-group">
									<label class="form-label">Phone Number  </label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <input type="text" class="form-control" value="<?php echo e($didData->forward_number_ooh); ?>"  name="forward_number_ooh" id="forward_number_ooh" placeholder="(999) 999-9999">

                                	</div>
								</div>
                              </div>
                              <div  id="8_div_ooh"class="col-md-6 hideMe ooh_div" <?php if(8==$didData->dest_type_ooh): ?> style='display: block' <?php endif; ?> >
                                  <div class="form-group">
									<label class="form-label">Destination (Out Of Hours)</label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <select class="form-control"  name="ingroup_ooh" id="ingroup">
                                                <?php if(isset($ring_group_list) && !empty($ring_group_list)): ?>
                                                <?php $__currentLoopData = $ring_group_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rgroup_lst): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option <?php echo e($didData->ingroup_ooh == $rgroup_lst->id ? 'selected' : ''); ?> value=<?php echo e($rgroup_lst->id); ?>><?php echo e($rgroup_lst->description); ?> - <?php echo e($rgroup_lst->title); ?>

                                                </option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </select>
                                	</div>
								</div>
                                </div>
                                <?php
                                    $did_fax_array = array();
                                    if($fax_did_list)
                                    {
                                        foreach($fax_did_list as $ky=>$vl)
                                        {
                                            $did_fax_array[] = $vl->userId;
                                        }
                                    }
                                    // print_r($did_fax_array);exit;
                                    ?>
                                <div id="6_div_ooh"class="col-md-6 hideMe ooh_div" <?php if(6==$didData->dest_type_ooh): ?>
                                        style='display: block' <?php endif; ?>"  >
                                  <div class="form-group">
									<label class="form-label">Destination (Out Of Hours)  </label>
									<div class="input-group mb-3">
                                        <select class="form-select select2" multiple  name="fax_did_ooh[]" id="fax_did_ooh" style="width:100%">
                                                <?php if(is_array($extension_list) && !empty($extension_list)): ?>
                                                <?php $__currentLoopData = $extension_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ext_lst_1): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option <?php if($did_fax_array){  if (in_array($ext_lst_1->id, $did_fax_array)){  echo "selected='selected'"; }else{ echo ''; } } ?> value=<?php echo e($ext_lst_1->id); ?> ><?php echo e($ext_lst_1->first_name); ?> <?php echo e($ext_lst_1->last_name); ?> - <?php echo e($ext_lst_1->email); ?> - <?php echo e($ext_lst_1->extension); ?>

                                                </option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            </select>
                                	</div>
								</div>
                              </div>
                                    <div class="col-md-6 hideMe hideMe ooh_div" id="12_div_ooh" <?php if(12==$didData->dest_type): ?>
                                        style='display: block' <?php endif; ?>>
                                        <div class="form-group">
                                            <label class="form-label">Voice Ai</label>
                                            <div class="input-group mb-3">
                                                <span class="input-group-text"><i class="ti-user"></i></span>
                                                <select class="form-select" name="voice_ai_ooh" id="voice_ai_ooh">
                                                    <option>Select Prompt</option>
                                                    <?php if(isset($prompts) && is_array($prompts) && !empty($prompts)): ?>
                                                        <?php $__currentLoopData = $prompts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prompt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option value="<?php echo e($prompt->id); ?>"
                <?php echo e((isset($didData->voice_ai_ooh) && $didData->voice_ai_ooh == $prompt->id) ? 'selected' : ''); ?>>
                <?php echo e($prompt->title); ?>

            </option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    <?php endif; ?>
                                                </select>

                                            </div>
                                        </div>
                              <input type="hidden" class="form-control" name="old_ann_id" value="<?php echo e(isset($didData->call_screening_ivr_id) ? $didData->call_screening_ivr_id : "0"); ?>" id="ann_id">

                                    </div>





                                <div id="9_div_ooh"class="col-md-6 hideMe ooh_div"  <?php if(9==$didData->dest_type_ooh): ?> style='display: block' <?php endif; ?>>
                                  <div class="form-group">
									<label class="form-label">Destination (Out Of Hours) </label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <select class="form-select"  name="queue_id_ooh"></select>

                                	</div>
								</div>
                              </div>


                            </div>

                                 <div class="row">
                              <div class="col-md-6">
                     <div class="form-group">
                       <label class="form-label">Call Screening Audio</label>
                       <div class="input-group mb-3">
                       <select class="form-select" name="call_screening_status" id="call_screening_status">
                           <option <?php if($didData->call_screening_status == 0): ?> selected <?php endif; ?> value="0">No</option>
                           <option <?php if($didData->call_screening_status == 1): ?> selected <?php endif; ?> value="1">Yes</option>
                       </select>
                       </div>
                   </div>
                   </div>
                   <?php
    $role = Session::get('role');
?>
<?php if(in_array($role, ['system_admin', 'system_administrator'])): ?>
                   <div class="col-md-6">
                <div class="form-group <?php $__errorArgs = ['group_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> has-error <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                  <label class="form-label">Voip Providers</label>
                  <div class="input-group mb-3">
                  <span class="input-group-text <?php $__errorArgs = ['caller_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> text-danger border-danger <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"><i class="ti-world"></i></span>
                    <select class="form-select" name="voip_provider" autocomplete="off" data-placeholder="Select Providers"id="voip_provider"required>
                        <option value="didforsale"<?php if($didData->voip_provider == "didforsale"): ?> selected <?php endif; ?> >DidForSale</option>
                        <option value="plivo"<?php if($didData->voip_provider == "plivo"): ?> selected <?php endif; ?>>Plivo</option>
                        <option value="telnyx"<?php if($didData->voip_provider == "telnyx"): ?> selected <?php endif; ?>>Telnyx</option>
                        <option value="twilio"<?php if($didData->voip_provider == "twilio"): ?> selected <?php endif; ?>>Twilio</option>
                        <option value="tata"<?php if($didData->voip_provider == "tata"): ?> selected <?php endif; ?>>Tata</option>





                                                </select>
                  </div>
                </div>
                </div>
                <?php else: ?>
                <input type="hidden" name="voip_provider" value="<?php echo e($didData->voip_provider ?? ''); ?>">
                        <?php endif; ?>

                 </div>

                                <div <?php if($didData->call_screening_status == 0): ?>  style="display: none;"  <?php endif; ?> id="show_call_screen" >
                                <hr class="my-15">
                                <div class="form-group">
                                    <div class="ivr-input-types">
                                        <div class="col-sm-6 radio ivr_type_file">
                                                <div class="demo-radio-button">
                                                    <input  type="radio" id="ivr_audio_option_upload_file"name="ivr_audio_option" value="upload" checked onclick="selectIvrUploadFileOption('upload_file_div');"/>
                                                    <label for="ivr_audio_option_upload_file">Upload File</label>
                                                    <input type="radio" id="ivr_audio_option_audio" name="ivr_audio_option" value="text_to_speech" onclick="selectIvrUploadFileOption('text_to_speech_div');">
                                                    <label for="ivr_audio_option_audio">Convert Text to Audio</label>

                                                </div>

                                        </div>
                                    </div>
                                </div>

                                <div class="col-md-6"id="upload_file_div">
                                    <div class="form-group" >
                                        <label for="" class="form-label">Upload File<span style="color:red;">* &nbsp; (Only mp3 or wav file type is allowed)</span></label>
                                        <input type="file" accept="audio/*"  class="form-control"   name="ann_id"  placeholder="Please Upload file" style="width:100%" />
                                    </div>
                                </div>



                          <div class="row" id="text_to_speech_div" style="display: none;">

                                <div class="col-md-6" >
                                  <div class="form-group">
									<label class="form-label">Language </label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <select id="language_ddl" name="language" class="form-select" onchange="selectVoiceNameOnLanugageChange();">
                                            <option value="">--Select Language--</option>
                                           <?php if(!empty($arrLang)): ?>
                                            <?php $__currentLoopData = $arrLang; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option <?php echo e(isset($didData->language) && $didData->language == base64_decode($key) ? "selected='selected'" : ""); ?> value="<?php echo e($key); ?>"><?php echo e(base64_decode($key)); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php endif; ?>
                                        </select>
                                	</div>
								</div>
                            </div>



								  <div class="col-md-6" >
                                  <div class="form-group">
									<label class="form-label">Voice Name</label>
									<div class="input-group mb-3">
										<span class="input-group-text"><i class="ti-user"></i></span>
                                        <select id="voice_name_ddl" name="voice_name" class="form-select">
                                            <option value="">--Select Voice Name--</option>
                                        </select>
                                	</div>
								</div>
                                </div>
                                <div class="col-md-10">
                                  <div class="form-group">
									<label class="form-label">Text </label>
                                    <textarea id="speech_text" class="form-control" name="speech_text"
                                            placeholder="Type what you like your customers to hear and click on Listen button to listen"><?php echo e(isset($didData->speech_text) ? $didData->speech_text : ""); ?></textarea>
                                        <audio style="display:none;" id="test_audio" controls preload ='none'>
                                            <source src="" type='audio/mp3'>
                                        </audio>
								</div>
                                </div>
                                <div class="col-md-2"style="margin-top:25px;">
                                  <div class="form-group">
									<div class="input-group mb-3">
                                    <a class="btn btn-primary" href="javascript:void(0);" onclick="getAudioOnText();">Listen</a>

                                	</div>
								</div>
                            </div>
                            </div>
                            </div>
                            <div class="row">

								  <div class="col-md-6"id="record_audio" style="display: none;">
                                  <div class="form-group">

									<div class="input-group mb-3">
                                    <button type="button" id="record" class="btn"><i class="fa fa-microphone"></i></button>
                                        <button type="button" id="stopRecord" class="btn" disabled><i class="fa fa-stop"></i></button>
                                        <span class="recording-status">Voice recording...</span>
                                        <audio id=recordedAudio></audio>
                                	</div>
								</div>
                                </div>

                            </div>



							<!-- /.box-body --> 
							<div class="box-footer text-end">
								<a href="/did"><button type="button" class="btn btn-warning me-1">
								  <i class="ti-trash"></i></a> Cancel
								</button>
								<button type="submit" name="submit" value="add" class="btn btn-primary">
								  <i class="ti-save-alt"></i> Update
								</button>
							</div>
						</form>
					  </div>
					  <!-- /.box -->
				</div>


                <div class="modal fade" id="models" tabindex="-1" aria-labelledby="modelsLabel" aria-hidden="true">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title">Confirm Changes</h5>
              <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>

                                  <div class="modal-body">
                                  <p>< <span id="view"></span> > is currently the default CLI for your account.</p>                                    <p>Do you want to proceed?</p>
                                  <p>Do you want to set < <span id="viewCurrentCLI"></span> > as your default CLI ?</p>


                                </div>
                                <div class="modal-footer">
                                  <button type="button" class="btn btn-secondary btn-sm changeDefault" data-bs-dismiss="modal">No</button>
                                  <button type="button" class="btn btn-success btn-ok  btn-sm" data-bs-dismiss="modal">Yes</button>

                                </div>

          </div>
        </div>
      </div>
		  </div>
		  <!-- /.row -->

		</section>

        <style>
.row-margin-15
{
    margin-top: 1.5em;
}

.hideMe
{
    display: none;
}

.hide_show
{
    display:none;
}

.operator_txt
{
    display:none;
}



.fax_email_grid
{
    display:none;
}

</style>


<script src="https://code.jquery.com/jquery-3.7.0.js" integrity="sha256-JlqSTELeR4TLqP0OG9dxM7yDPqX1ox/HfgiSLBj8+kM=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/imask"></script>
<script>
      var phoneInput = document.getElementById('forward_number');
    var phoneMask = new IMask(phoneInput, {
        mask: '(000) 000-0000'
    });
    var phoneInput = document.getElementById('forward_number_ooh');
    var phoneMask = new IMask(phoneInput, {
        mask: '(000) 000-0000'
    });
    </script>
<script>
    $("#call_screening_status").change(function()
    {
        if($("#call_screening_status").val() == 0)
        {
            $("#show_call_screen").hide();
        }
        else
        if($("#call_screening_status").val() == 1)
        {
            $("#show_call_screen").show();
        }

    });
</script>

<script>

        var csrfToken = $('meta[name="csrf-token"]').attr('content');


    $(document).ready(function () {
        setTimeout(function() {
            selectVoiceNameOnLanugageChange();
        }, 1000);

        $(".edit_ivr_form").submit(function () {
            if ($("#ivr_audio_option_audio").prop("checked") && !$("#test_audio").attr("src")) {
                toastr.info("Please listen to the audio before submitting");
                return false;
            }
        });

        var prompt_option = <?php if(isset($didData->prompt_option)): ?> <?php echo $didData->prompt_option ?> <?php else: ?>"0"<?php endif; ?>;
        var voice_name = "<?php if(isset($didData->voice_name)): ?><?php echo $didData->voice_name ?><?php else: ?> 0 <?php endif; ?>";

        if(prompt_option == 2){
            $("#ivr_audio_option_audio_record").prop("checked", true);
            $("#upload_file_div").hide();
            $("#text_to_speech_div").hide();
            $("#record_audio").show();
        } else if(prompt_option == 1){
            $("#ivr_audio_option_audio").prop("checked", true);
            $("#upload_file_div").hide();
            $("#record_audio").hide();
            $("#text_to_speech_div").show();

            setTimeout(function() {
                selectVoiceNameOnLanugageChange(voice_name);
            }, 2000);
        } else{
            $("#ivr_audio_option_upload_file").prop("checked", true);
            $("#record_audio").hide();
            $("#upload_file_div").show();
            $("#text_to_speech_div").hide();
        }
    });

    function selectIvrUploadFileOption(option) {
        if (option == 'text_to_speech_div') {
            $("#text_to_speech_div").show();
            $("#upload_file_div").hide();
            $("#record_audio").hide();
        } else if(option == 'audio_record') {
            getAudioRecordPermission();
            $("#record_audio").show();
            $("#upload_file_div").hide();
            $("#text_to_speech_div").hide();
        } else {
            $("#upload_file_div").show();
            $("#text_to_speech_div").hide();
            $("#record_audio").hide();
        }
    }

    function selectVoiceNameOnLanugageChange(defaultSelected = null) {
        var csrfToken = $('meta[name="csrf-token"]').attr('content');
        $.ajax({
            url: '/get-voice-name-on-lanugage',
            type: 'post',
            headers: {
            'X-CSRF-TOKEN': csrfToken // Include the CSRF token in the headers
        },
            data: {'language': $('#language_ddl').val()},
            success: function (response) {
                var html = '';
                $.each(response, function (index, value) {
                    var optionValue = value.language_code + " ## " + value.voice_name + " ## " + value.ssml_gender;
                    html += '<option value="'+ optionValue +'" ';
                    html += (defaultSelected == optionValue) ? 'selected >' : '>';
                    html += optionValue + '</option>';
                });
                $("#voice_name_ddl").html('');
                $("#voice_name_ddl").html(html);
            }
        });

    }

    function getAudioOnText() {
        if ($('#speech_text').val() == '') {
            toastr.error("Please Type Text");
            return;
        }
        if ($('#language_ddl').val() == '') {
            toastr.error("Please Select Language");
            return;
        }
        if ($('#voice_name_ddl').val() == '' || $('#voice_name_ddl').val() == null) {
            toastr.error("Please Select Voice Name");
            return;
        }

        $("#test_audio").attr('src', "");
        $.ajax({
            url: '/get-audio-on-text',
            type: 'post',
           /* headers: {
            'X-CSRF-TOKEN': csrfToken // Include the CSRF token in the headers
        },*/
            data: {'language': $('#language_ddl').val(),
                'voice_name_ddl': $('#voice_name_ddl').val(),
                'speech_text': $('#speech_text').val(),
                'prompt_for' : 'announcements',
                '_token': $('meta[name="csrf-token"]').attr('content') // Add the CSRF token here


            },

            success: function (response) {
                if (typeof (response.file) != 'undefined') {
                    var file = "<?php echo e(env('FILE_UPLOAD_URL')); ?>" + "<?php echo e(env('ANNOUNCEMENTS_FILE_UPLOAD_FOLDER_NAME')); ?>" + "/" + response.file;
                     var d = new Date();
                    $("#test_audio").attr('src', file+"?"+d.getTime());
                    var x = document.getElementById("test_audio");
                    x.play();
                } else {

                }
            }
        });
    }

    function getAudioRecordPermission(){
        navigator.mediaDevices.getUserMedia({audio:true})
            .then(stream => {handlerFunction(stream)});
    }

    function handlerFunction(stream) {
        rec = new MediaRecorder(stream);
        rec.ondataavailable = e => {
            audioChunks.push(e.data);
            if (rec.state == "inactive"){
                let blob = new Blob(audioChunks,{type:'audio/wav'});
                recordedAudio.src = URL.createObjectURL(blob);
                recordedAudio.controls=true;
                recordedAudio.autoplay=true;
                sendData(blob)
            }
        }
    }

    function sendData(data) {
        var fd = new FormData();
        fd.append('data', data);

        $.ajax({
            url: '/save-recorded-audio-announcements',
            type: 'POST',
            data: fd,
            processData: false,
            contentType: false,
            success: function (response){
                // console.log(response);
            },
            error: function (response) {
                console.log(response);
            }
        });
    }

    record.onclick = e => {
        record.disabled = true;
        $(".recording-status").show();
        stopRecord.disabled=false;
        audioChunks = [];
        rec.start();
    }
    stopRecord.onclick = e => {
        record.disabled = false;
        stop.disabled=true;
        $(".recording-status").hide();
        rec.stop();
    }
</script>

<script>
    function showData(id)
    {
        $('.inner_div').hide();
        $('#' + id + '_div').css("display", "block");
        $('.' + id + '_div').css("display", "block");

    }

    function showDataOoh(id)
    {
        $('.ooh_div').hide();
        $('#' + id + '_div_ooh').css("display", "block");
        $('.' + id + '_div_ooh').css("display", "block");

    }

    function checkPhoneNo()
    {
        var mobile = document.getElementById('sms_phone');
        var message = document.getElementById('sms_message');
        var goodColor = "#dd4b39";
        var badColor = "";

        if(sms_phone.value.length < 9)
        {
            sms_phone.style.backgroundColor = badColor;
            sms_message.style.color = goodColor;
            sms_message.innerHTML = "required 10 digits!";
            $("#message").show();
            $("#submit").attr("disabled", true);
            return false;
        }

        if(sms_phone.value.length >9)
        {
            sms_phone.style.backgroundColor = badColor;
            sms_message.style.color = badColor;
            $("#message").hide();
            $("#submit").removeAttr("disabled");
        }
    }

    function check()
    {
        var mobile = document.getElementById('cli');
        var message = document.getElementById('message');
        var goodColor = "#dd4b39";
        var badColor = "";

        if(cli.value.length < 9)
        {
            cli.style.backgroundColor = badColor;
            message.style.color = goodColor;
            message.innerHTML = "required 10 digits!";
            $("#message").show();
            $("#submit").attr("disabled", true);
            return false;
        }

        if(cli.value.length >9)
        {
            cli.style.backgroundColor = badColor;
            message.style.color = badColor;
            $("#message").hide();
            $("#submit").removeAttr("disabled");
        }
    }

    $(document).ready(function()
    {
        $('#default_did').change(function()
        {
            default_did = $('#default_did').val();
            $.ajax({
                url: '/findDefaultDid/' + default_did,
                type: 'get',
                success: function (response)
                {
                    if(response[0].cli)
                    {
                        cli = $("#cli").val();
                        $("#view").html(response[0].cli);
                        $("#viewCurrentCLI").html(cli);


                        $("#models").modal('show');
                    }
                }
            });
        });

        $(document).on("click", ".changeDefault" , function()
        {
            $("#default_did").val('0');
        });

        $('#operator_check').change(function()
        {
            operator = $('#operator_check').val();
            if(operator == 0)
            {
                $('.operator_txt').hide();
            }

            else if(operator == 1)
            {
                $('.operator_txt').show();
            }
        });

        $('#veh1').change(function()
        {
            veh1 = $('#veh1').val();
            if(veh1 == 'v')
            {
                $('.fax_email_grid').hide();
            }

            else if(veh1 == 'f')
            {
                $('.fax_email_grid').show();
            }
        });


        chk_sms = $('#chk_sms').val();
        if(chk_sms == '1')
        {
            $('.sms_grid').show();
        }
        else
            $('.sms_grid').hide();



        $('#chk_sms').change(function()
        {
            chk_sms = $('#chk_sms').val();
            if(chk_sms == 0)
            {
                $('.sms_grid').hide();
            }
            else
            if(chk_sms == 1)
            {
                $('.sms_grid').show();
            }
        });

        redirect_last_agent = $('#redirect_last_agent').val();
        if(redirect_last_agent == '1')
        {
            $('#showRow').hide();
        }
        else
            $('#showRow').show();

        $('#redirect_last_agent').change(function()
        {
            redirect_last_agent = $('#redirect_last_agent').val();
            if(redirect_last_agent == 1)
            {
                $('#showRow').hide();
            }
            else
            if(redirect_last_agent == 0)
            {
                $('#showRow').show();

            }
        });

        $('#fax_did').select2()
        $('#fax_did_ooh').select2()

        //Toggle ooh inputs
        $("#call_time_department").on('change', function(){
            toggleOutOfHousDiv();
        });
        //Toggle ooh inputs
        $("#holiday").on('change', function(){
            toggleOutOfHousDiv();
        });
    });

    /**
    * Toggle ooh inputs
    * @returns {undefined}
    */
    function toggleOutOfHousDiv() {
        if($("#call_time_department").val() == '0' && $("#holiday").val() == '0') {
            $("#OutOfHours").hide();
        } else {
            $("#OutOfHours").show();
        }
    }

    </script>


<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/leadmine/leadmine_pro/resources/views/did/edit_did.blade.php ENDPATH**/ ?>