本文整理汇总了PHP中isRecordExists函数的典型用法代码示例。如果您正苦于以下问题:PHP isRecordExists函数的具体用法?PHP isRecordExists怎么用?PHP isRecordExists使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isRecordExists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
function process(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$records = $request->get('records');
$template = $request->get('template');
$targetModuleName = $request->get('target');
$method = $request->get('method');
$success = [];
if (!empty($template)) {
$templateRecord = Vtiger_MappedFields_Model::getInstanceById($template);
foreach ($records as $recordId) {
if ($templateRecord->checkFiltersForRecord(intval($recordId))) {
if ($method == 0) {
$recordModel = Vtiger_Record_Model::getCleanInstance($targetModuleName);
$parentRecordModel = Vtiger_Record_Model::getInstanceById($recordId);
$recordModel->setRecordFieldValues($parentRecordModel);
if ($this->checkMandatoryFields($recordModel)) {
continue;
}
// TODO Add saving fields that exist in advanced module
$recordModel->save();
if (isRecordExists($recordModel->getId())) {
$success[] = $recordId;
}
} else {
$success[] = $recordId;
}
}
}
}
$output = ['all' => count($records), 'ok' => $success, 'fail' => array_diff($records, $success)];
$response = new Vtiger_Response();
$response->setResult($output);
$response->emit();
}
示例2: updateProgressMilestone
public function updateProgressMilestone($id)
{
$adb = PearDatabase::getInstance();
//TODO need to handle security
if (!isRecordExists($id)) {
return;
}
$focus = CRMEntity::getInstance($this->getName());
$relatedListMileston = $focus->get_dependents_list($id, $this->getId(), getTabid('ProjectTask'));
$resultMileston = $adb->query($relatedListMileston['query']);
$num = $adb->num_rows($resultMileston);
$estimatedWorkTime = 0;
$progressInHours = 0;
for ($i = 0; $i < $num; $i++) {
$row = $adb->query_result_rowdata($resultMileston, $i);
$estimatedWorkTime += $row['estimated_work_time'];
$recordProgress = $row['estimated_work_time'] * (int) $row['projecttaskprogress'] / 100;
$progressInHours += $recordProgress;
}
if (!$estimatedWorkTime) {
return;
}
$projectMilestoneProgress = round(100 * $progressInHours / $estimatedWorkTime);
$focus->retrieve_entity_info($id, $this->getName());
$focus->column_fields['projectmilestone_progress'] = $projectMilestoneProgress . '%';
$focus->column_fields['mode'] = 'edit';
$focus->saveentity($this->getName(), $id);
}
示例3: initializeListViewContents
public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
{
$moduleName = $this->getModule($request);
$sourceModule = $request->get('src_module');
$sourceRecord = $request->get('src_record');
//list of records is narrowed to contacts related to help desks account, only in Help Desk Contacts relation view
if ($moduleName == 'Contacts' && $sourceModule == 'HelpDesk' && isRecordExists($sourceRecord) && strpos($_SERVER['QUERY_STRING'], 'module=Contacts&src_module=HelpDesk') === 0) {
$request->set('related_parent_module', 'Accounts');
$helpDeskRecord = Vtiger_Record_Model::getInstanceById($sourceRecord, 'HelpDesk');
$request->set('related_parent_id', $helpDeskRecord->get('parent_id'));
$viewer->assign('SWITCH', true);
}
if ($moduleName == 'Contacts' && $sourceModule == 'SSalesProcesses' && isRecordExists($sourceRecord) && strpos($_SERVER['QUERY_STRING'], 'module=Contacts&src_module=SSalesProcesses') === 0) {
$request->set('related_parent_module', 'Accounts');
$moduleRecord = Vtiger_Record_Model::getInstanceById($sourceRecord, 'SSalesProcesses');
$request->set('related_parent_id', $moduleRecord->get('related_to'));
$viewer->assign('SWITCH', true);
}
if ($moduleName == 'Contacts' && $sourceModule == 'Project' && isRecordExists($sourceRecord) && strpos($_SERVER['QUERY_STRING'], 'module=Contacts&src_module=Project') === 0) {
$request->set('related_parent_module', 'Accounts');
$moduleRecord = Vtiger_Record_Model::getInstanceById($sourceRecord, 'Project');
$request->set('related_parent_id', $moduleRecord->get('linktoaccountscontacts'));
$viewer->assign('SWITCH', true);
}
parent::initializeListViewContents($request, $viewer);
}
示例4: getComposeUrlParam
function getComposeUrlParam($moduleName = false, $record = false, $view = false)
{
$url = '';
if (!empty($record) && isRecordExists($record)) {
$recordModel_OSSMailView = Vtiger_Record_Model::getCleanInstance('OSSMailView');
$email = $recordModel_OSSMailView->findEmail($record, $moduleName);
if ($email) {
$url = '&to=' . $email;
}
$recordModel = Vtiger_Record_Model::getInstanceById($record, $moduleName);
if ($moduleName == 'HelpDesk') {
$urldata = '&subject=' . $recordModel->get('ticket_no') . ' - ' . $recordModel->get('ticket_title');
} elseif ($moduleName == 'SSalesProcesses') {
$urldata = '&subject=' . $recordModel->get('ssalesprocesses_no') . ' - ' . $recordModel->get('subject');
} elseif ($moduleName == 'Project') {
$urldata = '&subject=' . $recordModel->get('project_no') . ' - ' . $recordModel->get('projectname');
}
$url .= $urldata;
}
if (!empty($moduleName)) {
$url .= '&crmmodule=' . $moduleName;
}
if (!empty($record)) {
$url .= '&crmrecord=' . $record;
}
if (!empty($view)) {
$url .= '&crmview=' . $view;
}
return $url;
}
示例5: getValue
function getValue($fieldName, $relId, $templateId, $baseRecord = NULL, $parentTplId = NULL)
{
$val = parent::getValue($fieldName, $relId, $templateId, $baseRecord, $parentTplId);
if ('base_on_parent_module' === $val) {
if (isRecordExists($baseRecord)) {
return $baseRecord;
}
}
}
示例6: getValue
function getValue($fieldName, $relId, $templateId, $baseRecord = NULL, $parentTplId = NULL)
{
$val = parent::getValue($fieldName, $relId, $templateId, $baseRecord, $parentTplId);
if (isRecordExists($relId) && 'base_on_record' === $val) {
$recodeModel = Vtiger_Record_Model::getInstanceById($relId);
return $recodeModel->get('forecast_amount');
} else {
return '';
}
}
示例7: handleEvent
function handleEvent($eventName, $entityData)
{
$adb = PearDatabase::getInstance();
$log = vglobal('log');
if ($eventName == 'vtiger.entity.aftersave.final') {
$moduleName = $entityData->getModuleName();
if ($moduleName == 'HelpDesk') {
$ticketId = $entityData->getId();
$sql = 'UPDATE `vtiger_troubletickets` SET `from_portal` = 0 WHERE `ticketid` = ?';
$params = array($ticketId);
$adb->pquery($sql, $params);
}
} else {
if ($eventName == 'vtiger.entity.link.after') {
if ($entityData['destinationModule'] == 'Contacts' && $entityData['sourceModule'] == 'HelpDesk' && isRecordExists($entityData['destinationRecordId'])) {
$ticketId = $entityData['sourceRecordId'];
$contactId = $entityData['destinationRecordId'];
$log->debug("Entering HelpDeskHandler:vtiger.entity.link.after");
$ticketRecord = Vtiger_Record_Model::getInstanceById($ticketId, 'HelpDesk');
if ($ticketRecord->get('ticketstatus') == 'Closed') {
return true;
}
$mails = [];
if (isRecordExists($contactId)) {
$contactRecord = Vtiger_Record_Model::getInstanceById($contactId, 'Contacts');
$primaryEmail = $contactRecord->get('email');
$secondaryEmail = $contactRecord->get('secondary_email');
if ($contactRecord->get('emailoptout') == 1) {
if (!empty($primaryEmail)) {
$mails[] = $primaryEmail;
} else {
if (!empty($secondaryEmail)) {
$mails[] = $secondaryEmail;
}
}
}
}
if (count($mails) > 0) {
$mails = implode(',', $mails);
$data = array('id' => 39, 'to_email' => $mails, 'module' => 'HelpDesk', 'record' => $ticketId);
$recordModel = Vtiger_Record_Model::getCleanInstance('OSSMailTemplates');
$log->debug("HelpDeskHandler:vtiger.entity.link.after");
if ($recordModel->sendMailFromTemplate($data)) {
return true;
}
}
$log->debug("HelpDeskHandler:vtiger.entity.link.after");
return false;
}
}
}
}
示例8: process
function process(Vtiger_Request $request)
{
$productId = $request->get('record');
$values = [];
if (isRecordExists($productId)) {
$productModel = Vtiger_Record_Model::getInstanceById($productId);
$subProducts = $productModel->getSubProducts();
foreach ($subProducts as $subProduct) {
$values[$subProduct->getId()] = $subProduct->getName();
}
}
$response = new Vtiger_Response();
$response->setResult($values);
$response->emit();
}
示例9: getValue
function getValue($fieldName, $relId, $templateId, $baseRecord = NULL, $parentTplId = NULL)
{
$val = parent::getValue($fieldName, $relId, $templateId, $baseRecord, $parentTplId);
if ('none' === $val) {
return '';
} else {
if ('base_on_record' == $val) {
if (isRecordExists($relId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($relId);
return $recordModel->get('related_to');
} else {
return '';
}
} else {
return '';
}
}
}
示例10: HeldDeskClosedNotifyContacts
function HeldDeskClosedNotifyContacts($entityData)
{
$wsId = $entityData->getId();
$parts = explode('x', $wsId);
$entityId = $parts[1];
$log = vglobal('log');
$db = PearDatabase::getInstance();
$log->debug("Entering HeldDeskClosedNotifyContacts");
$mails = [];
$sql = 'SELECT `relcrmid` as contactid FROM `vtiger_crmentityrel` WHERE `module` = ? AND `relmodule` = ? AND `crmid` = ?;';
$params = array('HelpDesk', 'Contacts', $entityId);
$result = $db->pquery($sql, $params);
$num = $db->num_rows($result);
if ($num > 0) {
for ($i = 0; $i < $num; $i++) {
$contactId = $db->query_result($result, $i, 'contactid');
if (isRecordExists($contactId)) {
$contactRecord = Vtiger_Record_Model::getInstanceById($contactId, 'Contacts');
$primaryEmail = $contactRecord->get('email');
$secondaryEmail = $contactRecord->get('secondary_email');
if ($contactRecord->get('emailoptout') == 1) {
if (!empty($primaryEmail)) {
$mails[] = $primaryEmail;
} else {
if (!empty($secondaryEmail)) {
$mails[] = $secondaryEmail;
}
}
}
}
}
}
if (count($mails) > 0) {
$mails = implode(',', $mails);
$data = array('id' => 37, 'to_email' => $mails, 'module' => 'HelpDesk', 'record' => $entityId);
$recordModel = Vtiger_Record_Model::getCleanInstance('OSSMailTemplates');
$log->debug("HeldDeskClosedNotifyContacts");
if ($recordModel->sendMailFromTemplate($data)) {
return true;
}
}
$log->debug("HeldDeskClosedNotifyContacts");
return false;
}
示例11: handleEvent
function handleEvent($eventName, $entityData)
{
$adb = PearDatabase::getInstance();
$log = vglobal('log');
if ($eventName == 'vtiger.entity.aftersave.final') {
$moduleName = $entityData->getModuleName();
if ($moduleName == 'HelpDesk') {
$ticketId = $entityData->getId();
$sql = 'UPDATE `vtiger_troubletickets` SET `from_portal` = 0 WHERE `ticketid` = ?';
$adb->pquery($sql, [$ticketId]);
}
} else {
if ($eventName == 'vtiger.entity.link.after') {
if ($entityData['destinationModule'] == 'Contacts' && $entityData['sourceModule'] == 'HelpDesk' && isRecordExists($entityData['destinationRecordId'])) {
$ticketId = $entityData['sourceRecordId'];
$contactId = $entityData['destinationRecordId'];
$log->debug("Entering HelpDeskHandler:vtiger.entity.link.after");
$ticketRecord = Vtiger_Record_Model::getInstanceById($ticketId, 'HelpDesk');
if ($ticketRecord->get('ticketstatus') == 'Closed') {
return true;
}
$mail = false;
if (isRecordExists($contactId)) {
$contactRecord = Vtiger_Record_Model::getInstanceById($contactId, 'Contacts');
if ($contactRecord->get('emailoptout') == 1) {
$mail = $contactRecord->get('email');
}
}
if ($mail) {
$data = ['sysname' => 'NotifyContactOnTicketCreate', 'to_email' => $mail, 'module' => 'HelpDesk', 'record' => $ticketId];
$recordModel = Vtiger_Record_Model::getCleanInstance('OSSMailTemplates');
if ($recordModel->sendMailFromTemplate($data)) {
$log->debug('HelpDeskHandler:vtiger.entity.link.after');
return true;
}
}
$log->debug('HelpDeskHandler:vtiger.entity.link.after');
return false;
}
}
}
}
示例12: getActiveTemplatesForRecord
public function getActiveTemplatesForRecord($recordId, $view, $moduleName = false)
{
$log = vglobal('log');
$log->debug('Entering ' . __CLASS__ . '::' . __METHOD__ . '(' . $recordId . ',' . $view . ',' . $moduleName . ') method ...');
if (!isRecordExists($recordId)) {
$log->debug('Exiting ' . __CLASS__ . '::' . __METHOD__ . ' method ...');
return [];
}
if (!$moduleName) {
$moduleName = Vtiger_Functions::getCRMRecordType($recordId);
}
$templates = $this->getTemplatesByModule($moduleName);
foreach ($templates as $id => &$template) {
if (!$template->checkFiltersForRecord($recordId) || !$template->checkUserPermissions() || !Users_Privileges_Model::isPermitted($template->getRelatedName(), 'EditView')) {
unset($templates[$id]);
}
}
$log->debug('Exiting ' . __CLASS__ . '::' . __METHOD__ . ' method ...');
return $templates;
}
示例13: getContactsMailsFromTicket
function getContactsMailsFromTicket($id)
{
if (empty($id)) {
return [];
}
$db = PearDatabase::getInstance();
$mails = [];
$sql = 'SELECT `relcrmid` as contactid FROM `vtiger_crmentityrel` WHERE `module` = ? AND `relmodule` = ? AND `crmid` = ?;';
$result = $db->pquery($sql, ['HelpDesk', 'Contacts', $id]);
$num = $db->num_rows($result);
while ($contactId = $db->getSingleValue($result)) {
if (isRecordExists($contactId)) {
$contactRecord = Vtiger_Record_Model::getInstanceById($contactId, 'Contacts');
$primaryEmail = $contactRecord->get('email');
if ($contactRecord->get('emailoptout') == 1 && !empty($primaryEmail)) {
$mails[] = $primaryEmail;
}
}
}
return $mails;
}
示例14: UpdatePotential
function UpdatePotential($potentialId)
{
if (!isRecordExists($potentialId) || Vtiger_Functions::getCRMRecordType($potentialId) != 'Potentials') {
return false;
}
$db = PearDatabase::getInstance();
$potentialTotal = 0;
$paymentsIn = 0;
$paymentsOut = 0;
$sql = 'SELECT SUM(i.`total`) AS total FROM `vtiger_invoice` i INNER JOIN `vtiger_potential` p ON i.`potentialid` = p.`potentialid` WHERE p.`potentialid` = ?;';
$params = array($potentialId);
$result = $db->pquery($sql, $params);
$potentialTotal = $db->query_result($result, 0, 'total');
$sql = 'SELECT i.`invoiceid` FROM `vtiger_invoice` i INNER JOIN `vtiger_potential` p ON i.`potentialid` = p.`potentialid` WHERE p.`potentialid` = ?;';
$params = array($potentialId);
$result = $db->pquery($sql, $params);
$invNum = $db->num_rows($result);
if ($invNum > 0) {
for ($i = 0; $i < $invNum; $i++) {
$invoiceId = $db->query_result($result, $i, 'invoiceid');
if (!isRecordExists($invoiceId)) {
continue;
}
// get sum of payments in
$sql = 'SELECT SUM(`paymentsvalue`) AS suma FROM `vtiger_paymentsin` WHERE `salesid` = ? AND `paymentsin_status` = ?;';
$params = array($invoiceId, 'Paid');
$inResult = $db->pquery($sql, $params);
$paymentsIn += $db->query_result($inResult, 0, 'suma');
// get sum of payments out
$sql = 'SELECT SUM(`paymentsvalue`) AS suma FROM `vtiger_paymentsout` WHERE `salesid` = ? AND `paymentsout_status` = ?;';
$inResult = $db->pquery($sql, $params);
$paymentsOut += $db->query_result($inResult, 0, 'suma');
}
}
$paymentsSum = $paymentsIn - $paymentsOut;
$balance = $potentialTotal - $paymentsSum;
$sql = 'UPDATE `vtiger_potential` SET `payment_balance` = ? WHERE `potentialid` = ? LIMIT 1;';
$params = array($balance, $potentialId);
$db->pquery($sql, $params);
}
示例15: process
public function process(Vtiger_Request $request)
{
$adb = PearDatabase::getInstance();
$moduleName = $request->getModule();
$id = $request->get('id');
$sourceModule = $request->get('sourceModule');
$sourceData = array();
if (isRecordExists($id)) {
$record = Vtiger_Record_Model::getInstanceById($id, $sourceModule);
$entity = $record->getEntity();
$sourceData = $entity->column_fields;
if ($sourceModule == 'HelpDesk') {
$sourceData['contact_label'] = Vtiger_Functions::getCRMRecordLabel($sourceData['contact_id']);
if (Vtiger_Functions::getCRMRecordType($sourceData['parent_id']) != 'Accounts') {
unset($sourceData['parent_id']);
} else {
$sourceData['account_label'] = Vtiger_Functions::getCRMRecordLabel($sourceData['parent_id']);
}
} else {
if ($sourceModule == 'Project') {
$ifExist = $adb->query("select * from vtiger_account where accountid = " . $sourceData['linktoaccountscontacts'] . "", true, "Błąd podczas pobierania danych z vtiger_crmentityrel");
if ($adb->num_rows($ifExist) > 0) {
$sourceData['account_label'] = Vtiger_Functions::getCRMRecordLabel($sourceData['linktoaccountscontacts']);
} else {
$sourceData['contact_label'] = Vtiger_Functions::getCRMRecordLabel($sourceData['linktoaccountscontacts']);
}
}
}
}
if ($sourceData === false) {
$result = array('success' => false, 'message' => vtranslate('LBL_FAILED_TO_IMPORT_INFO', $moduleName));
} else {
$result = array('success' => true, 'sourceData' => $sourceData);
}
$response = new Vtiger_Response();
$response->setResult($result);
$response->emit();
}