public function process(Vtiger_Request $request) { $recordId = $request->get('record'); $modules = $request->get('modules'); $assignId = $request->get('assigned_user_id'); $currentUser = Users_Record_Model::getCurrentUserModel(); $entityValues = array(); $entityValues['transferRelatedRecordsTo'] = $request->get('transferModule'); //■権限なぜか、エラーになるので権限を固定するinouchi //$entityValues['assignedTo'] = vtws_getWebserviceEntityId(vtws_getOwnerType($assignId), $assignId); $entityValues['assignedTo'] = vtws_getWebserviceEntityId(vtws_getOwnerType(1), 1); $entityValues['leadId'] = vtws_getWebserviceEntityId($request->getModule(), $recordId); $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $request->getModule()); $convertLeadFields = $recordModel->getConvertLeadFields(); $availableModules = array('Accounts', 'Contacts', 'Potentials'); foreach ($availableModules as $module) { if (vtlib_isModuleActive($module) && in_array($module, $modules)) { $entityValues['entities'][$module]['create'] = true; $entityValues['entities'][$module]['name'] = $module; foreach ($convertLeadFields[$module] as $fieldModel) { $fieldName = $fieldModel->getName(); $fieldValue = $request->get($fieldName); //Potential Amount Field value converting into DB format if ($fieldModel->getFieldDataType() === 'currency') { $fieldValue = Vtiger_Currency_UIType::convertToDBFormat($fieldValue); } elseif ($fieldModel->getFieldDataType() === 'date') { $fieldValue = DateTimeField::convertToDBFormat($fieldValue); } elseif ($fieldModel->getFieldDataType() === 'reference' && $fieldValue) { $ids = vtws_getIdComponents($fieldValue); if (count($ids) === 1) { $fieldValue = vtws_getWebserviceEntityId(getSalesEntityType($fieldValue), $fieldValue); } } $entityValues['entities'][$module][$fieldName] = $fieldValue; } } } try { $result = vtws_convertlead($entityValues, $currentUser); } catch (Exception $e) { $this->showError($request, $e); exit; } if (!empty($result['Accounts'])) { $accountIdComponents = vtws_getIdComponents($result['Accounts']); $accountId = $accountIdComponents[1]; } if (!empty($result['Contacts'])) { $contactIdComponents = vtws_getIdComponents($result['Contacts']); $contactId = $contactIdComponents[1]; } if (!empty($accountId)) { header("Location: index.php?view=Detail&module=Accounts&record={$accountId}"); } elseif (!empty($contactId)) { header("Location: index.php?view=Detail&module=Contacts&record={$contactId}"); } else { $this->showError($request); exit; } }
function handleEvent($eventName, $data) { if ($eventName == 'vtiger.entity.beforesave') { // Entity is about to be saved, take required action } if ($eventName == 'vtiger.entity.aftersave') { $db = PearDatabase::getInstance(); $relatedToId = $data->get('related_to'); if ($relatedToId) { $moduleName = getSalesEntityType($relatedToId); $focus = CRMEntity::getInstance($moduleName); $focus->retrieve_entity_info($relatedToId, $moduleName); $focus->id = $relatedToId; $fromPortal = $data->get('from_portal'); if ($fromPortal) { $focus->column_fields['from_portal'] = $fromPortal; } $entityData = VTEntityData::fromCRMEntity($focus); $wfs = new VTWorkflowManager($db); $relatedToEventHandler = new VTWorkflowEventHandler(); $relatedToEventHandler->workflows = $wfs->getWorkflowsForModuleSupportingComments($entityData->getModuleName()); $wsId = vtws_getWebserviceEntityId($entityData->getModuleName(), $entityData->getId()); $fromPortal = $entityData->get('from_portal'); $util = new VTWorkflowUtils(); $entityCache = new VTEntityCache($util->adminUser()); $entityCacheData = $entityCache->forId($wsId); $entityCacheData->set('from_portal', $fromPortal); $entityCache->cache[$wsId] = $entityCacheData; $relatedToEventHandler->handleEvent($eventName, $entityData, $entityCache); $util->revertUser(); } } }
public function retrieve($id) { global $adb, $default_charset, $site_URL; $ids = vtws_getIdComponents($id); $elemid = $ids[1]; $doc = parent::retrieve($id); // Add relations $relsrs = $adb->pquery("SELECT crmid FROM vtiger_senotesrel where notesid=?", array($elemid)); $rels = array(); while ($rl = $adb->fetch_array($relsrs)) { $rels[] = $this->vtyiicpng_getWSEntityId(getSalesEntityType($rl['crmid'])) . $rl['crmid']; } $doc['relations'] = $rels; if ($doc['filelocationtype'] == 'I') { // Add direct download link $relatt = $adb->pquery("SELECT attachmentsid FROM vtiger_seattachmentsrel WHERE crmid=?", array($elemid)); if ($relatt and $adb->num_rows($relatt) == 1) { $fileid = $adb->query_result($relatt, 0, 0); $attrs = $adb->pquery("SELECT * FROM vtiger_attachments WHERE attachmentsid = ?", array($fileid)); if ($attrs and $adb->num_rows($attrs) == 1) { $name = @$adb->query_result($attrs, 0, "name"); $filepath = @$adb->query_result($attrs, 0, "path"); $name = html_entity_decode($name, ENT_QUOTES, $default_charset); $doc['_downloadurl'] = $site_URL . "/" . $filepath . $fileid . "_" . $name; } } } return $doc; }
/** * Function to get the Display Value, for the current field type with given DB Insert Value * @param <Object> $value * @return <Object> */ public function getReferenceModule($value) { $fieldModel = $this->get('field'); $referenceModuleList = $fieldModel->getReferenceList(); $referenceEntityType = getSalesEntityType($value); if (in_array($referenceEntityType, $referenceModuleList)) { return Vtiger_Module_Model::getInstance($referenceEntityType); } elseif (in_array('Users', $referenceModuleList)) { return Vtiger_Module_Model::getInstance('Users'); } return null; }
function updateContactAssignedTo($entity) { global $adb, $default_charset, $log; list($acc, $acc_id) = explode('x', $entity->data['id']); // separate webservice ID if (getSalesEntityType($acc_id) == 'Accounts') { list($usr, $usr_id) = explode('x', $entity->data['assigned_user_id']); $query = 'update vtiger_crmentity set smownerid=? where crmid in (select contactid from vtiger_contactdetails where accountid=?)'; $params = array($usr_id, $acc_id); $adb->pquery($query, $params); } }
/** * Function to get the Display Value, for the current field type with given DB Insert Value * @param <Object> $value * @return <Object> */ public function getReferenceModule($value) { global $log; $log->debug("Entering ./uitypes/Reference.php::getReferenceModule"); $fieldModel = $this->get('field'); $referenceModuleList = $fieldModel->getReferenceList(); $referenceEntityType = getSalesEntityType($value); if (in_array($referenceEntityType, $referenceModuleList)) { return Vtiger_Module_Model::getInstance($referenceEntityType); } elseif (in_array('Users', $referenceModuleList)) { return Vtiger_Module_Model::getInstance('Users'); } return null; }
function duplicaterec($currentModule, $record_id, $bmapname) { global $adb, $current_user; $focus = CRMEntity::getInstance($currentModule); $focus->retrieve_entity_info($record_id, $currentModule); // Retrieve relations map //$bmapname = 'BusinessMapping_'.$currentModule.'_DuplicateRelations'; $cbMapid = GlobalVariable::getVariable('BusinessMapping_' . $bmapname, cbMap::getMapIdByName($bmapname)); if ($cbMapid) { $cbMap = cbMap::getMapByID($cbMapid); $maped_relations = $cbMap->DuplicateRelations()->getRelatedModules(); } // Duplicate Records that this Record is dependent of if ($cbMapid && $cbMap->DuplicateRelations()->DuplicateDirectRelations()) { $invmods = getInventoryModules(); foreach ($focus->column_fields as $fieldname => $value) { $sql = 'SELECT * FROM vtiger_field WHERE columnname = ? AND uitype IN (10,50,51,57,58,59,73,68,76,75,81,78,80)'; $result = $adb->pquery($sql, array($fieldname)); if ($adb->num_rows($result) == 1 && !empty($value)) { $module = getSalesEntityType($value); if (in_array($module, $invmods)) { continue; } // we can't duplicate these $handler = vtws_getModuleHandlerFromName($module, $current_user); $meta = $handler->getMeta(); $entity = CRMEntity::getInstance($module); $entity->mode = ''; $entity->retrieve_entity_info($value, $module); $entity->column_fields = DataTransform::sanitizeRetrieveEntityInfo($entity->column_fields, $meta); $entity->save($module); $focus->column_fields[$fieldname] = $entity->id; } } } $handler = vtws_getModuleHandlerFromName($currentModule, $current_user); $meta = $handler->getMeta(); $focus->column_fields = DataTransform::sanitizeRetrieveEntityInfo($focus->column_fields, $meta); $focus->saveentity($currentModule); // no workflows for this one => so we don't reenter this process $new_record_id = $focus->id; $curr_tab_id = gettabid($currentModule); $related_list = get_related_lists($curr_tab_id, $maped_relations); dup_related_lists($new_record_id, $currentModule, $related_list, $record_id, $maped_relations); $dependents_list = get_dependent_lists($curr_tab_id); $dependent_tables = get_dependent_tables($dependents_list, $currentModule); dup_dependent_rec($record_id, $currentModule, $new_record_id, $dependent_tables, $maped_relations); return $new_record_id; }
function getEmail($relid) { global $adb; $email = ''; if (!empty($relid)) { $relModule = getSalesEntityType($relid); if ($relModule == "Contacts") { $res = $adb->pquery("SELECT email FROM vtiger_contactdetails WHERE contactid = ?", array($relid)); $email = $adb->query_result($res, 0, 'email'); } else { $res = $adb->pquery("SELECT email1 FROM vtiger_account WHERE accountid = ?", array($relid)); $email = $adb->query_result($res, 0, 'email1'); } } return $email; }
function buildDocumentModel() { global $app_strings; try { $model = parent::buildDocumentModel(); $this->generateEntityModel($this->focus, 'Potentials', 'potential_', $model); if ($this->focusColumnValue('related_to')) $setype = getSalesEntityType($this->focusColumnValue('related_to')); $account = new Accounts(); $contact = new Contacts(); if ($setype == 'Accounts') $account->retrieve_entity_info($this->focusColumnValue('related_to'), $setype); elseif ($setype == 'Contacts') $contact->retrieve_entity_info($this->focusColumnValue('related_to'), $setype); $this->generateEntityModel($account, 'Accounts', 'account_', $model); $this->generateEntityModel($contact, 'Contacts', 'contact_', $model); $this->generateUi10Models($model); $this->generateRelatedListModels($model); $model->set('potential_no', $this->focusColumnValue('potential_no')); $model->set('potential_owner', getUserFullName($this->focusColumnValue('assigned_user_id'))); return $model; } catch (Exception $e) { echo '<meta charset="utf-8" />'; if($e->getMessage() == $app_strings['LBL_RECORD_DELETE']) { echo $app_strings['LBL_RECORD_INCORRECT']; echo '<br><br>'; } else { echo $e->getMessage(); echo '<br><br>'; } return null; } }
/** * $arguments[0] origin column_fields array * $arguments[1] target column_fields array */ function processMap($arguments) { global $adb, $current_user; $mapping = $this->convertMap2Array(); $ofields = $arguments[0]; if (!empty($ofields['record_id'])) { $setype = getSalesEntityType($ofields['record_id']); $wsidrs = $adb->pquery('SELECT id FROM vtiger_ws_entity WHERE name=?', array($setype)); $entityId = $adb->query_result($wsidrs, 0, 0) . 'x' . $ofields['record_id']; } $tfields = $arguments[1]; foreach ($mapping['fields'] as $targetfield => $sourcefields) { $value = ''; $delim = isset($sourcefields['delimiter']) ? $sourcefields['delimiter'] : ''; foreach ($sourcefields['merge'] as $pos => $fieldinfo) { $idx = array_keys($fieldinfo); if (strtoupper($idx[0]) == 'CONST') { $const = array_pop($fieldinfo); $value .= $const . $delim; } elseif (strtoupper($idx[0]) == 'EXPRESSION') { $testexpression = array_pop($fieldinfo); $parser = new VTExpressionParser(new VTExpressionSpaceFilter(new VTExpressionTokenizer($testexpression))); $expression = $parser->expression(); $exprEvaluater = new VTFieldExpressionEvaluater($expression); if (empty($ofields['record_id'])) { $exprEvaluation = $exprEvaluater->evaluate(false); } else { $entity = new VTWorkflowEntity($current_user, $entityId); $exprEvaluation = $exprEvaluater->evaluate($entity); } $value .= $exprEvaluation . $delim; } else { $fieldname = array_pop($fieldinfo); $value .= $ofields[$fieldname] . $delim; } } $value = rtrim($value, $delim); $tfields[$targetfield] = $value; } return $tfields; }
function startCall() { global $current_user, $adb, $log; require_once 'include/utils/utils.php'; require_once 'modules/PBXManager/utils/AsteriskClass.php'; require_once 'modules/PBXManager/AsteriskUtils.php'; $id = $current_user->id; $number = $_REQUEST['number']; $record = $_REQUEST['recordid']; $result = $adb->query("select * from vtiger_asteriskextensions where userid=" . $current_user->id); $extension = $adb->query_result($result, 0, "asterisk_extension"); $data = getAsteriskInfo($adb); if (!empty($data)) { $server = $data['server']; $port = $data['port']; $username = $data['username']; $password = $data['password']; $version = $data['version']; $errno = $errstr = NULL; $sock = fsockopen($server, $port, $errno, $errstr, 1); stream_set_blocking($sock, false); if ($sock === false) { echo "Socket cannot be created due to error: {$errno}: {$errstr}\n"; $log->debug("Socket cannot be created due to error: {$errno}: {$errstr}\n"); exit(0); } $asterisk = new Asterisk($sock, $server, $port); loginUser($username, $password, $asterisk); $asterisk->transfer($extension, $number); $callerModule = getSalesEntityType($record); $entityNames = getEntityName($callerModule, array($record)); $callerName = $entityNames[$record]; $callerInfo = array('id' => $record, 'module' => $callerModule, 'name' => $callerName); //adds to pbx manager addToCallHistory($extension, $extension, $number, "outgoing", $adb, $callerInfo); // add to the records activity history addOutgoingcallHistory($current_user, $extension, $record, $adb); } }
function getRelatedRecords($id, $module, $relatedModule, $queryParameters, $user) { global $adb, $currentModule, $log, $current_user; // TODO To be integrated with PearDatabase $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; // END // pickup meta data of related module $webserviceObject = VtigerWebserviceObject::fromName($adb, $relatedModule); $handlerPath = $webserviceObject->getHandlerPath(); $handlerClass = $webserviceObject->getHandlerClass(); if ($relatedModule == 'Products' and $module != 'Products') { $srvwebserviceObject = VtigerWebserviceObject::fromName($adb, 'Services'); $srvhandlerPath = $srvwebserviceObject->getHandlerPath(); $srvhandlerClass = $srvwebserviceObject->getHandlerClass(); require_once $srvhandlerPath; $srvhandler = new $srvhandlerClass($srvwebserviceObject, $user, $adb, $log); $srvmeta = $srvhandler->getMeta(); } require_once $handlerPath; $handler = new $handlerClass($webserviceObject, $user, $adb, $log); $meta = $handler->getMeta(); $query = __getRLQuery($id, $module, $relatedModule, $queryParameters, $user); $result = $adb->pquery($query, array()); $records = array(); // Return results while ($row = $adb->fetch_array($result)) { if (($module == 'HelpDesk' or $module == 'Faq') and $relatedModule == 'ModComments') { $records[] = $row; } else { if (isset($row['id']) and getSalesEntityType($row['id']) == 'Services') { $records[] = DataTransform::sanitizeData($row, $srvmeta); } else { $records[] = DataTransform::sanitizeData($row, $meta); } } } return array('records' => $records); }
/** * Function which processes request for Mail Operations * @global Integer $list_max_entries_per_page - Number of entries per page * @global PearDataBase Instance $adb * @global Users Instance $current_user * @global String $root_directory * @param Vtiger_Request $request * @return MailManager_Response */ function process(Vtiger_Request $request) { global $list_max_entries_per_page, $adb, $current_user; $moduleName = $request->getModule(); $response = new Vtiger_Response(); if ('open' == $this->getOperationArg($request)) { $foldername = $request->get('_folder'); $connector = $this->getConnector($foldername); $folder = $connector->folderInstance($foldername); $connector->markMailRead($request->get('_msgno')); $mail = $connector->openMail($request->get('_msgno')); // Get updated count after opening the email $connector->updateFolder($folder, SA_MESSAGES | SA_UNSEEN); $viewer = $this->getViewer($request); $viewer->assign('FOLDER', $folder); $viewer->assign('MAIL', $mail); $viewer->assign('MODULE', $moduleName); $uicontent = $viewer->view('MailOpen.tpl', 'MailManager', true); $metainfo = array('from' => $mail->from(), 'subject' => $mail->subject(), 'msgno' => $mail->msgNo(), 'msguid' => $mail->uniqueid(), 'folder' => $foldername); $response->isJson(true); $response->setResult(array('folder' => $foldername, 'unread' => $folder->unreadCount(), 'ui' => $uicontent, 'meta' => $metainfo)); } else { if ('mark' == $this->getOperationArg($request)) { $foldername = $request->get('_folder'); $connector = $this->getConnector($foldername); $folder = $connector->folderInstance($foldername); $connector->updateFolder($folder, SA_UNSEEN); if ('unread' == $request->get('_markas')) { $connector->markMailUnread($request->get('_msgno')); } $response->isJson(true); $response->setResult(array('folder' => $foldername, 'unread' => $folder->unreadCount() + 1, 'status' => true, 'msgno' => $request->get('_msgno'))); } else { if ('delete' == $this->getOperationArg($request)) { $msg_no = $request->get('_msgno'); $foldername = $request->get('_folder'); $connector = $this->getConnector($foldername); $connector->deleteMail($msg_no); $response->isJson(true); $response->setResult(array('folder' => $foldername, 'status' => true)); } else { if ('move' == $this->getOperationArg($request)) { $msg_no = $request->get('_msgno'); $foldername = $request->get('_folder'); $moveToFolder = $request->get('_moveFolder'); $connector = $this->getConnector($foldername); $connector->moveMail($msg_no, $moveToFolder); $response->isJson(true); $response->setResult(array('folder' => $foldername, 'status' => true)); } else { if ('send' == $this->getOperationArg($request)) { require_once 'modules/MailManager/Config.php'; // This is to handle larger uploads $memory_limit = MailManager_Config::get('MEMORY_LIMIT'); ini_set('memory_limit', $memory_limit); $to_string = rtrim($request->get('to'), ','); $connector = $this->getConnector('__vt_drafts'); if (!empty($to_string)) { $toArray = explode(',', $to_string); foreach ($toArray as $to) { $relatedtos = MailManager::lookupMailInVtiger($to, $current_user); $referenceArray = array('Contacts', 'Accounts', 'Leads'); for ($j = 0; $j < count($referenceArray); $j++) { $val = $referenceArray[$j]; if (!empty($relatedtos) && is_array($relatedtos)) { for ($i = 0; $i < count($relatedtos); $i++) { if ($i == count($relatedtos) - 1) { $relateto = vtws_getIdComponents($relatedtos[$i]['record']); $parentIds = $relateto[1] . "@1"; } elseif ($relatedtos[$i]['module'] == $val) { $relateto = vtws_getIdComponents($relatedtos[$i]['record']); $parentIds = $relateto[1] . "@1"; break; } } } if (isset($parentIds)) { break; } } if ($parentIds == '') { if (count($relatedtos) > 0) { $relateto = vtws_getIdComponents($relatedtos[0]['record']); $parentIds = $relateto[1] . "@1"; break; } } $cc_string = rtrim($request->get('cc'), ','); $bcc_string = rtrim($request->get('bcc'), ','); $subject = $request->get('subject'); $body = $request->get('body'); //Restrict this for users module if ($relateto[1] != NULL && $relateto[0] != '19') { $entityId = $relateto[1]; $parent_module = getSalesEntityType($entityId); $description = getMergedDescription($body, $entityId, $parent_module); } else { if ($relateto[0] == '19') { $parentIds = $relateto[1] . '@-1'; } $description = $body; } $fromEmail = $connector->getFromEmailAddress(); $userFullName = getFullNameFromArray('Users', $current_user->column_fields); $userId = $current_user->id; $mailer = new Vtiger_Mailer(); $mailer->IsHTML(true); $mailer->ConfigSenderInfo($fromEmail, $userFullName, $current_user->email1); $mailer->Subject = $subject; $mailer->Body = $description; $mailer->addSignature($userId); if ($mailer->Signature != '') { $mailer->Body .= $mailer->Signature; } $ccs = empty($cc_string) ? array() : explode(',', $cc_string); $bccs = empty($bcc_string) ? array() : explode(',', $bcc_string); $emailId = $request->get('emailid'); $attachments = $connector->getAttachmentDetails($emailId); $mailer->AddAddress($to); foreach ($ccs as $cc) { $mailer->AddCC($cc); } foreach ($bccs as $bcc) { $mailer->AddBCC($bcc); } global $root_directory; if (is_array($attachments)) { foreach ($attachments as $attachment) { $fileNameWithPath = $root_directory . $attachment['path'] . $attachment['fileid'] . "_" . $attachment['attachment']; if (is_file($fileNameWithPath)) { $mailer->AddAttachment($fileNameWithPath, $attachment['attachment']); } } } $status = $mailer->Send(true); if ($status === true) { $email = CRMEntity::getInstance('Emails'); $email->column_fields['assigned_user_id'] = $current_user->id; $email->column_fields['date_start'] = date('Y-m-d'); $email->column_fields['time_start'] = date('H:i'); $email->column_fields['parent_id'] = $parentIds; $email->column_fields['subject'] = $mailer->Subject; $email->column_fields['description'] = $mailer->Body; $email->column_fields['activitytype'] = 'Emails'; $email->column_fields['from_email'] = $mailer->From; $email->column_fields['saved_toid'] = $to; $email->column_fields['ccmail'] = $cc_string; $email->column_fields['bccmail'] = $bcc_string; $email->column_fields['email_flag'] = 'SENT'; if (empty($emailId)) { $email->save('Emails'); } else { $email->id = $emailId; $email->mode = 'edit'; $email->save('Emails'); } // This is added since the Emails save_module is not handling this global $adb; $realid = explode("@", $parentIds); $mycrmid = $realid[0]; $params = array($mycrmid, $email->id); if ($realid[1] == -1) { $adb->pquery('DELETE FROM vtiger_salesmanactivityrel WHERE smid=? AND activityid=?', $params); $adb->pquery('INSERT INTO vtiger_salesmanactivityrel VALUES (?,?)', $params); } else { $adb->pquery('DELETE FROM vtiger_seactivityrel WHERE crmid=? AND activityid=?', $params); $adb->pquery('INSERT INTO vtiger_seactivityrel VALUES (?,?)', $params); } } } } if ($status === true) { $response->isJson(true); $response->setResult(array('sent' => true)); } else { $response->isJson(true); $response->setError(112, 'please verify outgoing server.'); } } else { if ('attachment_dld' == $this->getOperationArg($request)) { $attachmentName = $request->get('_atname'); $attachmentName = str_replace(' ', '_', $attachmentName); if (MailManager_Utils::allowedFileExtension($attachmentName)) { // This is to handle larger uploads $memory_limit = MailManager_Config::get('MEMORY_LIMIT'); ini_set('memory_limit', $memory_limit); $mail = new MailManager_Message_Model(false, false); $mail->readFromDB($request->get('_muid')); $attachment = $mail->attachments(true, $attachmentName); if ($attachment[$attachmentName]) { // Send as downloadable header("Content-type: application/octet-stream"); header("Pragma: public"); header("Cache-Control: private"); header("Content-Disposition: attachment; filename={$attachmentName}"); echo $attachment[$attachmentName]; } else { header("Content-Disposition: attachment; filename=INVALIDFILE"); echo ""; } } else { header("Content-Disposition: attachment; filename=INVALIDFILE"); echo ""; } flush(); exit; } elseif ('getdraftmail' == $this->getOperationArg($request)) { $connector = $this->getConnector('__vt_drafts'); $draftMail = $connector->getDraftMail($request); $response->isJson(true); $response->setResult(array($draftMail)); } elseif ('save' == $this->getOperationArg($request)) { $connector = $this->getConnector('__vt_drafts'); $draftId = $connector->saveDraft($request); $response->isJson(true); if (!empty($draftId)) { $response->setResult(array('success' => true, 'emailid' => $draftId)); } else { $response->setResult(array('success' => false, 'error' => "Draft was not saved")); } } elseif ('deleteAttachment' == $this->getOperationArg($request)) { $connector = $this->getConnector('__vt_drafts'); $deleteResponse = $connector->deleteAttachment($request); $response->isJson(true); $response->setResult(array('success' => $deleteResponse)); } elseif ('forward' == $this->getOperationArg($request)) { $messageId = $request->get('messageid'); $folderName = $request->get('folder'); $connector = $this->getConnector($folderName); $mail = $connector->openMail($messageId); $attachments = $mail->attachments(true); $draftConnector = $this->getConnector('__vt_drafts'); $draftId = $draftConnector->saveDraft($request); if (!empty($attachments)) { foreach ($attachments as $aName => $aValue) { $attachInfo = $mail->__SaveAttachmentFile($aName, $aValue); if (is_array($attachInfo) && !empty($attachInfo) && $attachInfo['size'] > 0) { if (!MailManager::checkModuleWriteAccessForCurrentUser('Documents')) { return; } $document = CRMEntity::getInstance('Documents'); $document->column_fields['notes_title'] = $attachInfo['name']; $document->column_fields['filename'] = $attachInfo['name']; $document->column_fields['filestatus'] = 1; $document->column_fields['filelocationtype'] = 'I'; $document->column_fields['folderid'] = 1; // Default Folder $document->column_fields['filesize'] = $attachInfo['size']; $document->column_fields['assigned_user_id'] = $current_user->id; $document->save('Documents'); //save doc-attachment relation $draftConnector->saveAttachmentRel($document->id, $attachInfo['attachid']); //save email-doc relation $draftConnector->saveEmailDocumentRel($draftId, $document->id); //save email-attachment relation $draftConnector->saveAttachmentRel($draftId, $attachInfo['attachid']); $attachmentInfo[] = array('name' => $attachInfo['name'], 'size' => $attachInfo['size'], 'emailid' => $draftId, 'docid' => $document->id); } unset($aValue); } } $response->isJson(true); $response->setResult(array('attachments' => $attachmentInfo, 'emailid' => $draftId)); } } } } } } return $response; }
function getRelatedToEntity($module, $list_result, $rset) { global $log; $log->debug("Entering getRelatedToEntity(" . $module . "," . $list_result . "," . $rset . ") method ..."); global $adb; $seid = $adb->query_result($list_result, $rset, "relatedto"); $action = "DetailView"; if (isset($seid) && $seid != '') { $parent_module = $parent_module = getSalesEntityType($seid); if ($parent_module == 'Accounts') { $numrows = $adb->num_rows($evt_result); $parent_module = $adb->query_result($evt_result, 0, 'setype'); $parent_id = $adb->query_result($evt_result, 0, 'crmid'); if ($numrows > 1) { $parent_module = 'Multiple'; $parent_name = $app_strings['LBL_MULTIPLE']; } //Raju -- Ends $parent_query = "SELECT accountname FROM vtiger_account WHERE accountid=?"; $parent_result = $adb->pquery($parent_query, array($seid)); $parent_name = $adb->query_result($parent_result, 0, "accountname"); } if ($parent_module == 'Leads') { $parent_query = "SELECT firstname,lastname FROM vtiger_leaddetails WHERE leadid=?"; $parent_result = $adb->pquery($parent_query, array($seid)); $parent_name = getFullNameFromQResult($parent_result, 0, "Leads"); } if ($parent_module == 'Potentials') { $parent_query = "SELECT potentialname FROM vtiger_potential WHERE potentialid=?"; $parent_result = $adb->pquery($parent_query, array($seid)); $parent_name = $adb->query_result($parent_result, 0, "potentialname"); } if ($parent_module == 'Products') { $parent_query = "SELECT productname FROM vtiger_products WHERE productid=?"; $parent_result = $adb->pquery($parent_query, array($seid)); $parent_name = $adb->query_result($parent_result, 0, "productname"); } if ($parent_module == 'PurchaseOrder') { $parent_query = "SELECT subject FROM vtiger_purchaseorder WHERE purchaseorderid=?"; $parent_result = $adb->pquery($parent_query, array($seid)); $parent_name = $adb->query_result($parent_result, 0, "subject"); } if ($parent_module == 'SalesOrder') { $parent_query = "SELECT subject FROM vtiger_salesorder WHERE salesorderid=?"; $parent_result = $adb->pquery($parent_query, array($seid)); $parent_name = $adb->query_result($parent_result, 0, "subject"); } if ($parent_module == 'Invoice') { $parent_query = "SELECT subject FROM vtiger_invoice WHERE invoiceid=?"; $parent_result = $adb->pquery($parent_query, array($seid)); $parent_name = $adb->query_result($parent_result, 0, "subject"); } $parent_value = "<a href='index.php?module=" . $parent_module . "&action=" . $action . "&record=" . $seid . "'>" . $parent_name . "</a>"; } else { $parent_value = ''; } $log->debug("Exiting getRelatedToEntity method ..."); return $parent_value; }
/** * this function takes in an array of values for an user and sanitizes it for export * @param array $arr - the array of values */ function sanitizeValues($arr) { $db = PearDatabase::getInstance(); $currentUser = Users_Record_Model::getCurrentUserModel(); $roleid = $currentUser->get('roleid'); if (empty($this->fieldArray)) { $this->fieldArray = $this->moduleFieldInstances; foreach ($this->fieldArray as $fieldName => $fieldObj) { //In database we have same column name in two tables. - inventory modules only if ($fieldObj->get('table') == 'vtiger_inventoryproductrel' && ($fieldName == 'discount_amount' || $fieldName == 'discount_percent')) { $fieldName = 'item_' . $fieldName; $this->fieldArray[$fieldName] = $fieldObj; } else { $columnName = $fieldObj->get('column'); $this->fieldArray[$columnName] = $fieldObj; } } } $moduleName = $this->moduleInstance->getName(); foreach ($arr as $fieldName => &$value) { if (isset($this->fieldArray[$fieldName])) { $fieldInfo = $this->fieldArray[$fieldName]; } else { unset($arr[$fieldName]); continue; } $value = trim(decode_html($value), "\""); $uitype = $fieldInfo->get('uitype'); $fieldname = $fieldInfo->get('name'); if (!$this->fieldDataTypeCache[$fieldName]) { $this->fieldDataTypeCache[$fieldName] = $fieldInfo->getFieldDataType(); } $type = $this->fieldDataTypeCache[$fieldName]; if ($fieldname != 'hdnTaxType' && ($uitype == 15 || $uitype == 16 || $uitype == 33)) { if (empty($this->picklistValues[$fieldname])) { $this->picklistValues[$fieldname] = $this->fieldArray[$fieldname]->getPicklistValues(); } // If the value being exported is accessible to current user // or the picklist is multiselect type. if ($uitype == 33 || $uitype == 16 || array_key_exists($value, $this->picklistValues[$fieldname])) { // NOTE: multipicklist (uitype=33) values will be concatenated with |# delim $value = trim($value); } else { $value = ''; } } elseif ($uitype == 52 || $type == 'owner') { $value = Vtiger_Util_Helper::getOwnerName($value); } elseif ($type == 'reference') { $value = trim($value); if (!empty($value)) { $parent_module = getSalesEntityType($value); $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $k => $v) { $displayValue = $v; } } if (!empty($parent_module) && !empty($displayValue)) { $value = $parent_module . "::::" . $displayValue; } else { $value = ""; } } else { $value = ''; } } elseif ($uitype == 72 || $uitype == 71) { $value = CurrencyField::convertToUserFormat($value, null, true, true); } elseif ($uitype == 7 && $fieldInfo->get('typeofdata') == 'N~O' || $uitype == 9) { $value = decimalFormat($value); } else { if ($type == 'date' || $type == 'datetime') { $value = DateTimeField::convertToUserFormat($value); } } if ($moduleName == 'Documents' && $fieldname == 'description') { $value = strip_tags($value); $value = str_replace(' ', '', $value); array_push($new_arr, $value); } } return $arr; }
/** Returns a list of the associated contacts * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. * All Rights Reserved.. */ function get_contacts($id, $cur_tab_id, $rel_tab_id, $actions = false) { global $adb, $log, $singlepane_view, $currentModule, $current_user; $log->debug("Entering get_contacts(" . $id . ") method ..."); $this_module = $currentModule; $related_module = vtlib_getModuleNameById($rel_tab_id); require_once "modules/{$related_module}/{$related_module}.php"; $other = new $related_module(); vtlib_setup_modulevars($related_module, $other); $singular_modname = vtlib_toSingular($related_module); $parenttab = getParentTab(); if ($singlepane_view == 'true') { $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; } else { $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; } $button = ''; $search_string = '&fromPotential=true&acc_id='; // leave it empty for compatibility $relrs = $adb->pquery('select related_to from vtiger_potential where potentialid=?', array($id)); if ($relrs and $adb->num_rows($relrs) == 1) { $relatedid = $adb->query_result($relrs, 0, 0); $reltype = getSalesEntityType($relatedid); if ($reltype == 'Accounts') { $search_string = '&fromPotential=true&acc_id=' . $relatedid; } elseif ($reltype == 'Contacts') { $relrs = $adb->pquery('select accountid from vtiger_contactdetails where contactid=?', array($relatedid)); if ($relrs and $adb->num_rows($relrs) == 1) { $relatedid = $adb->query_result($relrs, 0, 0); if (!empty($relatedid)) { $search_string = '&fromPotential=true&acc_id=' . $relatedid; } } } } if ($actions) { if (is_string($actions)) { $actions = explode(',', strtoupper($actions)); } if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}{$search_string}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> "; } if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') { $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'> "; } } $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query = 'select case when (vtiger_users.user_name not like "") then ' . $userNameSql . ' else vtiger_groups.groupname end as user_name, vtiger_contactdetails.accountid,vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime , vtiger_account.accountname from vtiger_potential inner join vtiger_contpotentialrel on vtiger_contpotentialrel.potentialid = vtiger_potential.potentialid inner join vtiger_contactdetails on vtiger_contpotentialrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_account on vtiger_account.accountid = vtiger_contactdetails.accountid left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_potential.potentialid = ' . $id . ' and vtiger_crmentity.deleted=0'; $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); if ($return_value == null) { $return_value = array(); } $return_value['CUSTOM_BUTTON'] = $button; $log->debug("Exiting get_contacts method ..."); return $return_value; }
// Reset the value w.r.t SalesOrder Selected $currencyid = $so_focus->column_fields['currency_id']; $rate = $so_focus->column_fields['conversion_rate']; //Added to display the SO's associated products -- when we select SO in New Invoice page if (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') { $associated_prod = getAssociatedProducts("SalesOrder", $so_focus, $focus->column_fields['salesorder_id']); } $smarty->assign("SALESORDER_ID", $focus->column_fields['salesorder_id']); $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod); $smarty->assign("MODE", $so_focus->mode); $smarty->assign("AVAILABLE_PRODUCTS", 'true'); } elseif (isset($_REQUEST['convertmode']) && $_REQUEST['convertmode'] == 'potentoinvoice') { $focus->mode = ''; $_REQUEST['opportunity_id'] = $_REQUEST['return_id']; $relpot = $adb->query_result($adb->pquery('select related_to from vtiger_potential where potentialid=?', array($_REQUEST['return_id'])), 0, 0); $reltype = getSalesEntityType($relpot); if ($reltype == 'Accounts') { $_REQUEST['account_id'] = $relpot; } else { $_REQUEST['contact_id'] = $relpot; } } } if ($isduplicate == 'true') { $smarty->assign('DUPLICATE_FROM', $focus->id); $INVOICE_associated_prod = getAssociatedProducts($currentModule, $focus); $inventory_cur_info = getInventoryCurrencyInfo($currentModule, $focus->id); $currencyid = $inventory_cur_info['currency_id']; $focus->id = ''; $focus->mode = ''; }
function get_project_tickets($id, $module, $customerid, $sessionid) { require_once 'modules/HelpDesk/HelpDesk.php'; require_once 'include/utils/UserInfoUtil.php'; $adb = PearDatabase::getInstance(); $log = vglobal('log'); $log->debug("Entering customer portal function get_project_tickets .."); $check = checkModuleActive($module); if ($check == false) { return array("#MODULE INACTIVE#"); } if (!validateSession($customerid, $sessionid)) { return null; } $user = new Users(); $userid = getPortalUserid(); $current_user = $user->retrieveCurrentUserInfoFromFile($userid); $focus = new HelpDesk(); $focus->filterInactiveFields('HelpDesk'); $TicketsfieldVisibilityByColumn = array(); $fields_list = array(); foreach ($focus->list_fields as $fieldlabel => $values) { foreach ($values as $table => $fieldname) { $fields_list[$fieldlabel] = $fieldname; $TicketsfieldVisibilityByColumn[$fieldname] = getColumnVisibilityPermission($current_user->id, $fieldname, 'HelpDesk'); } } $query = "SELECT vtiger_troubletickets.*, vtiger_crmentity.smownerid FROM vtiger_troubletickets\n\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid\n\t\tINNER JOIN vtiger_crmentityrel ON (vtiger_crmentityrel.relcrmid = vtiger_crmentity.crmid OR vtiger_crmentityrel.crmid = vtiger_crmentity.crmid)\n\t\tWHERE vtiger_crmentity.deleted = 0 AND (vtiger_crmentityrel.crmid = ? OR vtiger_crmentityrel.relcrmid = ?)"; $params = array($id, $id); $res = $adb->pquery($query, $params); $noofdata = $adb->num_rows($res); for ($j = 0; $j < $noofdata; $j++) { $i = 0; foreach ($fields_list as $fieldlabel => $fieldname) { $fieldper = $TicketsfieldVisibilityByColumn[$fieldname]; //in troubletickets the list_fields has columns so we call this API if ($fieldper == '1') { continue; } $output[0][$module]['head'][0][$i]['fielddata'] = Vtiger_Language_Handler::getTranslatedString($fieldlabel, 'HelpDesk', vglobal('default_language')); $fieldvalue = $adb->query_result($res, $j, $fieldname); $ticketid = $adb->query_result($res, $j, 'ticketid'); if ($fieldname == 'title') { $fieldvalue = '<a href="index.php?module=HelpDesk&action=index&fun=detail&ticketid=' . $ticketid . '">' . $fieldvalue . '</a>'; } if ($fieldname == 'parent_id' || $fieldname == 'contact_id') { $crmid = $fieldvalue; $entitymodule = getSalesEntityType($crmid); if ($crmid != '' && $entitymodule != '') { $fieldvalues = getEntityName($entitymodule, array($crmid)); if ($entitymodule == 'Contacts') { $fieldvalue = '<a href="index.php?module=Contacts&action=index&id=' . $crmid . '">' . $fieldvalues[$crmid] . '</a>'; } elseif ($entitymodule == 'Accounts') { $fieldvalue = '<a href="index.php?module=Accounts&action=index&id=' . $crmid . '">' . $fieldvalues[$crmid] . '</a>'; } } else { $fieldvalue = ''; } } if ($fieldname == 'smownerid') { $fieldvalue = getOwnerName($fieldvalue); } if ($fieldlabel == 'Status') { $fieldvalue = Vtiger_Language_Handler::getTranslatedString($fieldvalue, 'HelpDesk', vglobal('default_language')); } $output[1][$module]['data'][$j][$i]['fielddata'] = $fieldvalue; $i++; } } $log->debug("Exiting customerportal function get_project_tickets .."); return $output; }
public static function createPotentialRelatedTo($relatedto, $campaignid) { global $adb, $current_user; $checkrs = $adb->pquery('select 1 from vtiger_potential inner join vtiger_crmentity on crmid=potentialid where deleted=0 and related_to=? and campaignid=?', array($relatedto, $campaignid)); if ($adb->num_rows($checkrs) == 0) { require_once 'modules/Potentials/Potentials.php'; $entity = new Potentials(); $entity->mode = ''; $cname = getEntityName('Campaigns', $campaignid); $cname = $cname[$campaignid] . ' - '; $setype = getSalesEntityType($relatedto); $rname = getEntityName($setype, $relatedto); $rname = $rname[$relatedto]; $cbMapid = GlobalVariable::getVariable('BusinessMapping_PotentialOnCampaignRelation', cbMap::getMapIdByName('PotentialOnCampaignRelation')); if ($cbMapid) { $cmp = CRMEntity::getInstance('Campaigns'); $cmp->retrieve_entity_info($campaignid, 'Campaigns'); if ($setype == 'Accounts') { $cmp->column_fields['AccountName'] = $rname; $cmp->column_fields['ContactName'] = ''; } else { $cmp->column_fields['AccountName'] = ''; $cmp->column_fields['ContactName'] = $rname; } $cbMap = cbMap::getMapByID($cbMapid); $entity->column_fields = $cbMap->Mapping($cmp->column_fields, array()); } if (empty($entity->column_fields['assigned_user_id'])) { $entity->column_fields['assigned_user_id'] = $current_user->id; } $entity->column_fields['related_to'] = $relatedto; $entity->column_fields['campaignid'] = $campaignid; if (empty($entity->column_fields['closingdate'])) { $dt = new DateTimeField(); $entity->column_fields['closingdate'] = $dt->getDisplayDate(); } if (empty($entity->column_fields['potentialname'])) { $entity->column_fields['potentialname'] = $cname . $rname; } if (empty($entity->column_fields['sales_stage'])) { $entity->column_fields['sales_stage'] = 'Prospecting'; } $_REQUEST['assigntype'] = 'U'; $_REQUEST['assigned_user_id'] = $entity->column_fields['assigned_user_id']; $entity->save('Potentials'); } }
function vtws_history_entityIdHelper($moduleName, $id) { static $wsEntityIdCache = NULL; if ($wsEntityIdCache === NULL) { $wsEntityIdCache = array('users' => array(), 'records' => array()); } if (!isset($wsEntityIdCache[$moduleName][$id])) { // Determine moduleName based on $id if (empty($moduleName)) { $moduleName = getSalesEntityType($id); } if ($moduleName == 'Calendar') { $moduleName = vtws_getCalendarEntityType($id); } $wsEntityIdCache[$moduleName][$id] = vtws_getWebserviceEntityId($moduleName, $id); } return $wsEntityIdCache[$moduleName][$id]; }
$modObj->id = $crmid; $modObj->mode = "edit"; //Added to construct the update log for Ticket history $assigned_group_name = getGroupName($_REQUEST['assigned_group_id']); $assigntype = $_REQUEST['assigntype']; $fldvalue = $modObj->constructUpdateLog($modObj, $modObj->mode, $assigned_group_name, $assigntype); $fldvalue = from_html($fldvalue, $modObj->mode == 'edit' ? true : false); $modObj->save("HelpDesk"); global $mod_strings; if ($fieldname == "solution" || $fieldname == "comments" || $fieldname == "assigned_user_id" || $fieldname == "ticketstatus" && $fieldvalue == $mod_strings['Closed']) { require_once 'modules/Emails/mail.php'; $user_emailid = getUserEmailId('id', $modObj->column_fields['assigned_user_id']); $subject = $modObj->column_fields['ticket_no'] . ' [ ' . $mod_strings['LBL_TICKET_ID'] . ' : ' . $modObj->id . ' ] Re : ' . $modObj->column_fields['ticket_title']; $parent_id = $modObj->column_fields['parent_id']; if (!empty($parent_id) && $parent_id != 0) { $parent_module = getSalesEntityType($parent_id); if ($parent_module == 'Contacts') { $result = $adb->pquery("select * from vtiger_contactdetails where contactid=?", array($parent_id)); $emailoptout = $adb->query_result($result, 0, 'emailoptout'); $contactname = $adb->query_result($result, 0, 'firstname') . ' ' . $adb->query_result($result, 0, 'lastname'); $parentname = $contactname; $contact_mailid = $adb->query_result($result, 0, 'email'); } if ($parent_module == 'Accounts') { $result = $adb->pquery("select * from vtiger_account where accountid=?", array($parent_id)); $emailoptout = $adb->query_result($result, 0, 'emailoptout'); $parentname = $adb->query_result($result, 0, 'accountname'); } if ($contact_mailid != '') { $sql = "select * from vtiger_portalinfo where user_name=?"; $isactive = $adb->query_result($adb->pquery($sql, array($contact_mailid)), 0, 'isactive');
private function x10($x92, $x93, $x94 = false, $x95 = false) { global $x15d, $x15e, $x15f, $x160, $x161, $x162, $x163, $x164, $x165, $x166, $x167, $x168, $x169, $x16a, $x16b, $x16c, $x16d, $x16e, $x16f, $x170, $x171, $x172, $x173, $x174, $x175, $x176, $x177, $x178; $x96 = Users_Record_Model::getCurrentUserModel(); $x97 = array("related_to", "relatedto", "parent_id", "parentid", "product_id", "productid", "service_id", "serviceid", "vendor_id", "product", "account", "invoiceid", "linktoaccountscontacts", "projectid", "sc_related_to"); if ($x95 !== false) { $x98 = array(); } $x51 = getTabid($x92); $x99 = $x92; if ($x94 === false) { $x9a = ""; } else { $x9a = "R_"; if ($x94 !== true) { $x99 = $x94; } } $x9b = array(); $x9c = array(); $x9d = array(); $x9e = array(); $x9f = array(); $xa0 = array(); $xa1 = array(); if ($x51 == '9') { $x3d = "SELECT fieldname, uitype FROM vtiger_field WHERE tabid IN (9,16)"; } else { $x3d = "SELECT fieldname, uitype FROM vtiger_field WHERE tabid = '" . $x51 . "'"; } $x3e = self::$x0f->query($x3d); while ($x42 = self::$x0f->fetchByAssoc($x3e)) { switch ($x42['uitype']) { case '19': case '20': case '21': case '24': $x9d[] = $x42['fieldname']; break; case '5': case '6': case '23': case '70': $x9e[] = $x42['fieldname']; break; case '15': $x9c[] = $x42['fieldname']; break; case '56': $x9b[] = $x42['fieldname']; break; case '33': $x9f[] = $x42['fieldname']; break; case '71': $xa0[] = $x42['fieldname']; break; case '9': $xa1[] = $x42['fieldname']; break; } if ($x42["fieldname"] == "salutationtype") { $x9c[] = $x42["fieldname"]; } } foreach ($x93->column_fields as $xa2 => $x83) { if ($xa2 == "assigned_user_id") { $x83 = $this->x1e($x83); } elseif ($xa2 == "account_id") { $x83 = getAccountName($x83); } elseif ($xa2 == "potential_id") { $x83 = getPotentialName($x83); } elseif ($xa2 == "contact_id") { $x83 = getContactName($x83); } elseif ($xa2 == "quote_id") { $x83 = getQuoteName($x83); } elseif ($xa2 == "salesorder_id") { $x83 = getSoName($x83); } elseif ($xa2 == "campaignid") { $x83 = getCampaignName($x83); } elseif ($xa2 == "terms_conditions") { $x83 = $this->x25($x83); } elseif ($xa2 == "comments") { $x83 = $this->x26($x93); } elseif ($xa2 == "folderid") { $x83 = $this->x27($x83); } elseif ($xa2 == "time_start" || $xa2 == "time_end") { $xa3 = DateTimeField::convertToUserTimeZone($x83); $x83 = $xa3->format('H:i'); } elseif ($x168($xa2, $x97)) { if ($x83 != "") { $xa4 = getSalesEntityType($x83); $xa5 = getEntityName($xa4, $x83); if (!empty($xa5)) { foreach ($xa5 as $xa6) { $x83 = $xa6; } } if ($xa2 == "invoiceid" && $x83 == "0") { $x83 = ""; } } } if ($x168($xa2, $x9e)) { if ($x92 == "Events" || $x92 == "Calendar") { if ($xa2 == "date_start" && $x93->column_fields["time_start"] != "") { $xa3 = $x93->column_fields['time_start']; $x83 = $x83 . ' ' . $xa3; } elseif ($xa2 == "due_date" && $x93->column_fields["time_end"] != "") { $xa3 = $x93->column_fields['time_end']; $x83 = $x83 . ' ' . $xa3; } } if ($x83 != "") { $x83 = getValidDisplayDate($x83); } } elseif ($x168($xa2, $x9c)) { if (!$x168($x178($x83), self::$x18)) { $x83 = $this->x20($x83, $x92); } else { $x83 = ""; } } elseif ($x168($xa2, $x9b)) { if ($x83 == 1) { $x83 = vtranslate('LBL_YES'); } else { $x83 = vtranslate('LBL_NO'); } } elseif ($x168($xa2, $x9d)) { $x83 = $x16d($x83); $x83 = $x165($x83, ENT_QUOTES, self::$x11); } elseif ($x168($xa2, $x9f)) { $x83 = $x173(' |##| ', ', ', $x83); } elseif ($x168($xa2, $xa0)) { if ($x16a($x83)) { if ($x95 === false) { $xa7 = getCurrencySymbolandCRate($x96->currency_id); $xa8 = $xa7["rate"]; } else { $xa8 = $x95["conversion_rate"]; } $x83 = $x83 * $xa8; } $x83 = $this->x23($x83); } elseif ($x168($xa2, $xa1)) { $x83 = $this->x23($x83); } if ($x95 !== false) { $x98[$x175($x92 . "_" . $xa2)] = $x83; } else { self::$x21["\$" . $x9a . $x175($x99 . "_" . $xa2) . "\$"] = $x83; } } if ($x95 !== false) { return $x98; } else { $this->x15(); } }
function module_Chart($user_id, $date_start = "2000-01-01", $end_date = "2017-01-01", $query, $graph_for, $title, $added_qry = "", $module = "", $graph_type) { global $adb, $current_user, $mod_strings, $default_charset; global $days, $date_array, $period_type; if ($added_qry != "") { $query .= $added_qry; } $result = $adb->query($query); $no_of_rows = $adb->num_rows($result); $mod_count_array = array(); $search_str_array = array(); $mod_name_array = array(); $count_by_date[] = array(); $mod_tot_cnt_array = array(); $mod_name_val = ""; $mod_cnt_crtd_date = ""; $target_val = ""; $bar_target_val = ""; $test_target_val = ""; if ($no_of_rows != 0) { while ($row = $adb->fetch_array($result)) { if ($graph_for == 'sostatus' || $graph_for == 'leadsource' || $graph_for == 'leadstatus' || $graph_for == 'industry' || $graph_for == 'productcategory' || $graph_for == 'postatus' || $graph_for == 'invoicestatus' || $graph_for == 'ticketstatus' || $graph_for == 'priority' || $graph_for == 'category' || $graph_for == 'quotestage' || $graph_for == 'salesstage') { $mod_name = getTranslatedString($row[$graph_for]); $search_str = $row[$graph_for]; } else { $mod_name = $row[$graph_for]; $search_str = $row[$graph_for]; } if ($mod_name == "") { $mod_name = $mod_strings["Un Assigned"]; $search_str = " "; } $crtd_time = $row['createdtime']; $crtd_time_array = explode(" ", $crtd_time); $crtd_date = $crtd_time_array[0]; if (!isset($mod_tot_cnt_array[$crtd_date])) { $mod_tot_cnt_array[$crtd_date] = 0; } $mod_tot_cnt_array[$crtd_date] += 1; if (in_array($mod_name, $mod_name_array) == false) { $uniqueid[$mod_name] = '0'; array_push($mod_name_array, $mod_name); // getting all the unique Names into the array if ($graph_for == "productname") { if ($row['qtyinstock'] == '') { $mod_count_array[$mod_name] = 1; } else { $mod_count_array[$mod_name] = $row['qtyinstock']; } } } else { if ($graph_for == "productname") { $uniqueid[$mod_name] = $uniqueid[$mod_name] + 1; $mod_name = $mod_name . '[' . $uniqueid[$mod_name] . ']'; array_push($mod_name_array, $mod_name); // getting all the unique Names into the array if ($row['qtyinstock'] == '') { $mod_count_array[$mod_name] = 1; } else { $mod_count_array[$mod_name] = $row['qtyinstock']; } } } if (in_array($search_str, $search_str_array) == false) { array_push($search_str_array, $search_str); } //Counting the number of values for a type of graph if ($graph_for == "productname") { if ($row['qtyinstock'] == '') { $mod_count_array[$mod_name] = 1; } else { $mod_count_array[$mod_name] = $row['qtyinstock']; } } else { if (!isset($mod_count_array[$mod_name])) { $mod_count_array[$mod_name] = 0; } $mod_count_array[$mod_name]++; } //Counting the number of values for a type of graph for a particular date if (!isset($count_by_date[$mod_name][$crtd_date])) { $count_by_date[$mod_name][$crtd_date] = 0; } $count_by_date[$mod_name][$crtd_date] += 1; } $mod_by_mod_cnt = count($mod_name_array); if ($mod_by_mod_cnt != 0) { $url_string = ""; $mod_cnt_table = "<table border=0 cellspacing=1 cellpadding=3><tr>\r\n\t\t\t\t<th> Status </th>"; //Assigning the Header values to the vtiger_table and giving the dates as graphformat for ($i = 0; $i < $days; $i++) { $tdate = $date_array[$i]; $values = Graph_n_table_format($period_type, $tdate); $graph_format = $values[0]; $table_format = $values[1]; $mod_cnt_table .= "<th>{$table_format}</th>"; } $mod_cnt_table .= "<th>Total</th></tr>"; //For all type of the array for ($i = 0; $i < count($mod_name_array); $i++) { $search_str = $search_str_array[$i]; $mod_name = $mod_name_array[$i]; $id_name = ""; if ($mod_name == "Un Assigned") { $mod_name = $mod_strings["Un Assigned"]; $search_str = " "; } if ($graph_for == "accountid") { $name_val_table = get_account_name($mod_name); } else { $name_val_table = $mod_name; } $mod_cnt_table .= "<tr><td>{$name_val_table}</td>"; $mod_cnt_crtd_date = ""; //For all the days for ($j = 0; $j < $days; $j++) { $tdate = $date_array[$j]; if (!isset($count_by_date[$mod_name][$tdate])) { $count_by_date[$mod_name][$tdate] = "0"; } $cnt_by_date = $count_by_date[$mod_name][$tdate]; $mod_cnt_table .= "<td>{$cnt_by_date} </td>"; if ($i == 0) { $values = Graph_n_table_format($period_type, $tdate); $graph_format = $values[0]; $table_format = $values[1]; //passing the created dates to graph if ($mod_graph_date != "") { $mod_graph_date = "{$mod_graph_date},{$graph_format}"; } else { $mod_graph_date = "{$graph_format}"; } } //passing the name count by date to graph if ($mod_cnt_crtd_date != "") { $mod_cnt_crtd_date .= ",{$cnt_by_date}"; } else { $mod_cnt_crtd_date = "{$cnt_by_date}"; } } $mod_count_val = $mod_count_array[$mod_name]; $tot_mod_cnt = array_sum($count_by_date[$mod_name]); $mod_cnt_table .= "<td align=center>{$tot_mod_cnt}</td></tr>"; if ($graph_for == "accountid") { $name_val = get_account_name($mod_name); if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "smownerid") { $name_val = getOwnerName($mod_name); if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "product_id" || $graph_for == "productid") { $query = "SELECT productname FROM vtiger_products WHERE productid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "productname"); if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "purchaseorderid") { $query = "SELECT subject FROM vtiger_purchaseorder WHERE purchaseorderid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "subject"); $id_name = $mod_name; if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "quoteid") { $query = "SELECT subject FROM vtiger_quotes WHERE quoteid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "subject"); $id_name = $mod_name; if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "invoiceid") { $query = "SELECT subject FROM vtiger_invoice WHERE invoiceid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "subject"); $id_name = $mod_name; if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "campaignid") { //this will return the list of the names of the campaign``:w for the y-axis $query = "SELECT campaignname FROM vtiger_campaign WHERE campaignid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "campaignname"); $id_name = $mod_name; if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "parent_id" || $graph_for == "related_to") { $seType = getSalesEntityType($mod_name); if ($seType == 'Contacts') { $query = "SELECT lastname, firstname FROM vtiger_contactdetails\r\n\t\t\t\t\t\t\tWHERE contactid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "lastname"); if ($name_val != "") { if (getFieldVisibilityPermission('Contacts', $current_user->id, 'firstname') == '0') { $first_name = $adb->query_result($result, 0, "firstname"); if ($first_name != '') { $name_val .= " " . $first_name; } } } } else { $query = "SELECT accountname FROM vtiger_account WHERE accountid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "accountname"); } $mod_name = $name_val; $search_str = $name_val; } //Passing name to graph $mod_name = str_replace(":", ":", $mod_name); if ($mod_name_val != "") { $mod_name_val .= "::{$mod_name}"; } else { $mod_name_val = "{$mod_name}"; } //Passing count to graph if ($mod_cnt_val != "") { $mod_cnt_val .= "::{$mod_count_val}"; } else { $mod_cnt_val = "{$mod_count_val}"; } if ($module != "") { //Check for Ticket Priority if ($graph_type == "ticketsbypriority") { $graph_for = "ticketpriorities"; } //added to get valid url in dashbord for tickets by team if ($graph_for == "smownerid") { $searchField = "assigned_user_id"; } elseif ($graph_for == 'category') { $searchField = 'ticketcategories'; } elseif ($graph_for == 'priority') { $searchField = 'ticketpriorities'; } elseif ($graph_for == "accountid") { $searchField = "account_id"; } else { $searchField = $graph_for; } $cvid = getCvIdOfAll($module); if ($module == "Home") { $cvid = getCvIdOfAll($mod_name); $link_val = "index.php?module=" . $mod_name . "&action=ListView&from_homepagedb=true&type=dbrd&query=true&owner=" . $current_user->user_name . "&viewname=" . $cvid; } else { if ($module == "Contacts" || $module == "Products" && ($graph_for == "quoteid" || $graph_for == "invoiceid" || $graph_for == "purchaseorderid")) { $link_val = "index.php?module=" . $module . "&action=ListView&from_dashboard=true&type=dbrd&query=true&" . $searchField . "=" . $id_name . "&viewname=" . $cvid; } else { $esc_search_str = urlencode($search_str); //$esc_search_str = htmlentities($search_str, ENT_QUOTES, $default_charset); $link_val = "index.php?module=" . $module . "&action=index&from_dashboard=true&search_text=" . $esc_search_str . "&search_field=" . $searchField . "&searchtype=BasicSearch&query=true&type=entchar&operator=e&viewname=" . $cvid; } } //Adding the links to the graph $link_val = str_replace(':', ':', $link_val); if ($i == 0) { $bar_target_val .= $link_val; } else { $bar_target_val .= "::" . $link_val; } } //The data as per given date if ($i == 0) { $urlstring .= $mod_cnt_crtd_date; } else { $urlstring .= "K" . $mod_cnt_crtd_date; } if ($i == 0) { $test_target_val .= $link_val; } else { $test_target_val .= "K" . $link_val; } } $mod_cnt_table .= "</tr><tr><td class=\"{$class}\">Total</td>"; //For all Days getting the vtiger_table for ($k = 0; $k < $days; $k++) { $tdate = $date_array[$k]; if (!isset($mod_tot_cnt_array[$tdate])) { $mod_tot_cnt_array[$tdate] = "0"; } $tot = $mod_tot_cnt_array[$tdate]; if ($period_type != "yday") { $mod_cnt_table .= "<td>{$tot}</td>"; } } if ($graph_for == "productname") { $cnt_total = array_sum($mod_count_array); } else { $cnt_total = array_sum($mod_tot_cnt_array); } $mod_cnt_table .= "<td align=\"center\" class=\"{$class}\">{$cnt_total}</td></tr></table>"; $mod_cnt_table .= "</table>"; $title_of_graph = "{$title} : {$cnt_total}"; $bar_target_val = urlencode($bar_target_val); $test_target_val = urlencode($test_target_val); $Prod_mod_val = array($mod_name_val, $mod_cnt_val, $title_of_graph, $bar_target_val, $mod_graph_date, $urlstring, $mod_cnt_table, $test_target_val); return $Prod_mod_val; } else { $data = 0; } } else { $data = 0; return "<h3> The data is not available with the specified time period</h3>"; } return $data; }
/** * Static Function to get the instance of the Vtiger Record Model given the recordid and the module name * @param <Number> $recordId * @param <String> $moduleName * @return Vtiger_Record_Model or Module Specific Record Model instance */ public static function getInstanceById($recordId, $module = null) { //TODO: Handle permissions if (is_object($module) && is_a($module, 'Vtiger_Module_Model')) { $moduleName = $module->get('name'); } elseif (is_string($module)) { $module = Vtiger_Module_Model::getInstance($module); $moduleName = $module->get('name'); } elseif (empty($module)) { $moduleName = getSalesEntityType($recordId); $module = Vtiger_Module_Model::getInstance($moduleName); } $focus = CRMEntity::getInstance($moduleName); $focus->id = $recordId; $focus->retrieve_entity_info($recordId, $moduleName); $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'Record', $moduleName); $instance = new $modelClassName(); return $instance->setData($focus->column_fields)->set('id', $recordId)->setModuleFromInstance($module)->setEntity($focus); }
static function getTicketComments($ticketid) { $adb = PearDatabase::getInstance(); $moduleName = getSalesEntityType($ticketid); $commentlist = ''; $sql = "SELECT commentcontent FROM vtiger_modcomments WHERE related_to = ?"; $result = $adb->pquery($sql, array($ticketid)); for ($i = 0; $i < $adb->num_rows($result); $i++) { $comment = $adb->query_result($result, $i, 'commentcontent'); if ($comment != '') { $commentlist .= '<br><br>' . $comment; } } if ($commentlist != '') { $commentlist = '<br><br>' . getTranslatedString("The comments are", $moduleName) . ' : ' . $commentlist; } return $commentlist; }
/** * this function takes in an array of values for an user and sanitizes it for export * @param array $arr - the array of values */ function sanitizeValues($arr) { global $current_user, $adb; $roleid = fetchUserRole($current_user->id); foreach ($arr as $fieldlabel => &$value) { $fieldInfo = $this->fieldsArr[$fieldlabel]; $uitype = $fieldInfo['uitype']; $fieldname = $fieldInfo['fieldname']; if ($uitype == 15 || $uitype == 16 || $uitype == 33) { //picklists if (empty($this->picklistValues[$fieldname])) { $this->picklistValues[$fieldname] = getAssignedPicklistValues($fieldname, $roleid, $adb); } $value = trim($value); } elseif ($uitype == 10) { //have to handle uitype 10 $value = trim($value); if (!empty($value)) { $parent_module = getSalesEntityType($value); $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $k => $v) { $displayValue = $v; } } if (!empty($parent_module) && !empty($displayValue)) { $value = $parent_module . "::::" . $displayValue; } else { $value = ""; } } else { $value = ''; } } } return $arr; }
function replaceRelatedModuleFields($content, $module, $recordid, $fields, &$site_URL) { $db = PearDatabase::getInstance(); require_once 'include/utils/utils.php'; $userLang = Users_Record_Model::getCurrentUserModel()->get('language'); include "languages/" . $userLang . "/OSSPdf.php"; require_once 'include/utils/CommonUtils.php'; require_once 'include/fields/CurrencyField.php'; ################################################################################# $uitypelist2 = array('10', '58', '51', '57', '68', '59', '75', '80', '76', '73', '81', '78'); $uitype2module2 = array('58' => 'Campaigns', '51' => 'Accounts', '57' => 'Contacts', '68' => 'Accounts;Contacts', '59' => 'Products', '75' => 'Vendors', '80' => 'SalesOrder', '76' => 'Potentials', '73' => 'Accounts', '81' => 'Vendors', '78' => 'Quotes'); ################################################################################# $uitypelist = array('10', '58', '51', '57', '68', '59', '75', '80', '76', '73', '81', '52', '53', '78'); $uitype2module = array('58' => 'Campaigns', '51' => 'Accounts', '57' => 'Contacts', '68' => 'Accounts;Contacts', '59' => 'Products', '75' => 'Vendors', '80' => 'SalesOrder', '76' => 'Potentials', '73' => 'Accounts', '81' => 'Vendors', '52' => 'Users', '53' => 'Users', '78' => 'Quotes'); ################################################################################# $ui_datefields = array('70', '5', '23'); ################################################################################# $ui_currfields = array('71', '72', '7'); ################################################################################# if ($module == 'Activity') { $wynik = $db->query("select tabid,name from vtiger_tab where name='Calendar'", true); } else { $wynik = $db->query("select tabid,name from vtiger_tab where name='{$module}'", true); } $moduleid = $db->query_result($wynik, 0, "tabid"); $list = array(); $pobierz = $db->query("select fieldid,uitype, fieldname from vtiger_field where tabid = '{$moduleid}'", true); for ($i = 0; $i < $db->num_rows($pobierz); $i++) { $uitype = $db->query_result($pobierz, $i, "uitype"); $fieldid = $db->query_result($pobierz, $i, "fieldid"); if (in_array($uitype, $uitypelist)) { if ($uitype == '10') { $wynik = $db->query("select relmodule from vtiger_fieldmodulerel where fieldid = '{$fieldid}'", true); for ($k = 0; $k < $db->num_rows($wynik); $k++) { $list[$db->query_result($wynik, $k, "relmodule")] = $fields[$db->query_result($pobierz, $i, "fieldname")]; } } else { $zmienna = $uitype2module[$uitype]; $zmienna = explode(';', $zmienna); foreach ($zmienna as $value) { $list[$value] = $fields[$db->query_result($pobierz, $i, "fieldname")]; } } } } if (count($list) > 0) { foreach ($list as $name => $record) { $modulename = $name; require_once "modules/{$modulename}/{$modulename}.php"; if ($modulename == 'Users') { $obiekt = new $modulename(); $pobierz_usera = $db->query("select * from vtiger_users where id = '{$record}'", true); if ($db->num_rows($pobierz_usera) > 0) { $obiekt->retrieve_entity_info($record, $modulename); } } else { $obiekt = new $modulename(); $assigned_module = getSalesEntityType($record); if ($record != 0 && $assigned_module == $modulename) { $obiekt->retrieve_entity_info($record, $modulename); } } $pobierz = $db->query("select tabid from vtiger_tab where name = '{$modulename}'", true); $moduleid = $db->query_result($pobierz, 0, "tabid"); $pobierz_bloki = $db->query("select blockid, blocklabel from vtiger_blocks where tabid = '{$moduleid}'", true); $relatedfield_list = array(); for ($k = 0; $k < $db->num_rows($pobierz_bloki); $k++) { $blockid = $db->query_result($pobierz_bloki, $k, "blockid"); $label = $db->query_result($pobierz_bloki, $k, "blocklabel"); $pobierz_pola = $db->query("select fieldname,fieldlabel,uitype from vtiger_field where block='{$blockid}' and tabid = '{$moduleid}'", true); for ($i = 0; $i < $db->num_rows($pobierz_pola); $i++) { $field_uitype = $db->query_result($pobierz_pola, $i, "uitype"); $label = $db->query_result($pobierz_pola, $i, "fieldlabel"); $key = $db->query_result($pobierz_pola, $i, "fieldname"); $value = $obiekt->column_fields[$key]; ################################################ /// Dla pól z datą if (in_array($field_uitype, $ui_datefields)) { $value = getValidDisplayDate($value); } ################################################ /// Dla pól z walutami if (in_array($field_uitype, $ui_currfields)) { $currfield = new CurrencyField($value); $value = $currfield->getDisplayValue(); } //// Dla pola z językiem użytkownika if ($field_uitype == 27) { if ($value == 'I') { $value = getTranslatedString('Internal', $modulename); } elseif ($value == 'E') { $value = getTranslatedString('External', $modulename); } } if ($field_uitype == 32) { $name = '%' . $value . '%'; $new_value = $db->query("select name from vtiger_language where prefix like '{$name}'", true); $value = getTranslatedString($db->query_result($new_value, 0, "name")); } /// dla pól z przypisanym użytkownikie, if ($field_uitype == 53 || $field_uitype == 52) { $value = getUserName($value); } /// dla pól z folderem /*if( $field_uitype == 26 ) { $new_value = $db->query( "select foldername from vtiger_attachmentsfolder where folderid = '$value'", true ); $value = $db->query_result( $new_value, 0, "foldername" ); }*/ /// Dla pól z roląużytkownika w organizacji if ($field_uitype == 98) { $new_value = $db->query("select rolename from vtiger_role where roleid = '{$value}'", true); $value = $db->query_result($new_value, 0, "rolename"); } /// Dla pól typu checkbox if ($field_uitype == 56) { if ($value == 1) { $value = getTranslatedString('yes', "OSSPdf"); } elseif ($value == 0) { $value = getTranslatedString('no', "OSSPdf"); } } /// Dla pola ze zdjęciem użytkownika if ($field_uitype == 105) { include_once "modules/OSSPdf/small_config.php"; if ($value != "") { $sql = "SELECT CONCAT(vtiger_attachments.path,vtiger_attachments.attachmentsid,'_',vtiger_users.imagename) AS sciezka FROM vtiger_attachments\n INNER JOIN vtiger_salesmanattachmentsrel ON ( vtiger_salesmanattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid )\n INNER JOIN vtiger_users ON ( vtiger_users.id = vtiger_salesmanattachmentsrel.smid )\n WHERE vtiger_salesmanattachmentsrel.smid = '{$record}'"; $pobierz_zdjecie = $db->query($sql, true); if ($db->num_rows($pobierz_zdjecie) > 0) { $value = '<img src="' . $site_URL . '/' . $db->query_result($pobierz_zdjecie, 0, "sciezka") . '" width="' . $UserImage_width . 'px" height="' . $UserImage_height . 'px"></img>'; } } } /// Dla pól typu lista wyboru if ($field_uitype == 15 || $field_uitype == 16 || $field_uitype == 55 && $key == 'salutationtype') { $value = getTranslatedString($value, $modulename); } if ($field_uitype == 83) { $pobierz_tax = $db->query("select * from vtiger_producttaxrel where productid = '{$record}'", true); for ($a = 0; $a < $db->num_rows($pobierz_tax); $a++) { $taxid = $db->query_result($pobierz_tax, $a, "taxid"); $taxvalue = $db->query_result($pobierz_tax, $a, "taxpercentage"); if ($taxid == 1) { $value .= getTranslatedString('LBL_VAT') . getTranslatedString('COVERED_PERCENTAGE') . ': ' . $taxvalue . '%'; } elseif ($taxid == 2) { $value .= getTranslatedString('LBL_SALES') . getTranslatedString('COVERED_PERCENTAGE') . ': ' . $taxvalue . '%'; } elseif ($taxid == 3) { $value .= getTranslatedString('LBL_SERVICE') . getTranslatedString('COVERED_PERCENTAGE') . ': ' . $taxvalue . '%'; } $value .= '<br/>'; } } ######################## if (in_array($field_uitype2, $uitypelist2)) { if ($field_uitype == 10) { $pobierz_wartosc = $db->query("select relmodule from vtiger_fieldmodulerel where fieldid = '{$fieldid}'", true); for ($i = 0; $i < $db->num_rows($pobierz_wartosc); $i++) { $module .= $db->query_result($pobierz_wartosc, $i, "relmodule") . ';'; } } else { $module = $uitype2module[$field_uitype]; } $module = trim($module, ';'); $ids = explode(';', $module); foreach ($ids as $singleid) { $newvalue = $db->query("select tablename, entityidfield,fieldname from vtiger_entityname where modulename = '{$singleid}'", true); $tablename = $db->query_result($newvalue, 0, "tablename"); $fieldname = $db->query_result($newvalue, 0, "fieldname"); $tableid = $db->query_result($newvalue, 0, "entityidfield"); $newvalue2 = $db->query("select {$fieldname} from {$tablename} where {$tableid} = '{$value}'", true); $value = $db->query_result($newvalue2, 0, $fieldname); } } ######################## if ($field_uitype == 10 && is_numeric($value)) { if ($value != 0) { $value = Vtiger_Functions::getCRMRecordLabel($value); } elseif ($value == 0) { $value = ''; } } $string = "#" . $modulename . "_" . $key . "#"; $string2 = "#" . $modulename . "_label_" . $key . "#"; //."# TLUMACZENIE: ". getTranslatedString( $label, $modulename ); $pozycja = (int) strpos($content, $string2); $content = str_replace($string2, getTranslatedString($label, $modulename), $content); if ($record != 0 && ($assigned_module == $modulename || $modulename == 'Users')) { $content = str_replace($string, $value, $content); } else { $content = str_replace($string, '', $content); } } } } } return $content; }
/** * this function takes in an array of values for an user and sanitizes it for export * @param array $arr - the array of values */ function sanitizeValues($arr) { global $current_user, $adb; $roleid = fetchUserRole($current_user->id); $decimal = $current_user->currency_decimal_separator; $numsep = $current_user->currency_grouping_separator; foreach ($arr as $fieldlabel => &$value) { $fieldInfo = $this->fieldsArr[$fieldlabel]; $uitype = $fieldInfo['uitype']; $fieldname = $fieldInfo['fieldname']; if ($uitype == 15 || $uitype == 16 || $uitype == 33) { //picklists if (empty($this->picklistValues[$fieldname])) { $this->picklistValues[$fieldname] = getAssignedPicklistValues($fieldname, $roleid, $adb); } $value = trim($value); } elseif ($uitype == 10) { //have to handle uitype 10 $value = trim($value); if (!empty($value)) { $parent_module = getSalesEntityType($value); $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $k => $v) { $displayValue = $v; } } if (!empty($parent_module) && !empty($displayValue)) { $value = $parent_module . "::::" . $displayValue; } else { $value = ""; } } else { $value = ''; } } elseif ($uitype == 71 || $uitype == 72) { $value = CurrencyField::convertToUserFormat($value, null, true); } elseif ($uitype == 7 || $fieldInfo['typeofdata'] == 'N~O' || $uitype == 9) { $value = number_format($value, 2, $decimal, $numsep); } } return $arr; }
$crmid = vtlib_purify($_REQUEST['invmodid']); switch (getSalesEntityType($crmid)) { case 'Invoice': $emailcrmid = $adb->query_result($adb->pquery('select case accountid when 0 then contactid else accountid end from vtiger_invoice where invoiceid=?', array($crmid)), 0, 0); break; case 'Quotes': $emailcrmid = $adb->query_result($adb->pquery('select case accountid when 0 then contactid else accountid end from vtiger_quotes where quoteid=?', array($crmid)), 0, 0); break; case 'SalesOrder': $emailcrmid = $adb->query_result($adb->pquery('select case accountid when 0 then contactid else accountid end from vtiger_salesorder where salesorderid=?', array($crmid)), 0, 0); break; case 'PurchaseOrder': $emailcrmid = $adb->query_result($adb->pquery('select case vendorid when 0 then contactid else vendorid end from vtiger_purchaseorder where purchaseorderid=?', array($crmid)), 0, 0); 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; } $_REQUEST["idlist"] = $emailcrmid; $mailids = get_to_emailids($pmodule); if ($mailids['mailds'] != '') { $to_add = trim($mailids['mailds'], ",") . ",";
/** This function returns the detail view form vtiger_field and and its properties in array format. * Param $uitype - UI type of the vtiger_field * Param $fieldname - Form vtiger_field name * Param $fieldlabel - Form vtiger_field label name * Param $col_fields - array contains the vtiger_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $tabid - vtiger_tab id to which the Field belongs to (default is "") * Return type is an array */ function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid = '', $module = '') { global $log; $log->debug("Entering getDetailViewOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $col_fields . "," . $generatedtype . "," . $tabid . ") method ..."); global $adb; global $mod_strings; global $app_strings; global $current_user; global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $fieldlabel = from_html($fieldlabel); $custfld = ''; $value = ''; $arr_data = array(); $label_fld = array(); $data_fld = array(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; // vtlib customization: New uitype to handle relation between modules if ($uitype == '10') { $fieldlabel = getTranslatedString($fieldlabel, $module); $parent_id = $col_fields[$fieldname]; if (!empty($parent_id)) { $parent_module = getSalesEntityType($parent_id); $valueTitle = getTranslatedString($parent_module, $parent_module); $displayValueArray = getEntityName($parent_module, $parent_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $displayValue = $value; } } // vtlib customization: For listview javascript triggers $modMetaInfo = getEntityFieldNames($parent_module); $modEName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname']; $vtlib_metainfo = "<span type='vtlib_metainfo' vtrecordid='{$parent_id}' vtfieldname=" . "'{$modEName}' vtmodule='{$parent_module}' style='display:none;'></span>"; // END $label_fld = array($fieldlabel, "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>{$vtlib_metainfo}"); } else { $moduleSpecificMessage = 'MODULE_NOT_SELECTED'; if ($mod_strings[$moduleSpecificMessage] != "") { $moduleSpecificMessage = $mod_strings[$moduleSpecificMessage]; } $label_fld = array($fieldlabel, ''); } } else { if ($uitype == 99) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; if ($fieldname == 'confirm_password') { return null; } } elseif ($uitype == 116 || $uitype == 117) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getCurrencyName($col_fields[$fieldname]); $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name'); $currency_id = $adb->query_result($pickListResult, $j, 'id'); if ($col_fields[$fieldname] == $currency_id) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[$currency_id] = array($pickListValue => $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 13 || $uitype == 104) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 16) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getTranslatedString($col_fields[$fieldname], $module); $fieldname = $adb->sql_escape_string($fieldname); $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid"; $params = array(); $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $count = 0; $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname))); $col_fields[$fieldname] = decode_html($col_fields[$fieldname]); if ($col_fields[$fieldname] == $pickListValue) { $chk_val = "selected"; $count++; $found = true; } else { $chk_val = ''; } $pickListValue = to_html($pickListValue); $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 15) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; $roleid = $current_user->roleid; $valueArr = explode("|##|", $col_fields[$fieldname]); $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $count = 0; $found = false; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { if (in_array(trim($pickListValue), array_map("trim", $valueArr))) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected'); } } $label_fld["options"] = $options; } elseif ($uitype == 115) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getTranslatedString($col_fields[$fieldname]); $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname); $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname)); if ($col_fields[$fieldname] == $pickListValue) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 33) { //uitype 33 added for multiselector picklist - Jeri $roleid = $current_user->roleid; $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = str_ireplace(' |##| ', ', ', $col_fields[$fieldname]); $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); $options = array(); $selected_entries = array(); $selected_entries = explode(' |##| ', $col_fields[$fieldname]); if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { foreach ($selected_entries as $selected_entries_value) { if (trim($selected_entries_value) == trim(htmlentities($pickListValue, ENT_QUOTES, $default_charset))) { $chk_val = 'selected'; $pickcount++; break; } else { $chk_val = ''; } } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $not_access_lbl = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; $options[] = array($not_access_lbl, trim($selected_entries_value), 'selected'); } } $label_fld["options"] = $options; } elseif ($uitype == 17) { $label_fld[] = getTranslatedString($fieldlabel, $module); $matchPattern = "^[\\w]+:\\/\\/^"; $value = $col_fields[$fieldname]; preg_match($matchPattern, $value, $matches); if (!empty($matches[0])) { $fieldValue = str_replace($matches, "", $value); $label_fld[] = $value; } else { if ($value != null) { $label_fld[] = 'http://' . $value; } else { $label_fld[] = ''; } } } elseif ($uitype == 19) { if ($fieldname == 'notecontent' or $module == 'Timecontrol') { $col_fields[$fieldname] = decode_html($col_fields[$fieldname]); } else { $col_fields[$fieldname] = str_replace("<br />", "<br>", $col_fields[$fieldname]); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 20 || $uitype == 21 || $uitype == 22 || $uitype == 24) { // Armando LC<scher 11.08.2005 -> B'descriptionSpan -> Desc: removed $uitype == 19 and made an aditional elseif above if ($uitype == 20) { //Fix the issue #4680 $col_fields[$fieldname] = $col_fields[$fieldname]; } else { $col_fields[$fieldname] = nl2br($col_fields[$fieldname]); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { $account_id = $col_fields[$fieldname]; if ($account_id != '') { $account_name = getAccountName($account_id); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $account_name; $label_fld["secid"] = $account_id; $label_fld["link"] = "index.php?module=Accounts&action=DetailView&record=" . $account_id; //Account Name View } elseif ($uitype == 52 || $uitype == 77 || $uitype == 101) { $label_fld[] = getTranslatedString($fieldlabel, $module); $user_id = $col_fields[$fieldname]; $user_name = getOwnerName($user_id); if ($user_id != '') { $assigned_user_id = $user_id; } else { $assigned_user_id = $current_user->id; } if (is_admin($current_user)) { $label_fld[] = '<a href="index.php?module=Users&action=DetailView&record=' . $user_id . '">' . $user_name . '</a>'; } else { $label_fld[] = $user_name; } if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $user_id), $assigned_user_id); } $label_fld["options"] = $users_combo; } elseif ($uitype == 11) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 53) { global $noof_group_rows, $adb; $owner_id = $col_fields[$fieldname]; $user = '******'; $result = $adb->pquery("SELECT count(*) as count from vtiger_users where id = ?", array($owner_id)); if ($adb->query_result($result, 0, 'count') > 0) { $user = '******'; } $owner_name = getOwnerName($owner_id); $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $owner_name; if (is_admin($current_user)) { $label_fld["secid"][] = $owner_id; if ($user == 'no') { $label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=" . $owner_id; } else { $label_fld["link"][] = "index.php?module=Users&action=DetailView&record=" . $owner_id; } //$label_fld["secid"][] = $groupid; //$label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=".$groupid; } //Security Checks if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $result = get_current_user_access_groups($module_name); } else { $result = get_group_options(); } if ($result) { $nameArray = $adb->fetch_array($result); } global $current_user; //$value = $user_id; if ($owner_id != '') { if ($user == 'yes') { $label_fld["options"][] = 'User'; $assigned_user_id = $owner_id; $user_checked = "checked"; $team_checked = ''; $user_style = 'display:block'; $team_style = 'display:none'; } else { //$record = $col_fields["record_id"]; //$module = $col_fields["record_module"]; $label_fld["options"][] = 'Group'; $assigned_group_id = $owner_id; $user_checked = ''; $team_checked = 'checked'; $user_style = 'display:none'; $team_style = 'display:block'; } } else { $label_fld["options"][] = 'User'; $assigned_user_id = $current_user->id; $user_checked = "checked"; $team_checked = ''; $user_style = 'display:block'; $team_style = 'display:none'; } if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id), $assigned_user_id); } if ($noof_group_rows != 0) { if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id, 'private'), $current_user->id); } else { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id), $current_user->id); } } $label_fld["options"][] = $users_combo; $label_fld["options"][] = $groups_combo; } elseif ($uitype == 55 || $uitype == 255) { if ($tabid == 4) { $query = "select vtiger_contactdetails.imagename from vtiger_contactdetails where contactid=?"; $result = $adb->pquery($query, array($col_fields['record_id'])); $imagename = $adb->query_result($result, 0, 'imagename'); if ($imagename != '') { $imgpath = "test/contact/" . $imagename; $label_fld[] = getTranslatedString($fieldlabel, $module); } else { $label_fld[] = getTranslatedString($fieldlabel, $module); } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); } $value = $col_fields[$fieldname]; if ($uitype == 255) { global $currentModule; $fieldpermission = getFieldVisibilityPermission($currentModule, $current_user->id, 'firstname'); } if ($uitype == 255 && $fieldpermission == 0 && $fieldpermission != '') { $fieldvalue[] = ''; } else { $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = implode("','", $subrole); $roleids = $roleids . "','" . $roleid; } else { $roleids = $roleid; } if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $pick_query = "select salutationtype from vtiger_salutationtype order by salutationtype"; $params = array(); } else { $pick_query = "select * from vtiger_salutationtype left join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid=vtiger_salutationtype.picklist_valueid where picklistid in (select picklistid from vtiger_picklist where name='salutationtype') and roleid=? order by salutationtype"; $params = array($current_user->roleid); } $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $sal_value = $col_fields["salutationtype"]; $salcount = 0; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, "salutationtype"); if ($sal_value == $pickListValue) { $chk_val = "selected"; $salcount++; } else { $chk_val = ''; } } if ($salcount == 0 && $sal_value != '') { $notacc = $app_strings['LBL_NOT_ACCESSIBLE']; } $sal_value = $col_fields["salutationtype"]; if ($sal_value == '--None--') { $sal_value = ''; } $label_fld["salut"] = getTranslatedString($sal_value); $label_fld["notaccess"] = $notacc; } $label_fld[] = $value; } elseif ($uitype == 56) { $label_fld[] = getTranslatedString($fieldlabel, $module); $value = $col_fields[$fieldname]; if ($value == 1) { //Since "yes" is not been translated it is given as app strings here.. $displayValue = $app_strings['yes']; } else { $displayValue = $app_strings['no']; } $label_fld[] = $displayValue; } elseif ($uitype == 156) { $label_fld[] = getTranslatedString($fieldlabel, $module); $value = $col_fields[$fieldname]; if ($value == 'on') { //Since "yes" is not been translated it is given as app strings here.. $displayValue = $app_strings['yes']; } else { $displayValue = $app_strings['no']; } $label_fld[] = $displayValue; } elseif ($uitype == 57) { $label_fld[] = getTranslatedString($fieldlabel, $module); $contact_id = $col_fields[$fieldname]; if ($contact_id != '') { $displayValueArray = getEntityName('Contacts', $contact_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } } $label_fld[] = $contact_name; $label_fld["secid"] = $contact_id; $label_fld["link"] = "index.php?module=Contacts&action=DetailView&record=" . $contact_id; } elseif ($uitype == 58) { $label_fld[] = getTranslatedString($fieldlabel, $module); $campaign_id = $col_fields[$fieldname]; if ($campaign_id != '') { $campaign_name = getCampaignName($campaign_id); } $label_fld[] = $campaign_name; $label_fld["secid"] = $campaign_id; $label_fld["link"] = "index.php?module=Campaigns&action=DetailView&record=" . $campaign_id; } elseif ($uitype == 59) { $label_fld[] = getTranslatedString($fieldlabel, $module); $product_id = $col_fields[$fieldname]; if ($product_id != '') { $product_name = getProductName($product_id); } //Account Name View $label_fld[] = $product_name; $label_fld["secid"] = $product_id; $label_fld["link"] = "index.php?module=Products&action=DetailView&record=" . $product_id; } elseif ($uitype == 61) { global $adb; $label_fld[] = getTranslatedString($fieldlabel, $module); if ($tabid == 10) { $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])); for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) { $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid'); if ($attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); if ($attachmentsname != '') { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '">' . $attachmentsname . '</a>'; } else { $custfldval = ''; } } $label_fld['options'][] = $custfldval; } } else { $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } //This is added to strip the crmid and _ from the file name and show the original filename //$org_filename = ltrim($col_fields[$fieldname],$col_fields['record_id'].'_'); /* Above line is not required as the filename in the database is stored as it is and doesn't have crmid attached to it. This was the cause for the issue reported in ticket #4645 */ $org_filename = $col_fields[$fieldname]; // For Backward Compatibility version < 5.0.4 $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_'); if ($filename_pos === 0) { $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_'); $org_filename = substr($org_filename, $start_idx); } if ($org_filename != '') { if ($col_fields['filelocationtype'] == 'E') { if ($col_fields['filestatus'] == 1) { //&& strlen($col_fields['filename']) > 7 ){ $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } elseif ($col_fields['filelocationtype'] == 'I') { if ($col_fields['filestatus'] == 1) { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } else { $custfldval = ''; } } $label_fld[] = $custfldval; } } elseif ($uitype == 28) { $label_fld[] = getTranslatedString($fieldlabel, $module); $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } $org_filename = $col_fields[$fieldname]; // For Backward Compatibility version < 5.0.4 $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_'); if ($filename_pos === 0) { $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_'); $org_filename = substr($org_filename, $start_idx); } if ($org_filename != '') { if ($col_fields['filelocationtype'] == 'E') { if ($col_fields['filestatus'] == 1) { //&& strlen($col_fields['filename']) > 7 ){ $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } elseif ($col_fields['filelocationtype'] == 'I') { if ($col_fields['filestatus'] == 1) { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } else { $custfldval = ''; } } $label_fld[] = $custfldval; } elseif ($uitype == 69) { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($tabid == 14) { $images = array(); $query = 'select productname, vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?'; $result_image = $adb->pquery($query, array($col_fields['record_id'])); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name'))); $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name')); $imagepath_array[] = $adb->query_result($result_image, $image_iter, 'path'); } if (count($image_array) > 1) { if (count($image_array) < 4) { $sides = count($image_array) * 2; } else { $sides = 8; } $image_lists = '<div id="Carousel" style="position:relative;vertical-align: middle;"> <img src="modules/Products/placeholder.gif" width="571" height="117" style="position:relative;"> </div><script>var Car_NoOfSides=' . $sides . '; Car_Image_Sources=new Array('; for ($image_iter = 0; $image_iter < count($image_array); $image_iter++) { $images[] = '"' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '","' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '"'; } $image_lists .= implode(',', $images) . ');</script><script language="JavaScript" type="text/javascript" src="modules/Products/Productsslide.js"></script><script language="JavaScript" type="text/javascript">Carousel();</script>'; $label_fld[] = $image_lists; } elseif (count($image_array) == 1) { list($pro_image_width, $pro_image_height) = getimagesize($imagepath_array[0] . $image_id_array[0] . "_" . $image_orgname_array[0]); if ($pro_image_width > 450 || $pro_image_height > 300) { $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="450" height="300">'; } else { $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="' . $pro_image_width . '" height="' . $pro_image_height . '">'; } } else { $label_fld[] = ''; } } else { if ($module == 'Contacts') { $imageattachment = 'Image'; } else { $imageattachment = 'Attachment'; } //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t from vtiger_attachments\n\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t and vtiger_attachments.name = ?\n\t\t\t and vtiger_seattachmentsrel.crmid=?"; $image_res = $adb->pquery($sql, array($col_fields[$fieldname], $col_fields['record_id'])); $image_id = $adb->query_result($image_res, 0, 'attachmentsid'); $image_path = $adb->query_result($image_res, 0, 'path'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_name = urlencode(decode_html($adb->query_result($image_res, 0, 'name'))); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { $ftype = $adb->query_result($image_res, 0, 'type'); $isimage = stripos($ftype, 'image') !== false; if ($isimage) { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image'); $label_fld[] = '<img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 500px;">'; } else { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents'); $label_fld[] = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>'; } } else { $label_fld[] = ''; } } } elseif ($uitype == 62) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } elseif ($parent_module == "Potentials") { $label_fld[] = $app_strings['LBL_POTENTIAL_NAME']; $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $potentialname = $adb->query_result($result, 0, "potentialname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>'; } elseif ($parent_module == "Products") { $label_fld[] = $app_strings['LBL_PRODUCT_NAME']; $sql = "select * from vtiger_products where productid=?"; $result = $adb->pquery($sql, array($value)); $productname = $adb->query_result($result, 0, "productname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $productname . '</a>'; } elseif ($parent_module == "PurchaseOrder") { $label_fld[] = $app_strings['LBL_PORDER_NAME']; $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $pordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>'; } elseif ($parent_module == "SalesOrder") { $label_fld[] = $app_strings['LBL_SORDER_NAME']; $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $sordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>'; } elseif ($parent_module == "Invoice") { $label_fld[] = $app_strings['LBL_INVOICE_NAME']; $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $invoicename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>'; } elseif ($parent_module == "Quotes") { $label_fld[] = $app_strings['LBL_QUOTES_NAME']; $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $quotename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>'; } elseif ($parent_module == "HelpDesk") { $label_fld[] = $app_strings['LBL_HELPDESK_NAME']; $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $title = $adb->query_result($result, 0, "title"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $title . '</a>'; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 105) { //Added for user image $label_fld[] = getTranslatedString($fieldlabel, $module); //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.* from vtiger_attachments left join vtiger_salesmanattachmentsrel on vtiger_salesmanattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_salesmanattachmentsrel.smid=?"; $image_res = $adb->pquery($sql, array($col_fields['record_id'])); $image_id = $adb->query_result($image_res, 0, 'attachmentsid'); $image_path = $adb->query_result($image_res, 0, 'path'); $image_name = $adb->query_result($image_res, 0, 'name'); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { //Added the following check for the image to retain its in original size. list($pro_image_width, $pro_image_height) = getimagesize(decode_html($imgpath)); $label_fld[] = '<a href="' . $imgpath . '" target="_blank"><img src="' . $imgpath . '" width="' . $pro_image_width . '" height="' . $pro_image_height . '" alt="' . $col_fields['user_name'] . '" title="' . $col_fields['user_name'] . '" border="0"></a>'; } else { $label_fld[] = ''; } } elseif ($uitype == 66) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } elseif ($parent_module == "Potentials") { $label_fld[] = $app_strings['LBL_POTENTIAL_NAME']; $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $potentialname = $adb->query_result($result, 0, "potentialname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>'; } elseif ($parent_module == "Quotes") { $label_fld[] = $app_strings['LBL_QUOTE_NAME']; $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $quotename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>'; } elseif ($parent_module == "PurchaseOrder") { $label_fld[] = $app_strings['LBL_PORDER_NAME']; $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $pordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>'; } elseif ($parent_module == "SalesOrder") { $label_fld[] = $app_strings['LBL_SORDER_NAME']; $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $sordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>'; } elseif ($parent_module == "Invoice") { $label_fld[] = $app_strings['LBL_INVOICE_NAME']; $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $invoicename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>'; } elseif ($parent_module == "Campaigns") { $label_fld[] = $app_strings['LBL_CAMPAIGN_NAME']; $sql = "select * from vtiger_campaign where campaignid=?"; $result = $adb->pquery($sql, array($value)); $campaignname = $adb->query_result($result, 0, "campaignname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $campaignname . '</a>'; } elseif ($parent_module == "HelpDesk") { $label_fld[] = $app_strings['LBL_HELPDESK_NAME']; $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $tickettitle = $adb->query_result($result, 0, "title"); if (strlen($tickettitle) > 25) { $tickettitle = substr($tickettitle, 0, 25) . '...'; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $tickettitle . '</a>'; } elseif ($parent_module == "Vendors") { //MSL $label_fld[] = $app_strings['LBL_VENDOR_NAME']; $sql = "select vendorname from vtiger_vendor where vendorid=?"; $result = $adb->pquery($sql, array($value)); $vendor_name = $adb->query_result($result, 0, "vendorname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $vendor_name . '</a>'; } //MSL ------------------------------------------- } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 67) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 357) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_name = ''; $parent_id = ''; $myemailid = $_REQUEST['record']; $mysql = "select crmid from vtiger_seactivityrel where activityid=?"; $myresult = $adb->pquery($mysql, array($myemailid)); $mycount = $adb->num_rows($myresult); if ($mycount > 1) { $label_fld[] = $app_strings['LBL_RELATED_TO']; $label_fld[] = $app_strings['LBL_MULTIPLE']; } else { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $accountname = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $accountname . '</a>'; } } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 68) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } else { $value = ''; $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 63) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname] . 'h ' . $col_fields['duration_minutes'] . 'm'; } elseif ($uitype == 6) { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname] == '0') { $col_fields[$fieldname] = ''; } if ($col_fields['time_start'] != '') { $start_time = $col_fields['time_start']; } $dateValue = $col_fields[$fieldname]; if ($col_fields[$fieldname] == '0000-00-00' || empty($dateValue)) { $displayValue = ''; } else { if (empty($start_time) && strpos($col_fields[$fieldname], ' ') == false) { $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]); } else { if (!empty($start_time)) { $date = new DateTimeField($col_fields[$fieldname] . ' ' . $start_time); } else { $date = new DateTimeField($col_fields[$fieldname]); } $displayValue = $date->getDisplayDateTimeValue(); } } $label_fld[] = $displayValue; } elseif ($uitype == 5 || $uitype == 23 || $uitype == 70) { $label_fld[] = getTranslatedString($fieldlabel, $module); $dateValue = $col_fields[$fieldname]; if ($col_fields['time_end'] != '' && ($tabid == 9 || $tabid == 16) && $uitype == 23) { $end_time = $col_fields['time_end']; } if ($dateValue == '0000-00-00' || empty($dateValue)) { $displayValue = ''; } else { if (empty($end_time) && strpos($dateValue, ' ') == false) { $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]); } else { if (!empty($end_time)) { $date = new DateTimeField($col_fields[$fieldname] . ' ' . $end_time); } else { $date = new DateTimeField($col_fields[$fieldname]); } $displayValue = $date->getDisplayDateTimeValue(); } } $label_fld[] = $displayValue; } elseif ($uitype == 71 || $uitype == 72) { $label_fld[] = getTranslatedString($fieldlabel, $module); $currencyField = new CurrencyField($col_fields[$fieldname]); if ($uitype == 72) { // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($fieldname == 'unit_price') { $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module)); $label_fld[] = $currencyField->getDisplayValue(null, true); $label_fld["cursymb"] = $rate_symbol['symbol']; } else { $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']); $label_fld[] = $currencyField->getDisplayValue(null, true); $label_fld["cursymb"] = $currency_info['currency_symbol']; } } else { $label_fld[] = $currencyField->getDisplayValue(); $label_fld["cursymb"] = $currencyField->getCurrencySymbol(); } } elseif ($uitype == 75 || $uitype == 81) { $label_fld[] = getTranslatedString($fieldlabel, $module); $vendor_id = $col_fields[$fieldname]; if ($vendor_id != '') { $vendor_name = getVendorName($vendor_id); } $label_fld[] = $vendor_name; $label_fld["secid"] = $vendor_id; $label_fld["link"] = "index.php?module=Vendors&action=DetailView&record=" . $vendor_id; } elseif ($uitype == 76) { $label_fld[] = getTranslatedString($fieldlabel, $module); $potential_id = $col_fields[$fieldname]; if ($potential_id != '') { $potential_name = getPotentialName($potential_id); } $label_fld[] = $potential_name; $label_fld["secid"] = $potential_id; $label_fld["link"] = "index.php?module=Potentials&action=DetailView&record=" . $potential_id; } elseif ($uitype == 78) { $label_fld[] = getTranslatedString($fieldlabel, $module); $quote_id = $col_fields[$fieldname]; if ($quote_id != '') { $quote_name = getQuoteName($quote_id); } $label_fld[] = $quote_name; $label_fld["secid"] = $quote_id; $label_fld["link"] = "index.php?module=Quotes&action=DetailView&record=" . $quote_id; } elseif ($uitype == 79) { $label_fld[] = getTranslatedString($fieldlabel, $module); $purchaseorder_id = $col_fields[$fieldname]; if ($purchaseorder_id != '') { $purchaseorder_name = getPoName($purchaseorder_id); } $label_fld[] = $purchaseorder_name; $label_fld["secid"] = $purchaseorder_id; $label_fld["link"] = "index.php?module=PurchaseOrder&action=DetailView&record=" . $purchaseorder_id; } elseif ($uitype == 80) { $label_fld[] = getTranslatedString($fieldlabel, $module); $salesorder_id = $col_fields[$fieldname]; if ($salesorder_id != '') { $salesorder_name = getSoName($salesorder_id); } $label_fld[] = $salesorder_name; $label_fld["secid"] = $salesorder_id; $label_fld["link"] = "index.php?module=SalesOrder&action=DetailView&record=" . $salesorder_id; } elseif ($uitype == 30) { $rem_days = 0; $rem_hrs = 0; $rem_min = 0; $reminder_str = ""; $rem_days = floor($col_fields[$fieldname] / (24 * 60)); $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60); $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60; $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname]) { $reminder_str = $rem_days . ' ' . $mod_strings['LBL_DAYS'] . ' ' . $rem_hrs . ' ' . $mod_strings['LBL_HOURS'] . ' ' . $rem_min . ' ' . $mod_strings['LBL_MINUTES'] . ' ' . $mod_strings['LBL_BEFORE_EVENT']; } $label_fld[] = ' ' . $reminder_str; } elseif ($uitype == 98) { $label_fld[] = getTranslatedString($fieldlabel, $module); if (is_admin($current_user)) { $label_fld[] = '<a href="index.php?module=Settings&action=RoleDetailView&roleid=' . $col_fields[$fieldname] . '">' . getRoleName($col_fields[$fieldname]) . '</a>'; } else { $label_fld[] = getRoleName($col_fields[$fieldname]); } } elseif ($uitype == 85) { //Added for Skype by Minnie $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 26) { $label_fld[] = getTranslatedString($fieldlabel, $module); $query = "select foldername from vtiger_attachmentsfolder where folderid = ?"; $result = $adb->pquery($query, array($col_fields[$fieldname])); $folder_name = $adb->query_result($result, 0, "foldername"); $label_fld[] = $folder_name; } elseif ($uitype == 27) { if ($col_fields[$fieldname] == 'I') { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $mod_strings['LBL_INTERNAL']; } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $mod_strings['LBL_EXTERNAL']; } } elseif ($uitype == 31) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; $options = array(); $themeList = get_themes(); foreach ($themeList as $theme) { if ($current_user->theme == $theme) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($theme), $theme, $selected); } $label_fld["options"] = $options; } elseif ($uitype == 32) { $options = array(); $languageList = Vtiger_Language::getAll(); $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = isset($languageList[$col_fields[$fieldname]]) ? $languageList[$col_fields[$fieldname]] : $col_fields[$fieldname]; foreach ($languageList as $prefix => $label) { if ($current_user->language == $prefix) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($label), $prefix, $selected); } $label_fld["options"] = $options; } else { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname] == '0' && $fieldname != 'filedownloadcount' && $fieldname != 'filestatus' && $fieldname != 'filesize') { $col_fields[$fieldname] = ''; } //code for Documents module :start if ($tabid == 8) { $downloadtype = $col_fields['filelocationtype']; if ($fieldname == 'filename') { if ($downloadtype == 'I') { //$file_value = $mod_strings['LBL_INTERNAL']; $fld_value = $col_fields['filename']; $ext_pos = strrpos($fld_value, "."); $ext = substr($fld_value, $ext_pos + 1); $ext = strtolower($ext); if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } else { $fld_value = $col_fields['filename']; $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' title='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' hspace='3' align='absmiddle' border='0'>"; } $label_fld[] = $fileicon . $fld_value; } if ($fieldname == 'filesize') { if ($col_fields['filelocationtype'] == 'I') { $filesize = $col_fields[$fieldname]; if ($filesize < 1024) { $label_fld[] = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $label_fld[] = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $label_fld[] = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $label_fld[] = ' --'; } } if ($fieldname == 'filetype' && $col_fields['filelocationtype'] == 'E') { $label_fld[] = ' --'; } /* if($fieldname == 'filestatus') { $filestatus = $col_fields[$fieldname]; if($filestatus == 0) $label_fld[]=$mod_strings['LBL_ACTIVE']; else $label_fld[]=$mod_strings['LBL_INACTIVE']; } */ } //code for Documents module :end $label_fld[] = $col_fields[$fieldname]; } } $label_fld[] = $uitype; //sets whether the currenct user is admin or not if (is_admin($current_user)) { $label_fld["isadmin"] = 1; } else { $label_fld["isadmin"] = 0; } $log->debug("Exiting getDetailViewOutputHtml method ..."); return $label_fld; }