init
This commit is contained in:
293
modules/EcmCalls/anMenu/anMenu.html
Executable file
293
modules/EcmCalls/anMenu/anMenu.html
Executable file
@@ -0,0 +1,293 @@
|
||||
<!-- BEGIN: main -->
|
||||
|
||||
<script type="text/javascript" src="modules/EcmCalls/anMenu/anMenu.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="modules/EcmCalls/anMenu/anMenu.css" />
|
||||
|
||||
<div id="anMenu" class="anMenu" style="display:none;">
|
||||
<form name="anMenuEdit">
|
||||
<div id="anMenuHeader" class="anMenuHeader">
|
||||
{MOD.LBL_ASSIGN_MENU_TITLE}
|
||||
<img src="modules/EcmCalls/anMenu/close.gif" width="12" height="12" onClick="anMenuClose();" />
|
||||
</div>
|
||||
<div id="anMenuBody" class="anMenuBody">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
{MOD.LBL_ASSIGN_MENU_PARENT_NAME}:
|
||||
</td>
|
||||
<td>
|
||||
<select id="an_menu_parent" name="an_menu_parent">
|
||||
{AN_MENU_PARENT_OPTIONS}
|
||||
</select>
|
||||
|
||||
<input type="text" name="an_menu_parent_name" id="an_menu_parent_name" class="sqsEnabled" autocomplete="off" />
|
||||
<input type="hidden" name="an_menu_parent_id" id="an_menu_parent_id" />
|
||||
<input type="button" id="an_menu_parent_select_button" value="{MOD.LBL_ASSIGN_MENU_SELECT_BUTTON}" />
|
||||
<input type="button" id="an_menu_parent_clear_button" value="{MOD.LBL_ASSIGN_MENU_CLEAR_BUTTON}" />
|
||||
<input type="button" id="an_menu_parent_create_button" value="{MOD.LBL_ASSIGN_MENU_CREATE_BUTTON}" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{MOD.LBL_ASSIGN_MENU_PARENT_PHONE}:
|
||||
</td>
|
||||
<td>
|
||||
<span id="an_menu_parent_phones_select">
|
||||
{AN_MENU_PARENT_PHONES_OPTIONS}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{MOD.LBL_ASSIGN_MENU_NEW_NUMBER}:
|
||||
</td>
|
||||
<td>
|
||||
<span id="an_menu_parent_phones_select">
|
||||
<input type="text" name="an_menu_new_phone" id="an_menu_new_phone" style="width:250px" />
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{MOD.LBL_ASSIGN_MENU_UPDATE_RECORDS}:
|
||||
</td>
|
||||
<td>
|
||||
<span id="an_menu_parent_uaor">
|
||||
<select name="an_menu_update_records" id="an_menu_update_records">{AN_MENU_UPDATE_RECORDS_OPTIONS}</select>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div id="anMenuFooter" class="anMenuFooter">
|
||||
<div style="text-align:right;">
|
||||
<span>
|
||||
|
||||
<input type="hidden" name="an_menu_old_parent" id="an_menu_old_parent" />
|
||||
<input type="hidden" name="an_menu_old_parent_id" id="an_menu_old_parent_id" />
|
||||
<input type="hidden" name="an_menu_old_parent_phone" id="an_menu_old_parent_phone" />
|
||||
|
||||
<input type="hidden" name="an_menu_ecmcall_record" id="an_menu_ecmcall_record" />
|
||||
|
||||
<input type="button" class="button" value="{MOD.LBL_ASSIGN_MENU_SAVE_BUTTON}" id="an_menu_parent_save_button" />
|
||||
<input type="button" class="button" value="{MOD.LBL_ASSIGN_MENU_CANCEL_BUTTON}" onClick="anMenuClose();" />
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript" src="include/JSON.js"></script>
|
||||
<script language="javascript">sqsWaitGif = "themes/default/images/sqsWait.gif";</script>
|
||||
<script language="javascript">
|
||||
|
||||
if(typeof(sqs_objects) != "object") {
|
||||
sqs_objects = new Object();
|
||||
}
|
||||
|
||||
</script>
|
||||
<script language="javascript" src="include/javascript/quicksearch.js"></script>
|
||||
<script language="javascript" src="modules/EcmCalls/formloader.js"></script>
|
||||
|
||||
<script language="javascript">
|
||||
|
||||
function anMenuClose() {
|
||||
anMenuClear();
|
||||
var am = document.getElementById('anMenu');
|
||||
if(am && am.style) am.style.display = 'none';
|
||||
}
|
||||
|
||||
function anMenuClear() {
|
||||
document.forms.anMenuEdit.an_menu_parent_name.value = "";
|
||||
document.forms.anMenuEdit.an_menu_parent_id.value = "";
|
||||
enableQS(false);
|
||||
}
|
||||
|
||||
function anMenuParentIdChange() {
|
||||
if(an_menu_parent_old_id != document.forms.anMenuEdit.an_menu_parent_id.value) {
|
||||
an_menu_parent_old_id = document.forms.anMenuEdit.an_menu_parent_id.value;
|
||||
anMenuParentChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function anMenuParentChange(noClear) {
|
||||
var an_menu_parent = document.getElementById('an_menu_parent');
|
||||
if(an_menu_parent.value == "Users") {
|
||||
sqs_objects["an_menu_parent_name"] = sqs_objects_employee;
|
||||
}
|
||||
else {
|
||||
sqs_objects["an_menu_parent_name"] = sqs_objects_other;
|
||||
sqs_objects["an_menu_parent_name"]["modules"][0] = an_menu_parent.value;
|
||||
}
|
||||
enableQS(false);
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
'POST',
|
||||
'index.php',
|
||||
{
|
||||
success: function(results) {
|
||||
//alert(results.responseText);
|
||||
if(results.responseText) {
|
||||
var an_menu_parent_phones_select = document.getElementById('an_menu_parent_phones_select');
|
||||
if(an_menu_parent_phones_select) {
|
||||
an_menu_parent_phones_select.innerHTML = results.responseText;
|
||||
}
|
||||
}
|
||||
},
|
||||
failure: function(results) {}
|
||||
},
|
||||
'module=EcmCalls&action=AnMenu&anMenuAction=get'+an_menu_parent.value+'Select&to_pdf=1&an_menu_parent_id='+document.forms.anMenuEdit.an_menu_parent_id.value
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
var an_menu_parentFL;
|
||||
var an_menu_dd;
|
||||
var an_menu_parent_old_id = '';
|
||||
|
||||
YAHOO.util.Event.addListener(window, 'load', function() {
|
||||
|
||||
sqs_objects_other = {
|
||||
"method":"query",
|
||||
"modules":["Accounts"],
|
||||
"group":"or",
|
||||
"field_list":["name", "id"],
|
||||
"populate_list":["an_menu_parent_name", "an_menu_parent_id"],
|
||||
"conditions":[{"name":"name","op":"like_custom","end":"%","value":""}],
|
||||
"limit":"30",
|
||||
"order":"name",
|
||||
"no_match_text":"No Match"
|
||||
}
|
||||
|
||||
sqs_objects_employee = {
|
||||
"method":"get_employee_array",
|
||||
"modules":["Users"],
|
||||
"group":"or",
|
||||
"field_list":["name", "id"],
|
||||
"populate_list":["an_menu_parent_name", "an_menu_parent_id"],
|
||||
"conditions":[{"name":"name","op":"like_custom","end":"%","value":""}],
|
||||
"limit":"30",
|
||||
"order":"name",
|
||||
"no_match_text":"No Match"
|
||||
}
|
||||
|
||||
sqs_objects["an_menu_parent_name"] = sqs_objects_other;
|
||||
enableQS(false);
|
||||
|
||||
var an_menu_parent = document.getElementById('an_menu_parent');
|
||||
YAHOO.util.Event.addListener(an_menu_parent, 'change', function() { anMenuClear(); an_menu_parent_old_id = ''; anMenuParentChange(); } );
|
||||
|
||||
var an_menu_parent_select_button = document.getElementById('an_menu_parent_select_button');
|
||||
YAHOO.util.Event.addListener(an_menu_parent_select_button, 'click', function() {
|
||||
var sb = document.getElementById('an_menu_parent');
|
||||
if(sb) {
|
||||
|
||||
var user_obj = {"call_back_function":"set_return","form_name":"anMenuEdit","field_to_name_array":{"id":"an_menu_parent_id","full_name":"an_menu_parent_name"}};
|
||||
var other_obj = {"call_back_function":"set_return","form_name":"anMenuEdit","field_to_name_array":{"id":"an_menu_parent_id","name":"an_menu_parent_name"}};
|
||||
|
||||
if(sb.value == "Users") var select_obj = user_obj; else var select_obj = other_obj;
|
||||
open_popup((sb.value == "Users" ? "Employees" : sb.value), 600, 400, "", true, false, select_obj, "single", true);
|
||||
}
|
||||
});
|
||||
|
||||
var an_menu_parent_clear_button = document.getElementById('an_menu_parent_clear_button');
|
||||
YAHOO.util.Event.addListener(an_menu_parent_clear_button, 'click', function() {
|
||||
anMenuClear();
|
||||
});
|
||||
|
||||
an_menu_parentFL = new FormLoader();
|
||||
an_menu_parentFL.load('EcmCalls','Parents','an_menu_parentFL');
|
||||
an_menu_parentFL.onResponseData = function(data) {
|
||||
//hideSmartInputFloater(true);
|
||||
document.forms.anMenuEdit.an_menu_parent_id.value = data['id'];
|
||||
if(document.forms.anMenuEdit.an_menu_parent.value == "Users")
|
||||
data['name'] = data['user_name'];
|
||||
|
||||
document.forms.anMenuEdit.an_menu_parent_name.value = data['name'];
|
||||
};
|
||||
an_menu_parentFL.setEditDblClick(document.forms.anMenuEdit.an_menu_parent_name);
|
||||
an_menu_parentFL.onEditDblClick = function() {
|
||||
an_menu_parentFL.createModule=document.forms.anMenuEdit.an_menu_parent.value;
|
||||
return "&fl_record="+document.forms.anMenuEdit.an_menu_parent_id.value+'&fl_'+document.forms.anMenuEdit.an_menu_parent_phone.value+'='+document.forms.anMenuEdit.an_menu_new_phone.value;
|
||||
}
|
||||
an_menu_parentFL.onButtonClick = function() {
|
||||
an_menu_parentFL.createModule = document.forms.anMenuEdit.an_menu_parent.value;
|
||||
if(document.forms.anMenuEdit.an_menu_parent.value == "Users") var nn = "sugar_user_name"; else var nn= "name";
|
||||
return "&fl_"+nn+"="+document.forms.anMenuEdit.an_menu_parent_name.value+'&fl_'+document.forms.anMenuEdit.an_menu_parent_phone.value+'='+document.forms.anMenuEdit.an_menu_new_phone.value;
|
||||
}
|
||||
|
||||
var an_menu_parent_create_button = document.getElementById('an_menu_parent_create_button');
|
||||
YAHOO.util.Event.addListener(an_menu_parent_create_button, 'click', function() {
|
||||
var sb = document.getElementById('an_menu_parent');
|
||||
var cc_ = '';
|
||||
if(sb) {
|
||||
if(document.forms.anMenuEdit.an_menu_parent.value == "Users") var nn = "sugar_user_name"; else var nn= "name";
|
||||
if(document.forms.anMenuEdit.an_menu_parent.value == "Contacts") {
|
||||
var ccc = document.forms.anMenuEdit.an_menu_parent_name.value;
|
||||
var cc_pos = ccc.indexOf(" ");
|
||||
if(cc_pos != -1) {
|
||||
var cc_ = '&fl_first_name='+ccc.substr(0,cc_pos)+'&fl_last_name='+ccc.substr(cc_pos+1,ccc.length);
|
||||
}
|
||||
}
|
||||
|
||||
window.open("index.php?module=EcmCalls&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName=an_menu_parentFL&createModule="+sb.value+"&fl_"+nn+"="+document.forms.anMenuEdit.an_menu_parent_name.value+'&fl_'+document.forms.anMenuEdit.an_menu_parent_phone.value+'='+document.forms.anMenuEdit.an_menu_new_phone.value+cc_,"Create30","resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
|
||||
}
|
||||
});
|
||||
|
||||
an_menu_dd = new YAHOO.util.DD("anMenu");
|
||||
an_menu_dd.setHandleElId("anMenuHeader");
|
||||
|
||||
var an_menu_parent_save_button = document.getElementById('an_menu_parent_save_button');
|
||||
YAHOO.util.Event.addListener(an_menu_parent_save_button, 'click', function() {
|
||||
|
||||
var data = new Object();
|
||||
data.an_menu_parent = document.forms.anMenuEdit.an_menu_parent.value;
|
||||
data.an_menu_parent_phone = document.forms.anMenuEdit.an_menu_parent_phone.value;
|
||||
data.an_menu_parent_id = document.forms.anMenuEdit.an_menu_parent_id.value;
|
||||
data.an_menu_new_phone = document.forms.anMenuEdit.an_menu_new_phone.value;
|
||||
data.an_menu_update_records = document.forms.anMenuEdit.an_menu_update_records.value;
|
||||
|
||||
data.an_menu_ecmcall_record = document.forms.anMenuEdit.an_menu_ecmcall_record.value;
|
||||
data.an_menu_old_parent = document.forms.anMenuEdit.an_menu_old_parent.value;
|
||||
data.an_menu_old_parent_id = document.forms.anMenuEdit.an_menu_old_parent_id.value;
|
||||
data.an_menu_old_parent_phone = document.forms.anMenuEdit.an_menu_old_parent_phone.value;
|
||||
|
||||
data = JSON.stringifyNoSecurity(data);
|
||||
|
||||
var an_menu_parent = document.getElementById('an_menu_parent');
|
||||
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
'POST',
|
||||
'index.php',
|
||||
{
|
||||
success: function(results) {
|
||||
//alert('>'+results.responseText+'<');
|
||||
if(results.responseText) {
|
||||
var ampid = document.getElementById('an_menu_parent_id');
|
||||
if(results.responseText.indexOf(ampid.value) != -1) {
|
||||
alert('{MOD.LBL_ASSIGN_MENU_SAVE_SUCCESS}');
|
||||
anMenuClose();
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
},
|
||||
failure: function(results) { alert('{MOD.LBL_ASSIGN_MENU_SAVE_FAILURE}'); }
|
||||
},
|
||||
'module=EcmCalls&action=AnMenu&anMenuAction=Save&to_pdf=1&an_menu_data='+data
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
setInterval(anMenuParentIdChange,500);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<!-- END: main -->
|
||||
1
modules/EcmCalls/anMenu/anMenu.js
Executable file
1
modules/EcmCalls/anMenu/anMenu.js
Executable file
@@ -0,0 +1 @@
|
||||
// JavaScript Document
|
||||
100
modules/EcmCalls/anMenu/anMenu.php
Executable file
100
modules/EcmCalls/anMenu/anMenu.php
Executable file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
require_once("XTemplate/xtpl.php");
|
||||
|
||||
class anMenu {
|
||||
|
||||
var $xtpl = 'modules/EcmCalls/anMenu/anMenu.html';
|
||||
|
||||
function trimColon($str) {
|
||||
$pos = strrpos($str,':');
|
||||
if($pos == strlen($str)-1) $str = substr($str,0,$pos);
|
||||
return $str;
|
||||
}
|
||||
|
||||
function getParentOptions() {
|
||||
global $app_list_strings, $mod_strings;
|
||||
|
||||
$arr = array(
|
||||
'Accounts' => $app_list_strings['moduleList']['Accounts'],
|
||||
'Contacts' => $app_list_strings['moduleList']['Contacts'],
|
||||
'Users' => translate("LBL_PARENT_FROM", "EcmCalls"),//$app_list_strings['moduleList']['Users'],
|
||||
);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getBeanSelect($bean_module, $bean_name, $bean_id) {
|
||||
$arr = array();
|
||||
$file = "modules/$bean_module/$bean_name.php";
|
||||
if(file_exists($file)) {
|
||||
|
||||
require_once($file);
|
||||
$focus = new $bean_name();
|
||||
$focus->retrieve($bean_id);
|
||||
|
||||
foreach($focus->field_defs as $name => $value) {
|
||||
if($value['type'] == "phone" || strpos($name,"phone_") === 0)
|
||||
$arr[$name] = $this->formatNumerName(translate($value['vname'], $bean_module), $focus->$name);
|
||||
}
|
||||
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getAccountsSelectJSON($parent_id = '') {
|
||||
return '<select id="an_menu_parent_phone" name="an_menu_parent_phone">'.get_select_options_with_id($this->getBeanSelect("Accounts", "Account", $parent_id),'').'</select>';
|
||||
}
|
||||
|
||||
function getUsersSelectJSON($parent_id = '') {
|
||||
return '<select id="an_menu_parent_phone" name="an_menu_parent_phone">'.get_select_options_with_id($this->getBeanSelect("Users", "User", $parent_id),'').'</select>';
|
||||
}
|
||||
|
||||
function getContactsSelectJSON($parent_id = '') {
|
||||
return '<select id="an_menu_parent_phone" name="an_menu_parent_phone">'.get_select_options_with_id($this->getBeanSelect("Contacts", "Contact", $parent_id),'').'</select>';
|
||||
}
|
||||
|
||||
|
||||
function formatNumerName($label,$number = '') {
|
||||
$str = $this->trimColon($label);
|
||||
if(isset($number) && $number != '') $str .= ' -> '.$number;
|
||||
return $str;
|
||||
}
|
||||
|
||||
function SavePhone($amd) {
|
||||
global $beanList, $beanFiles;
|
||||
$bean = $beanList[$amd['an_menu_parent']];
|
||||
$path = $beanFiles[$bean];
|
||||
if(file_exists($path)) {
|
||||
require_once($path);
|
||||
$focus = new $bean();
|
||||
$focus->retrieve($amd['an_menu_parent_id']);
|
||||
$focus->EcmCallInfo = array(
|
||||
'update_records' => $amd['an_menu_update_records'],
|
||||
'old_parent' => $amd['an_menu_old_parent'],
|
||||
'old_parent_id' => $amd['an_menu_old_parent_id'],
|
||||
'old_parent_phone' => $amd['an_menu_old_parent_phone'],
|
||||
'ecmcall_record' => $amd['an_menu_ecmcall_record'],
|
||||
'parent_phone' => $amd['an_menu_parent_phone']
|
||||
);
|
||||
if(isset($focus->id) && $focus->id != '') {
|
||||
$focus->$amd['an_menu_parent_phone'] = $amd['an_menu_new_phone'];
|
||||
$focus->save();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function display() {
|
||||
global $mod_strings, $app_strings, $current_language, $app_list_strings;
|
||||
$xtpl = new XTemplate ($this->xtpl);
|
||||
$xtpl->assign("MOD", return_module_language($current_language, 'EcmCalls'));
|
||||
$xtpl->assign("APP", $app_strings);
|
||||
$xtpl->assign("AN_MENU_PARENT_OPTIONS", get_select_options_with_id($this->getParentOptions(),''));
|
||||
$xtpl->assign("AN_MENU_PARENT_PHONES_OPTIONS", $this->getAccountsSelectJSON());
|
||||
$xtpl->assign("AN_MENU_UPDATE_RECORDS_OPTIONS", get_select_options_with_id($app_list_strings['calls_update_records_dom'],''));
|
||||
$xtpl->parse("main");
|
||||
$xtpl->out("main");
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user