Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified applets/transfer/applet.json
100644 → 100755
Empty file.
Empty file modified applets/transfer/icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions applets/transfer/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$(function(){
$('.subflow-applet input[type="radio"]').live('click', function(event) {
var tr = $(this).closest('tr');

tr.closest('table').find('tr').each(function (index, element) {
// Set the others to off
$(element).removeClass('on').addClass('off');
});

tr.addClass('on').removeClass('off');
});
});
31 changes: 9 additions & 22 deletions applets/transfer/twiml.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
<?php
$response = new Response();
$response = new TwimlResponse;

$redirect_type_selector = AppletInstance::getValue('redirect-type-selector');

if ($redirect_type_selector == "flow")
{
$gotoflow_raw = AppletInstance::getValue('gotoflow');
$gotoflow_url = site_url("/twiml/applet/voice/" . $gotoflow_raw . "/start");

$response = new Response();
$response->addRedirect($gotoflow_url);
$response->Respond();
exit;
}

else if ($redirect_type_selector == "url")
{
if($redirect_type_selector == 'url') {
$gotourl = AppletInstance::getValue('gotourl');
$response = new Response();
$response->addRedirect($gotourl);
$response->Respond();
exit;
$response->redirect($gotourl);
}
else {
$gotoflow = AppletInstance::getValue('gotoflow');
$gotoflow_url = site_url('/twiml/applet/' . AppletInstance::getFlowType() . '/' . $gotoflow);
$response->redirect($gotoflow_url);
}

else
{
trigger_error("Unexpected redirect-type-selector value of '$redirect_type_selector'");
}
$response->respond();
113 changes: 48 additions & 65 deletions applets/transfer/ui.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,74 +1,57 @@
<?php
$gotoflow = AppletInstance::getValue('gotoflow');
$redirect_type_selector = AppletInstance::getValue('redirect-type-selector', 'flow');

?>
<div class="vbx-applet subflow-applet">
<h2>Transfer</h2>
<p>Continue this flow by starting another flow or redirecting to a TwiML URL.</p>
<?php

/*
foreach(OpenVBX::GetFlows() as $flow)
{

echo $flow->values['name'];
}
*/
?>
<pre><?php // print_r(OpenVBX::GetFlows()); ?></pre>


<div class="radio-table">
<table>
<tr class="radio-table-row first <?php echo ($redirect_type_selector === 'flow') ? 'on' : 'off' ?>">
<td class="radio-cell">
<input type="radio" name="redirect-type-selector" value="flow" <?php echo ($redirect_type_selector === 'flow') ? 'checked="checked"' : '' ?> />
</td>
<td class="content-cell">
<div style="float: left;"><h4>Redirect to a call flow</h4></div>
<div style="float: right;">

<select name="gotoflow" class="medium">
<?php foreach(OpenVBX::GetFlows() as $flow): ?>
<option value="<?php echo $flow->values['id']; ?>" <?php echo ($gotoflow == $flow->values['id'])? 'selected="selected"' : '' ?>><?php echo $flow->values['name'];?></option>
<?php endforeach; ?>
</select>


</div>
</td>
</tr>
<tr class="radio-table-row last <?php echo ($redirect_type_selector === 'url') ? 'on' : 'off' ?>">
<td class="radio-cell">
<input type="radio" name="redirect-type-selector" value="url" <?php echo ($redirect_type_selector === 'url') ? 'checked="checked"' : '' ?> />
</td>
<td class="content-cell">
<div style="float: left;"><h4>Redirect to a URL</h4></div>
<div style="float: right;">
<div class="vbx-input-container input">
<input type="text" class="medium" name="gotourl" value="<?php echo AppletInstance::getValue('gotourl') ?>"/>
</div>
</div>
</td>
</tr>
</table>
<script>
$(".subflow-applet input[type=radio]").live('click', function(event) {
var tr = $(this).closest('tr');

tr.closest('table').find('tr').each(function (index, element) {
// Set the others to off
$(element).removeClass('on').addClass('off');
});

tr.addClass('on').removeClass('off');
});

</script>
</div>

<div class="radio-table">
<fieldset class="vbx-input-container">
<table>
<tr class="radio-table-row first <?php echo ($redirect_type_selector === 'flow') ? 'on' : 'off' ?>">
<td class="radio-cell">
<input type="radio" name="redirect-type-selector" value="flow" <?php echo ($redirect_type_selector === 'flow') ? 'checked="checked"' : '' ?> />
</td>
<td class="content-cell">
<div style="float: left;"><h4>Redirect to a flow</h4></div>
<div style="float: right;">
<select name="gotoflow" class="medium">
<?php
foreach(OpenVBX::GetFlows() as $flow):
$data = json_decode($flow->values['voice' == AppletInstance::getFlowType() ? 'data' : 'sms_data'], true);
if(empty($data))
continue;
if(is_object($data))
$data = get_object_vars($data);
?>
<optgroup label="<?php echo htmlentities($flow->values['name']); ?>">
<?php
foreach($data as $id => $instance):
$url = $flow->values['id'] . '/' . $id;
?>
<option value="<?php echo $url; ?>" <?php echo ($gotoflow == $url)? 'selected="selected"' : '' ?>><?php echo htmlentities($instance['name']); ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
</div>
</td>
</tr>
<tr class="radio-table-row last <?php echo ($redirect_type_selector === 'url') ? 'on' : 'off' ?>">
<td class="radio-cell">
<input type="radio" name="redirect-type-selector" value="url" <?php echo ($redirect_type_selector === 'url') ? 'checked="checked"' : '' ?> />
</td>
<td class="content-cell">
<div style="float: left;"><h4>Redirect to a URL</h4></div>
<div style="float: right;">
<div class="vbx-input-container input">
<input type="text" class="medium" name="gotourl" value="<?php echo AppletInstance::getValue('gotourl') ?>"/>
</div>
</div>
</td>
</tr>
</table>
</fieldset>
</div>
<br />


</div><!-- .vbx-applet -->