[Vtigercrm-developers] Select queries

John Crisp john at reetspetit.net
Tue Mar 2 05:11:54 PST 2010


I have been asking about this in the forums with no joy. I wondered if
there was someone who could give me a pointer !

http://forums.vtiger.com/viewtopic.php?p=102142


I'm trying to hack the PDF Configurator so that the P.O. displays both a
billing address (Ours - not the customers, which is useless) and the
shipping address

I'm actually stuck on how to query the account.id from the contact.id to
get the correct Account name for a Contact to add to the shipping address


If I use phpmyadmin with the following statement, I can get the Account Name

select accountname from vtiger_account, vtiger_contactdetails where
vtiger_account.accountid = vtiger_contactdetails.accountid and
vtiger_contactdetails.contactid = 28610

In the PDF creator there is the following code which I think gets the PO
information :


	$sql="select vtiger_currency_info.currency_symbol from
vtiger_currency_info inner join vtiger_users on vtiger_users.currency_id
=vtiger_currency_info.id where vtiger_users.id= ".$current_user->id;
	$result = $adb->query($sql);
	$currency_symbol = $adb->query_result($result,0,'currency_symbol');

	//internal number
	$id = $idnumber;

	//retreiving the PO info
	$focus = new PurchaseOrder();
	$focus->retrieve_entity_info($id,'PurchaseOrder');
	$vendor_name = getVendorName($focus->column_fields['vendor_id']);
	$vendor_id = $focus->column_fields['vendor_id'];
	$carriername = $focus->column_fields['carrier'];
	$PurchaseOrder_no = $focus->column_fields['purchaseorder_no'];
	//get the PO date set
	$date_to_display_array = array (str_replace
("-",".",getDisplayDate(date("Y-m-d"))));
	$date_created = getDisplayDate($focus->column_fields['createdtime']);
	$date_array = explode(" ",$date_created);
	$date_to_display_array[1] = str_replace ("-",".",$date_array[0]);
	$date_modified = getDisplayDate($focus->column_fields['modifiedtime']);
	$date_array = explode(" ",$date_modified);
	$date_to_display_array[2] = str_replace ("-",".",$date_array[0]);
	$date_to_display = $date_to_display_array[$pdf_config_details['dateused']];




// I have added the following :
$myctc_id = $focus->column_fields['contact_id'];


I then added this to try and find the Account Name, but I just get a blank.

$sql = "select accountname from vtiger_account, vtiger_contactdetails
where vtiger_account.accountid = vtiger_contactdetails.accountid and
vtiger_contactdetails.contactid =".$myctc_id;
   $result = $adb->query($sql);
   $the_acct_name = $adb->query_result($result,0,'accountname');

Anyone have any ideas how I can get the Account name ??



More information about the vtigercrm-developers mailing list