init
This commit is contained in:
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