[Vtigercrm-developers] VT5.4.0 modules/Accounts/DetailViewAjax.php

Alan Lord alanslists at gmail.com
Wed Feb 12 11:34:06 GMT 2014


Why does the accountname dupe test occur twice?

> if($ajaxaction == "DETAILVIEW")
> {
>      $crmid = $_REQUEST["recordid"];
>      $tablename = $_REQUEST["tableName"];
>      $fieldname = $_REQUEST["fldName"];
>      $fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]);
>      if($crmid != "")
> 	 {
> 	     $modObj->retrieve_entity_info($crmid,"Accounts");
> 	     $modObj->column_fields[$fieldname] = $fieldvalue;
> 	     if($fieldname=='accountname'){
> 	     	$value = $fieldvalue;
> 			$query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname =? and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1";
> 			$params = array($value);
> 			if(isset($crmid) && $crmid !='') {
> 				$query .= " and vtiger_account.accountid != ?";
> 				array_push($params, $crmid);
> 			}
> 			$result = $adb->pquery($query, $params);
> 		    if($adb->num_rows($result) > 0)
> 			{
> 				echo ":#:ERR".$mod_strings['LBL_ACCOUNT_EXIST'];
> 				return false;
> 			}
> 	     }
> 	     if($fieldname=='accountname'){
> 	     	$value = $fieldvalue;
> 			$query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname =? and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1";
> 			$params = array($value);
> 			if(isset($crmid) && $crmid !='') {
> 				$query .= " and vtiger_account.accountid != ?";
> 				array_push($params, $crmid);
> 			}
> 			$result = $adb->pquery($query, $params);
> 		    if($adb->num_rows($result) > 0)
> 			{
> 				echo ":#:ERR".$mod_strings['LBL_ACCOUNT_EXIST'];
> 				return false;
> 			}
> 	     }


The 2nd will either just waste resources by querying the database again 
or not run...

Or am I missing something?

Al




More information about the vtigercrm-developers mailing list