You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

213 lines
10 KiB

<?php
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is: SugarCRM Open Source
* The Initial Developer of the Original Code is SugarCRM, Inc.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
********************************************************************************/
/*********************************************************************************
* $Header: vtiger_crm/sugarcrm/modules/Cases/Popup.php,v 1.2 2004/10/06 09:02:05 jack Exp $
* Description: This file is used for all popups on this module
* The popup_picker.html file is used for generating a list from which to find and
* choose one instance.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
global $theme;
require_once('modules/Cases/Case.php');
require_once('themes/'.$theme.'/layout_utils.php');
require_once('include/logging.php');
require_once('XTemplate/xtpl.php');
require_once('include/utils.php');
require_once('include/ListView/ListView.php');
global $app_strings;
global $app_list_strings;
global $mod_strings;
global $list_max_entries_per_page;
global $urlPrefix;
global $currentModule;
$log = LoggerManager::getLogger('case');
$seed_object = new aCase();
$where = "";
if(isset($_REQUEST['query']))
{
$search_fields = Array("name", "account_name", "number");
$where_clauses = Array();
append_where_clause($where_clauses, "name", "cases.name");
append_where_clause($where_clauses, "number", "cases.number");
append_where_clause($where_clauses, "account_name", "accounts.name");
$where = generate_where_statement($where_clauses);
}
$image_path = 'themes/'.$theme.'/images';
////////////////////////////////////////////////////////
// Start the output
////////////////////////////////////////////////////////
if (!isset($_REQUEST['html'])) {
$form =new XTemplate ('modules/Cases/Popup_picker.html');
$log->debug("using file modules/Cases/Popup_picker.html");
}
else {
$log->debug("_REQUEST['html'] is ".$_REQUEST['html']);
$form =new XTemplate ('modules/Cases/'.$_REQUEST['html'].'.html');
$log->debug("using file modules/Cases/".$_REQUEST['html'].'.html');
}
$form->assign("MOD", $mod_strings);
$form->assign("APP", $app_strings);
// the form key is required
if(!isset($_REQUEST['form']))
die("Missing 'form' parameter");
// This code should always return an answer.
// The form name should be made into a parameter and not be hard coded in this file.
if($_REQUEST['form'] == 'EditView')
{
$the_javascript = "<script type='text/javascript' language='JavaScript'>\n";
$the_javascript .= "function set_return(case_id, case_name) {\n";
$the_javascript .= " window.opener.document.EditView.case_name.value = case_name;\n";
$the_javascript .= " window.opener.document.EditView.case_id.value = case_id;\n";
$the_javascript .= "}\n";
$the_javascript .= "</script>\n";
$button = "<table cellspacing='0' cellpadding='1' border='0'><form border='0' action='index.php' method='post' name='form' id='form'>\n";
$button .= "<tr><td>&nbsp;</td>";
$button .= "<td><input title='".$app_strings['LBL_CLEAR_BUTTON_TITLE']."' accessyKey='".$app_strings['LBL_CLEAR_BUTTON_KEY']."' class='button' LANGUAGE=javascript onclick=\"window.opener.document.EditView.account_name.value = '';window.opener.document.EditView.account_id.value = ''; window.close()\" type='submit' name='button' value=' Clear '>\n";
$button .= "<td><input title='".$app_strings['LBL_CANCEL_BUTTON_TITLE']."' accessyKey='".$app_strings['LBL_CANCEL_BUTTON_KEY']."' class='button' LANGUAGE=javascript onclick=\"window.close()\" type='submit' name='button' value=' ".$app_strings['LBL_CANCEL_BUTTON_LABEL']." '>\n";
$button .= "</td></tr></form></table>\n";
}
elseif(isset($_REQUEST['form_submit']) && $_REQUEST['form'] == 'DetailView' && $_REQUEST['form_submit'] == 'true')
{
$the_javascript = "<script type='text/javascript' language='JavaScript'>\n";
$the_javascript .= "function set_return(case_id, account_name) {\n";
$the_javascript .= " window.opener.document.DetailView.case_id.value = case_id; \n";
$the_javascript .= " window.opener.document.DetailView.return_module.value = window.opener.document.DetailView.module.value; \n";
$the_javascript .= " window.opener.document.DetailView.return_action.value = 'DetailView'; \n";
$the_javascript .= " window.opener.document.DetailView.return_id.value = window.opener.document.DetailView.record.value; \n";
$the_javascript .= " window.opener.document.DetailView.action.value = 'Save'; \n";
$the_javascript .= " window.opener.document.DetailView.submit(); \n";
$the_javascript .= "}\n";
$the_javascript .= "</script>\n";
$button = "<table cellspacing='0' cellpadding='1' border='0'><form border='0' action='index.php' method='post' name='form' id='form'>\n";
$button .= "<tr><td>&nbsp;</td>";
$button .= "<td><input title='".$app_strings['LBL_CANCEL_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_CANCEL_BUTTON_KEY']."' class='button' LANGUAGE=javascript onclick=\"window.close()\" type='submit' name='button' value=' ".$app_strings['LBL_CANCEL_BUTTON_LABEL']." '>\n";
$button .= "</tr></form></table>\n";
}
elseif(isset($_REQUEST['form_submit']) && $_REQUEST['form'] == 'ContactDetailView' && $_REQUEST['form_submit'] == 'true')
{
$the_javascript = "<script type='text/javascript' language='JavaScript'>\n";
$the_javascript .= "function set_return(case_id, case_name) {\n";
$the_javascript .= " window.opener.document.DetailView.case_id.value = case_id; \n";
$the_javascript .= " window.opener.document.DetailView.contact_role.value = '".$app_list_strings['case_relationship_type_default_key']."'; \n";
$the_javascript .= " window.opener.document.DetailView.return_module.value = window.opener.document.DetailView.module.value; \n";
$the_javascript .= " window.opener.document.DetailView.return_action.value = 'DetailView'; \n";
$the_javascript .= " window.opener.document.DetailView.return_id.value = window.opener.document.DetailView.record.value; \n";
$the_javascript .= " window.opener.document.DetailView.module.value = 'Cases'; \n";
$the_javascript .= " window.opener.document.DetailView.action.value = 'SaveContactCaseRelationship'; \n";
$the_javascript .= " window.opener.document.DetailView.submit(); \n";
$the_javascript .= "}\n";
$the_javascript .= "</script>\n";
$button = "<table cellspacing='0' cellpadding='1' border='0'><form border='0' action='index.php' method='post' name='form' id='form'>\n";
$button .= "<tr><td>&nbsp;</td>";
$button .= "<td><input title='".$app_strings['LBL_CANCEL_BUTTON_TITLE']."' accessyKey='".$app_strings['LBL_CANCEL_BUTTON_KEY']."' class='button' LANGUAGE=javascript onclick=\"window.close()\" type='submit' name='button' value=' ".$app_strings['LBL_CANCEL_BUTTON_LABEL']." '>\n";
$button .= "</td></tr></form></table>\n";
}
elseif ($_REQUEST['form'] == 'TasksEditView')
{
$the_javascript = "<script type='text/javascript' language='JavaScript'>\n";
$the_javascript .= "function set_return(case_id, case_name) {\n";
$the_javascript .= " window.opener.document.EditView.parent_name.value = case_name;\n";
$the_javascript .= " window.opener.document.EditView.parent_id.value = case_id;\n";
$the_javascript .= "}\n";
$the_javascript .= "</script>\n";
$button = "<table cellspacing='0' cellpadding='1' border='0'><form border='0' action='index.php' method='post' name='form' id='form'>\n";
$button .= "<tr><td>&nbsp;</td>";
$button .= "<td><input title='".$app_strings['LBL_CLEAR_BUTTON_TITLE']."' accessyKey='".$app_strings['LBL_CLEAR_BUTTON_KEY']."' class='button' LANGUAGE=javascript onclick=\"window.opener.document.EditView.parent_name.value = '';window.opener.document.EditView.parent_id.value = ''; window.close()\" type='submit' name='button' value=' Clear '>\n";
$button .= "<td><input title='".$app_strings['LBL_CANCEL_BUTTON_TITLE']."' accessyKey='".$app_strings['LBL_CANCEL_BUTTON_KEY']."' class='button' LANGUAGE=javascript onclick=\"window.close()\" type='submit' name='button' value=' ".$app_strings['LBL_CANCEL_BUTTON_LABEL']." '>\n";
$button .= "</td></tr></form></table>\n";
}
$form->assign("SET_RETURN_JS", $the_javascript);
$form->assign("THEME", $theme);
$form->assign("IMAGE_PATH", $image_path);
$form->assign("MODULE_NAME", $currentModule);
if (isset($_REQUEST['form_submit'])) $form->assign("FORM_SUBMIT", $_REQUEST['form_submit']);
$form->assign("FORM", $_REQUEST['form']);
if (isset($_REQUEST['number']))
{
$form->assign("NUMBER", $_REQUEST['number']);
}
if (isset($_REQUEST['name']))
{
$form->assign("NAME", $_REQUEST['name']);
}
if (isset($_REQUEST['account_name']))
{
$form->assign("ACCOUNT_NAME", $_REQUEST['account_name']);
}
insert_popup_header($theme);
// Quick search.
echo "<form>";
echo get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], "", false);
$form->parse("main.SearchHeader");
$form->out("main.SearchHeader");
echo get_form_footer();
$form->parse("main.SearchHeaderEnd");
$form->out("main.SearchHeaderEnd");
// Reset the sections that are already in the page so that they do not print again later.
$form->reset("main.SearchHeader");
$form->reset("main.SearchHeaderEnd");
$ListView = new ListView();
$ListView->setXTemplate($form);
$ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']);
$ListView->setHeaderText($button);
$ListView->setQuery($where, "", "name", "CASE");
$ListView->setModStrings($mod_strings);
$ListView->processListView($seed_object, "main", "CASE");
?>
<tr><td COLSPAN=7><?php echo get_form_footer(); ?></td></tr>
</form>
</table>
</td></tr></tbody></table>
</td></tr>
<?php insert_popup_footer(); ?>