$focus->column_fields['from_email'] = $emltpl[3]; } } setObjectValuesFromRequest($focus); $focus->mode = ''; } elseif (!empty($_REQUEST['invmodid'])) { $crmid = vtlib_purify($_REQUEST['invmodid']); switch (getSalesEntityType($crmid)) { case 'PurchaseOrder': $rs = $adb->pquery('select case vendorid when 0 then contactid else vendorid end from vtiger_purchaseorder where purchaseorderid=?', array($crmid)); $emailcrmid = $adb->query_result($rs, 0, 0); break; default: $emailcrmid = getRelatedAccountContact($crmid, 'Accounts'); if ($emailcrmid == 0) { $emailcrmid = getRelatedAccountContact($crmid, 'Contacts'); } break; } $pmodule = getSalesEntityType($emailcrmid); switch ($pmodule) { case 'Accounts': $_REQUEST["field_lists"] = 9; break; case 'Contacts': $_REQUEST["field_lists"] = 80; break; case 'Vendors': $_REQUEST["field_lists"] = 292; break; }
function AccountContactRelatedisPermitted($module, $actionname, $record_id = '') { global $adb, $current_user; if ($record_id == '') { // permission on module so we just return what has already been calculated return 'no'; } $ret = 'no'; // get related account/contact $acid = getRelatedAccountContact($record_id); if (!empty($acid)) { $acownerrs = $adb->pquery('select smownerid from vtiger_crmentity where crmid=? and deleted=0', array($acid)); if ($acownerrs and $adb->num_rows($acownerrs) > 0) { $owner = $adb->query_result($acownerrs, 0, 0); if ($owner == $current_user->id) { $ret = 'yes'; } } } return $ret; }
<?php // Turn on debugging level $Vtiger_Utils_Log = true; include_once 'vtlib/Vtiger/Module.php'; global $current_user, $adb; set_time_limit(0); ini_set('memory_limit', '1024M'); $current_user = Users::getActiveAdminUser(); $recs = $adb->query('SELECT crmid,setype FROM `vtiger_crmentity` where deleted=0 group by setype'); echo "<table border=1 width='80%' align='center'><tr><th>EntityID</th><th>Related Account</th><th>Related Contact</th></tr>"; while ($rec = $adb->fetch_row($recs)) { echo "<tr>"; echo "<td><a href='index.php?module=" . $rec['setype'] . "&action=DetailView&record=" . $rec['crmid'] . "'>" . $rec['crmid'] . ' (' . $rec['setype'] . ') </a></td>'; $a = getRelatedAccountContact($rec['crmid'], 'Accounts'); echo "<td align='center'>"; if ($a) { echo "<a href='index.php?module=Accounts&action=DetailView&record={$a}'>" . $a . '</a>'; } else { echo "-"; } echo "</td>"; $c = getRelatedAccountContact($rec['crmid'], 'Contacts'); echo "<td align='center'>"; if ($c) { echo "<a href='index.php?module=Contacts&action=DetailView&record={$c}'>" . $c . '</a>'; } else { echo "-"; } echo "</td>"; echo "</tr>"; }