主题:[讨论]我在用一套PHP的开源CRM客户系统,有个关于重复的小问题。
我在用一套PHP的CRM客户系统,开源的,sugarcrm,不是广告,因为对PHP我是新手,所以使用中有个问题,关于重复的,不会修改,请哪位朋友有空看下或指点下PHP如何判断重复数据。我可以提供所有文件。。。请加我QQ:284841839
默认是在“我的客户”里对重复的客户名称有重复提醒,我想找到程序里哪控制的,想修改其他栏目里也有这个重复提醒功能。。。。
有关文件应该是Account.php,AccountFormBase.php,ShowDuplicates.php,ShowDuplicates.html,
ShowDuplicates.html
<!--
/******************************
* {APP.LBL_CURRENCY_SYM}Header: /cvsroot/sugarcrm/sugarcrm/modules/Contacts/EditView.html,v 1.22 2004/07/16 04:04:42 sugarclint Exp {APP.LBL_CURRENCY_SYM}
*******************************************/
-->
<!-- BEGIN: main -->
<!-- BEGIN: error -->
<span class="color">{ERROR}</span>
<!-- END: error -->
<form action='index.php' method='post' name='Save'>
<input type="hidden" name="module" value="Accounts">
<input type="hidden" name="action" value="Save">
<input type="hidden" name="return_module" value="{RETURN_MODULE}">
<input type="hidden" name="return_action" value="{RETURN_ACTION}">
<input type="hidden" name="return_id" value="{RETURN_ID}">
<input type="hidden" name="dup_checked" value="true">
{INPUT_FIELDS}
<p> <table class='{TABLECLASS}' cellpadding="0" cellspacing="0" width="100%" border="0" >
<tr><td>
<table cellpadding="0" cellspacing="0" width="100%" border="0" >
<tr ><td valign='top' align='left' border='0' class="{CLASS}"><h4 class="{CLASS}">{FORMHEADER}</h4></td></tr>
<tr><td valign='top' align='left'>{FORMBODY}{FORMFOOTER}{POSTFORM}</td></tr>
</table>
</td>
</tr>
</table>
</p>
<!-- END: main -->
ShowDuplicates.php
<?php
if(empty($GLOBALS['sugarEntry'])) die('Not A Valid Entry Point');
global $app_strings;
global $app_list_strings;
global $theme;
require_once('XTemplate/xtpl.php');
$error_msg = '';
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
require_once($theme_path.'layout_utils.php');
global $current_language;
$mod_strings = return_module_language($current_language, 'Accounts');
echo "\n<p>\n";
echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'].": ".$mod_strings['LBL_SAVE_ACCOUNT'], true);
echo "\n</p>\n";
$xtpl=new XTemplate ('modules/Accounts/ShowDuplicates.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$xtpl->assign("IMAGE_PATH", $image_path);$xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
$xtpl->assign("MODULE", $_REQUEST['module']);
if ($error_msg != '')
{
$xtpl->assign("ERROR", $error_msg);
$xtpl->parse("main.error");
}
if(isset($_REQUEST['popup']) && $_REQUEST['popup'] == 'true') insert_popup_header($theme);
require_once('modules/Accounts/Account.php');
$account = new Account();
require_once('modules/Accounts/AccountFormBase.php');
$accountForm = new AccountFormBase();
$GLOBALS['check_notify'] = FALSE;
$query = 'select id, name, website, billing_address_city from accounts where deleted=0 ';
$duplicates = $_GET['duplicate'];
$count = count($duplicates);
if ($count > 0)
{
$query .= "and (";
$first = true;
foreach ($duplicates as $duplicate_id)
{
if (!$first) $query .= ' OR ';
$first = false;
$query .= "id='$duplicate_id' ";
}
$query .= ')';
}
$duplicateAccounts = array();
require_once('include/database/PearDatabase.php');
$db = & PearDatabase::getInstance();
$result = $db->query($query);
$i=-1;
while(($row=$db->fetchByAssoc($result)) != null) {
$i++;
$duplicateAccounts[$i] = $row;
}
$xtpl->assign('FORMBODY', $accountForm->buildTableForm($duplicateAccounts, 'Accounts'));
$input = '';
foreach ($account->column_fields as $field)
{
if (!empty($_GET['Accounts'.$field])) {
$input .= "<input type='hidden' name='$field' value='${_GET['Accounts'.$field]}'>\n";
}
}
foreach ($account->additional_column_fields as $field)
{
if (!empty($_GET['Accounts'.$field])) {
$input .= "<input type='hidden' name='$field' value='${_GET['Accounts'.$field]}'>\n";
}
}
$get = '';
if(!empty($_GET['return_module'])) $xtpl->assign('RETURN_MODULE', $_GET['return_module']);
else $get .= "Accounts";
$get .= "&return_action=";
if(!empty($_GET['return_action'])) $xtpl->assign('RETURN_ACTION', $_GET['return_action']);
else $get .= "DetailView";
if(!empty($_GET['return_id'])) $xtpl->assign('RETURN_ID', $_GET['return_id']);
if(!empty($_GET['popup']))
$input .= '<input type="hidden" name="popup" value="'.$_GET['popup'].'">';
else
$input .= '<input type="hidden" name="popup" value="false">';
if(!empty($_GET['to_pdf']))
$input .= '<input type="hidden" name="to_pdf" value="'.$_GET['to_pdf'].'">';
else
$input .= '<input type="hidden" name="to_pdf" value="false">';
if(!empty($_GET['create']))
$input .= '<input type="hidden" name="create" value="'.$_GET['create'].'">';
else
$input .= '<input type="hidden" name="create" value="false">';
$xtpl->assign('INPUT_FIELDS',$input);
$xtpl->parse('main');
$xtpl->out('main');
?>
默认是在“我的客户”里对重复的客户名称有重复提醒,我想找到程序里哪控制的,想修改其他栏目里也有这个重复提醒功能。。。。
有关文件应该是Account.php,AccountFormBase.php,ShowDuplicates.php,ShowDuplicates.html,
ShowDuplicates.html
<!--
/******************************
* {APP.LBL_CURRENCY_SYM}Header: /cvsroot/sugarcrm/sugarcrm/modules/Contacts/EditView.html,v 1.22 2004/07/16 04:04:42 sugarclint Exp {APP.LBL_CURRENCY_SYM}
*******************************************/
-->
<!-- BEGIN: main -->
<!-- BEGIN: error -->
<span class="color">{ERROR}</span>
<!-- END: error -->
<form action='index.php' method='post' name='Save'>
<input type="hidden" name="module" value="Accounts">
<input type="hidden" name="action" value="Save">
<input type="hidden" name="return_module" value="{RETURN_MODULE}">
<input type="hidden" name="return_action" value="{RETURN_ACTION}">
<input type="hidden" name="return_id" value="{RETURN_ID}">
<input type="hidden" name="dup_checked" value="true">
{INPUT_FIELDS}
<p> <table class='{TABLECLASS}' cellpadding="0" cellspacing="0" width="100%" border="0" >
<tr><td>
<table cellpadding="0" cellspacing="0" width="100%" border="0" >
<tr ><td valign='top' align='left' border='0' class="{CLASS}"><h4 class="{CLASS}">{FORMHEADER}</h4></td></tr>
<tr><td valign='top' align='left'>{FORMBODY}{FORMFOOTER}{POSTFORM}</td></tr>
</table>
</td>
</tr>
</table>
</p>
<!-- END: main -->
ShowDuplicates.php
<?php
if(empty($GLOBALS['sugarEntry'])) die('Not A Valid Entry Point');
global $app_strings;
global $app_list_strings;
global $theme;
require_once('XTemplate/xtpl.php');
$error_msg = '';
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
require_once($theme_path.'layout_utils.php');
global $current_language;
$mod_strings = return_module_language($current_language, 'Accounts');
echo "\n<p>\n";
echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'].": ".$mod_strings['LBL_SAVE_ACCOUNT'], true);
echo "\n</p>\n";
$xtpl=new XTemplate ('modules/Accounts/ShowDuplicates.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$xtpl->assign("IMAGE_PATH", $image_path);$xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
$xtpl->assign("MODULE", $_REQUEST['module']);
if ($error_msg != '')
{
$xtpl->assign("ERROR", $error_msg);
$xtpl->parse("main.error");
}
if(isset($_REQUEST['popup']) && $_REQUEST['popup'] == 'true') insert_popup_header($theme);
require_once('modules/Accounts/Account.php');
$account = new Account();
require_once('modules/Accounts/AccountFormBase.php');
$accountForm = new AccountFormBase();
$GLOBALS['check_notify'] = FALSE;
$query = 'select id, name, website, billing_address_city from accounts where deleted=0 ';
$duplicates = $_GET['duplicate'];
$count = count($duplicates);
if ($count > 0)
{
$query .= "and (";
$first = true;
foreach ($duplicates as $duplicate_id)
{
if (!$first) $query .= ' OR ';
$first = false;
$query .= "id='$duplicate_id' ";
}
$query .= ')';
}
$duplicateAccounts = array();
require_once('include/database/PearDatabase.php');
$db = & PearDatabase::getInstance();
$result = $db->query($query);
$i=-1;
while(($row=$db->fetchByAssoc($result)) != null) {
$i++;
$duplicateAccounts[$i] = $row;
}
$xtpl->assign('FORMBODY', $accountForm->buildTableForm($duplicateAccounts, 'Accounts'));
$input = '';
foreach ($account->column_fields as $field)
{
if (!empty($_GET['Accounts'.$field])) {
$input .= "<input type='hidden' name='$field' value='${_GET['Accounts'.$field]}'>\n";
}
}
foreach ($account->additional_column_fields as $field)
{
if (!empty($_GET['Accounts'.$field])) {
$input .= "<input type='hidden' name='$field' value='${_GET['Accounts'.$field]}'>\n";
}
}
$get = '';
if(!empty($_GET['return_module'])) $xtpl->assign('RETURN_MODULE', $_GET['return_module']);
else $get .= "Accounts";
$get .= "&return_action=";
if(!empty($_GET['return_action'])) $xtpl->assign('RETURN_ACTION', $_GET['return_action']);
else $get .= "DetailView";
if(!empty($_GET['return_id'])) $xtpl->assign('RETURN_ID', $_GET['return_id']);
if(!empty($_GET['popup']))
$input .= '<input type="hidden" name="popup" value="'.$_GET['popup'].'">';
else
$input .= '<input type="hidden" name="popup" value="false">';
if(!empty($_GET['to_pdf']))
$input .= '<input type="hidden" name="to_pdf" value="'.$_GET['to_pdf'].'">';
else
$input .= '<input type="hidden" name="to_pdf" value="false">';
if(!empty($_GET['create']))
$input .= '<input type="hidden" name="create" value="'.$_GET['create'].'">';
else
$input .= '<input type="hidden" name="create" value="false">';
$xtpl->assign('INPUT_FIELDS',$input);
$xtpl->parse('main');
$xtpl->out('main');
?>