PageRenderTime 67ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/include/utils/EditViewUtils.php

https://bitbucket.org/thomashii/vtigercrm-5.4-for-postgresql
PHP | 2061 lines | 1793 code | 142 blank | 126 comment | 592 complexity | 6a1c0d509173ba9849fc0376b0120d56 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*********************************************************************************
  3. * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
  4. * ("License"); You may not use this file except in compliance with the
  5. * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
  6. * Software distributed under the License is distributed on an "AS IS" basis,
  7. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  8. * the specific language governing rights and limitations under the License.
  9. * The Original Code is: SugarCRM Open Source
  10. * The Initial Developer of the Original Code is SugarCRM, Inc.
  11. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
  12. * All Rights Reserved.
  13. * Contributor(s): ______________________________________.
  14. ********************************************************************************/
  15. /*********************************************************************************
  16. * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/include/utils/EditViewUtils.php,v 1.188 2005/04/29 05:5 * 4:39 rank Exp
  17. * Description: Includes generic helper functions used throughout the application.
  18. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  19. * All Rights Reserved.
  20. * Contributor(s): ______________________________________..
  21. ********************************************************************************/
  22. require_once('include/database/PearDatabase.php');
  23. require_once('include/ComboUtil.php'); //new
  24. require_once('include/utils/CommonUtils.php'); //new
  25. require_once 'modules/PickList/DependentPickListUtils.php';
  26. /** This function returns the vtiger_field details for a given vtiger_fieldname.
  27. * Param $uitype - UI type of the vtiger_field
  28. * Param $fieldname - Form vtiger_field name
  29. * Param $fieldlabel - Form vtiger_field label name
  30. * Param $maxlength - maximum length of the vtiger_field
  31. * Param $col_fields - array contains the vtiger_fieldname and values
  32. * Param $generatedtype - Field generated type (default is 1)
  33. * Param $module_name - module name
  34. * Return type is an array
  35. */
  36. function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields,$generatedtype,$module_name,$mode='', $typeofdata=null)
  37. {
  38. global $log,$app_strings;
  39. $log->debug("Entering getOutputHtml(".$uitype.",". $fieldname.",". $fieldlabel.",". $maxlength.",". $col_fields.",".$generatedtype.",".$module_name.") method ...");
  40. global $adb,$log,$default_charset;
  41. global $theme;
  42. global $mod_strings;
  43. global $app_strings;
  44. global $current_user;
  45. require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
  46. require('user_privileges/user_privileges_'.$current_user->id.'.php');
  47. $theme_path="themes/".$theme."/";
  48. $image_path=$theme_path."images/";
  49. $fieldlabel = from_html($fieldlabel);
  50. $fieldvalue = Array();
  51. $final_arr = Array();
  52. $value = $col_fields[$fieldname];
  53. $custfld = '';
  54. $ui_type[]= $uitype;
  55. $editview_fldname[] = $fieldname;
  56. // vtlib customization: Related type field
  57. if($uitype == '10') {
  58. global $adb;
  59. $fldmod_result = $adb->pquery('SELECT relmodule, status FROM vtiger_fieldmodulerel WHERE fieldid=
  60. (SELECT fieldid FROM vtiger_field, vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid AND fieldname=? AND name=? and vtiger_field.presence in (0,2))',
  61. Array($fieldname, $module_name));
  62. $entityTypes = Array();
  63. $parent_id = $value;
  64. for($index = 0; $index < $adb->num_rows($fldmod_result); ++$index) {
  65. $entityTypes[] = $adb->query_result($fldmod_result, $index, 'relmodule');
  66. }
  67. if(!empty($value)) {
  68. $valueType = getSalesEntityType($value);
  69. $displayValueArray = getEntityName($valueType, $value);
  70. if(!empty($displayValueArray)){
  71. foreach($displayValueArray as $key=>$value){
  72. $displayValue = $value;
  73. }
  74. }
  75. } else {
  76. $displayValue='';
  77. $valueType='';
  78. $value='';
  79. }
  80. $editview_label[] = Array('options'=>$entityTypes, 'selected'=>$valueType, 'displaylabel'=>getTranslatedString($fieldlabel, $module_name));
  81. $fieldvalue[] = Array('displayvalue'=>$displayValue,'entityid'=>$parent_id);
  82. } // END
  83. else if($uitype == 5 || $uitype == 6 || $uitype ==23)
  84. {
  85. $log->info("uitype is ".$uitype);
  86. if($value == '') {
  87. //modified to fix the issue in trac(http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/1469)
  88. if ($fieldname != 'birthday' && $generatedtype != 2 && getTabid($module_name) != 14)
  89. $disp_value = getNewDisplayDate();
  90. if(($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 6) {
  91. $curr_time = date('H:i', strtotime('+5 minutes'));
  92. }
  93. if(($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) {
  94. $curr_time = date('H:i', strtotime('+10 minutes'));
  95. }
  96. //Added to display the Contact - Support End Date as one year future instead of
  97. //today's date -- 30-11-2005
  98. if ($fieldname == 'support_end_date' && $_REQUEST['module'] == 'Contacts') {
  99. $addyear = strtotime("+1 year");
  100. $disp_value = DateTimeField::convertToUserFormat(date('Y-m-d', $addyear));
  101. } elseif ($fieldname == 'validtill' && $_REQUEST['module'] == 'Quotes') {
  102. $disp_value = '';
  103. }
  104. } else {
  105. if($uitype == 6) {
  106. if ($col_fields['time_start'] != '' && ($module_name == 'Events' || $module_name
  107. == 'Calendar')) {
  108. $curr_time = $col_fields['time_start'];
  109. $value = $value . ' ' . $curr_time;
  110. } else {
  111. $curr_time = date('H:i', strtotime('+5 minutes'));
  112. }
  113. }
  114. if(($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) {
  115. if ($col_fields['time_end'] != '') {
  116. $curr_time = $col_fields['time_end'];
  117. $value = $value . ' ' . $curr_time;
  118. } else {
  119. $curr_time = date('H:i', strtotime('+10 minutes'));
  120. }
  121. }
  122. $disp_value = getValidDisplayDate($value);
  123. }
  124. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  125. $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
  126. if(!empty($curr_time)) {
  127. if(($module_name == 'Events' || $module_name == 'Calendar') && ($uitype == 23 ||
  128. $uitype == 6)) {
  129. $curr_time = DateTimeField::convertToUserTimeZone($curr_time);
  130. $curr_time = $curr_time->format('H:i');
  131. }
  132. }
  133. $fieldvalue[] = array($disp_value => $curr_time) ;
  134. if($uitype == 5 || $uitype == 23)
  135. {
  136. if($module_name == 'Events' && $uitype == 23)
  137. {
  138. $fieldvalue[] = array($date_format=>$current_user->date_format.' '.$app_strings['YEAR_MONTH_DATE']);
  139. }
  140. else
  141. $fieldvalue[] = array($date_format=>$current_user->date_format);
  142. }
  143. else
  144. {
  145. $fieldvalue[] = array($date_format=>$current_user->date_format.' '.$app_strings['YEAR_MONTH_DATE']);
  146. }
  147. }
  148. elseif($uitype == 16) {
  149. require_once 'modules/PickList/PickListUtils.php';
  150. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  151. $fieldname = $adb->sql_escape_string($fieldname);
  152. $pick_query="select $fieldname from vtiger_$fieldname order by sortorderid";
  153. $params = array();
  154. $pickListResult = $adb->pquery($pick_query, $params);
  155. $noofpickrows = $adb->num_rows($pickListResult);
  156. $options = array();
  157. $pickcount=0;
  158. $found = false;
  159. for($j = 0; $j < $noofpickrows; $j++)
  160. {
  161. $value = decode_html($value);
  162. $pickListValue=decode_html($adb->query_result($pickListResult,$j,strtolower($fieldname)));
  163. if($value == trim($pickListValue))
  164. {
  165. $chk_val = "selected";
  166. $pickcount++;
  167. $found = true;
  168. }
  169. else
  170. {
  171. $chk_val = '';
  172. }
  173. $pickListValue = to_html($pickListValue);
  174. if(isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate')
  175. $options[] = array(htmlentities(getTranslatedString($pickListValue),ENT_QUOTES,$default_charset),$pickListValue,$chk_val );
  176. else
  177. $options[] = array(getTranslatedString($pickListValue),$pickListValue,$chk_val );
  178. }
  179. $fieldvalue [] = $options;
  180. }
  181. elseif($uitype == 15 || $uitype == 33){
  182. require_once 'modules/PickList/PickListUtils.php';
  183. $roleid=$current_user->roleid;
  184. $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
  185. $valueArr = explode("|##|", $value);
  186. $pickcount = 0;
  187. if(!empty($picklistValues)){
  188. foreach($picklistValues as $order=>$pickListValue){
  189. if(in_array(trim($pickListValue),array_map("trim", $valueArr))){
  190. $chk_val = "selected";
  191. $pickcount++;
  192. }else{
  193. $chk_val = '';
  194. }
  195. if(isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate'){
  196. $options[] = array(htmlentities(getTranslatedString($pickListValue),ENT_QUOTES,$default_charset),$pickListValue,$chk_val );
  197. }else{
  198. $options[] = array(getTranslatedString($pickListValue),$pickListValue,$chk_val );
  199. }
  200. }
  201. if($pickcount == 0 && !empty($value)){
  202. $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'],$value,'selected');
  203. }
  204. }
  205. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  206. $fieldvalue [] = $options;
  207. }
  208. elseif($uitype == 17)
  209. {
  210. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  211. $fieldvalue [] = $value;
  212. }
  213. elseif($uitype == 85) //added for Skype by Minnie
  214. {
  215. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  216. $fieldvalue [] = $value;
  217. }elseif($uitype == 14) //added for Time Field
  218. {
  219. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  220. $fieldvalue [] = $value;
  221. }elseif($uitype == 19 || $uitype == 20)
  222. {
  223. if(isset($_REQUEST['body']))
  224. {
  225. $value = ($_REQUEST['body']);
  226. }
  227. if($fieldname == 'terms_conditions')//for default Terms & Conditions
  228. {
  229. //Assign the value from focus->column_fields (if we create Invoice from SO the SO's terms and conditions will be loaded to Invoice's terms and conditions, etc.,)
  230. $value = $col_fields['terms_conditions'];
  231. //if the value is empty then only we should get the default Terms and Conditions
  232. if($value == '' && $mode != 'edit')
  233. $value=getTermsandConditions();
  234. }
  235. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  236. $fieldvalue [] = $value;
  237. }
  238. elseif($uitype == 21 || $uitype == 24)
  239. {
  240. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  241. $fieldvalue [] = $value;
  242. }
  243. elseif($uitype == 22)
  244. {
  245. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  246. $fieldvalue[] = $value;
  247. }
  248. elseif($uitype == 52 || $uitype == 77)
  249. {
  250. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  251. global $current_user;
  252. if($value != '')
  253. {
  254. $assigned_user_id = $value;
  255. }
  256. else
  257. {
  258. $assigned_user_id = $current_user->id;
  259. }
  260. if($uitype == 52)
  261. {
  262. $combo_lbl_name = 'assigned_user_id';
  263. }
  264. elseif($uitype == 77)
  265. {
  266. $combo_lbl_name = 'assigned_user_id1';
  267. }
  268. //Control will come here only for Products - Handler and Quotes - Inventory Manager
  269. if($is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0))
  270. {
  271. $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id,'private'), $assigned_user_id);
  272. }
  273. else
  274. {
  275. $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
  276. }
  277. $fieldvalue [] = $users_combo;
  278. }
  279. elseif($uitype == 53)
  280. {
  281. global $noof_group_rows;
  282. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  283. //Security Checks
  284. if($fieldname == 'assigned_user_id' && $is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0))
  285. {
  286. $result=get_current_user_access_groups($module_name);
  287. }
  288. else
  289. {
  290. $result = get_group_options();
  291. }
  292. if($result) $nameArray = $adb->fetch_array($result);
  293. if($value != '' && $value != 0)
  294. $assigned_user_id = $value;
  295. else{
  296. if($value=='0'){
  297. if (isset($col_fields['assigned_group_info']) && $col_fields['assigned_group_info'] != '') {
  298. $selected_groupname = $col_fields['assigned_group_info'];
  299. } else {
  300. $record = $col_fields["record_id"];
  301. $module = $col_fields["record_module"];
  302. $selected_groupname = getGroupName($record, $module);
  303. }
  304. }else
  305. $assigned_user_id = $current_user->id;
  306. }
  307. if($fieldname == 'assigned_user_id' && $is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0))
  308. {
  309. $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id,'private'), $assigned_user_id);
  310. }
  311. else
  312. {
  313. $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
  314. }
  315. if($noof_group_rows!=0)
  316. {
  317. if($fieldname == 'assigned_user_id' && $is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0))
  318. {
  319. $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id,'private'), $assigned_user_id);
  320. }
  321. else
  322. {
  323. $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
  324. }
  325. }
  326. $fieldvalue[]=$users_combo;
  327. $fieldvalue[] = $groups_combo;
  328. }
  329. elseif($uitype == 51 || $uitype == 50 || $uitype == 73)
  330. {
  331. if($_REQUEST['convertmode'] != 'update_quote_val' && $_REQUEST['convertmode'] != 'update_so_val')
  332. {
  333. if(isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '')
  334. $value = $_REQUEST['account_id'];
  335. }
  336. if($value != '') {
  337. $account_name = getAccountName($value);
  338. }
  339. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  340. $fieldvalue[]=$account_name;
  341. $fieldvalue[] = $value;
  342. }
  343. elseif($uitype == 54)
  344. {
  345. $options = array();
  346. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  347. $pick_query="select * from vtiger_groups";
  348. $pickListResult = $adb->pquery($pick_query, array());
  349. $noofpickrows = $adb->num_rows($pickListResult);
  350. for($j = 0; $j < $noofpickrows; $j++)
  351. {
  352. $pickListValue=$adb->query_result($pickListResult,$j,"name");
  353. if($value == $pickListValue)
  354. {
  355. $chk_val = "selected";
  356. }
  357. else
  358. {
  359. $chk_val = '';
  360. }
  361. $options[] = array($pickListValue => $chk_val );
  362. }
  363. $fieldvalue[] = $options;
  364. }
  365. elseif($uitype == 55 || $uitype == 255){
  366. require_once 'modules/PickList/PickListUtils.php';
  367. if($uitype==255){
  368. $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id,'firstname', 'readwrite');
  369. }
  370. if($uitype == 255 && $fieldpermission == '0'){
  371. $fieldvalue[] = '';
  372. }else{
  373. $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id,'salutationtype', 'readwrite');
  374. if($fieldpermission == '0'){
  375. $roleid=$current_user->roleid;
  376. $picklistValues = getAssignedPicklistValues('salutationtype', $roleid, $adb);
  377. $pickcount = 0;
  378. $salt_value = $col_fields["salutationtype"];
  379. foreach($picklistValues as $order=>$pickListValue){
  380. if($salt_value == trim($pickListValue)){
  381. $chk_val = "selected";
  382. $pickcount++;
  383. }else{
  384. $chk_val = '';
  385. }
  386. if(isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate'){
  387. $options[] = array(htmlentities(getTranslatedString($pickListValue),ENT_QUOTES,$default_charset),$pickListValue,$chk_val );
  388. }else{
  389. $options[] = array(getTranslatedString($pickListValue),$pickListValue,$chk_val);
  390. }
  391. }
  392. if($pickcount == 0 && $salt_value != ''){
  393. $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'],$salt_value,'selected');
  394. }
  395. $fieldvalue [] = $options;
  396. } else {
  397. $fieldvalue[] = '';
  398. }
  399. }
  400. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  401. $fieldvalue[] = $value;
  402. }elseif($uitype == 59){
  403. if($_REQUEST['module'] == 'HelpDesk')
  404. {
  405. if(isset($_REQUEST['product_id']) & $_REQUEST['product_id'] != '')
  406. $value = $_REQUEST['product_id'];
  407. }
  408. elseif(isset($_REQUEST['parent_id']) & $_REQUEST['parent_id'] != '')
  409. $value = vtlib_purify($_REQUEST['parent_id']);
  410. if($value != '')
  411. {
  412. $product_name = getProductName($value);
  413. }
  414. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  415. $fieldvalue[]=$product_name;
  416. $fieldvalue[]=$value;
  417. }
  418. elseif($uitype == 63)
  419. {
  420. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  421. if($value=='')
  422. $value=1;
  423. $options = array();
  424. $pick_query="select * from vtiger_duration_minutes order by sortorderid";
  425. $pickListResult = $adb->pquery($pick_query, array());
  426. $noofpickrows = $adb->num_rows($pickListResult);
  427. $salt_value = $col_fields["duration_minutes"];
  428. for($j = 0; $j < $noofpickrows; $j++)
  429. {
  430. $pickListValue=$adb->query_result($pickListResult,$j,"duration_minutes");
  431. if($salt_value == $pickListValue)
  432. {
  433. $chk_val = "selected";
  434. }
  435. else
  436. {
  437. $chk_val = '';
  438. }
  439. $options[$pickListValue] = $chk_val;
  440. }
  441. $fieldvalue[]=$value;
  442. $fieldvalue[]=$options;
  443. }
  444. elseif($uitype == 64)
  445. {
  446. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  447. $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
  448. $fieldvalue[] = $value;
  449. }
  450. elseif($uitype == 156)
  451. {
  452. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  453. $fieldvalue[] = $value;
  454. $fieldvalue[] = $is_admin;
  455. }
  456. elseif($uitype == 56)
  457. {
  458. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  459. $fieldvalue[] = $value;
  460. }
  461. elseif($uitype == 57){
  462. if($value != ''){
  463. $displayValueArray = getEntityName('Contacts', $value);
  464. if (!empty($displayValueArray)) {
  465. foreach ($displayValueArray as $key => $field_value) {
  466. $contact_name = $field_value;
  467. }
  468. }
  469. }elseif(isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != ''){
  470. if($_REQUEST['module'] == 'Contacts' && $fieldname = 'contact_id'){
  471. $contact_name = '';
  472. }else{
  473. $value = $_REQUEST['contact_id'];
  474. $displayValueArray = getEntityName('Contacts', $value);
  475. if (!empty($displayValueArray)) {
  476. foreach ($displayValueArray as $key => $field_value) {
  477. $contact_name = $field_value;
  478. }
  479. } else {
  480. $contact_name='';
  481. }
  482. }
  483. }
  484. //Checking for contacts duplicate
  485. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  486. $fieldvalue[] = $contact_name;
  487. $fieldvalue[] = $value;
  488. }
  489. elseif($uitype == 58)
  490. {
  491. if($value != '')
  492. {
  493. $campaign_name = getCampaignName($value);
  494. }
  495. elseif(isset($_REQUEST['campaignid']) && $_REQUEST['campaignid'] != '')
  496. {
  497. if($_REQUEST['module'] == 'Campaigns' && $fieldname = 'campaignid')
  498. {
  499. $campaign_name = '';
  500. }
  501. else
  502. {
  503. $value = $_REQUEST['campaignid'];
  504. $campaign_name = getCampaignName($value);
  505. }
  506. }
  507. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  508. $fieldvalue[]=$campaign_name;
  509. $fieldvalue[] = $value;
  510. }
  511. elseif($uitype == 61)
  512. {
  513. if($value != '')
  514. {
  515. $assigned_user_id = $value;
  516. }
  517. else
  518. {
  519. $assigned_user_id = $current_user->id;
  520. }
  521. if($module_name == 'Emails' && $col_fields['record_id'] != '')
  522. {
  523. $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id']));
  524. //to fix the issue in mail attachment on forwarding mails
  525. if(isset($_REQUEST['forward']) && $_REQUEST['forward'] != '')
  526. global $att_id_list;
  527. for($ii=0;$ii < $adb->num_rows($attach_result);$ii++)
  528. {
  529. $attachmentid = $adb->query_result($attach_result,$ii,'attachmentsid');
  530. if($attachmentid != '')
  531. {
  532. $attachquery = "select * from vtiger_attachments where attachmentsid=?";
  533. $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)),0,'name');
  534. if($attachmentsname != '')
  535. $fieldvalue[$attachmentid] = '[ '.$attachmentsname.' ]';
  536. if(isset($_REQUEST['forward']) && $_REQUEST['forward'] != '')
  537. $att_id_list .= $attachmentid.';';
  538. }
  539. }
  540. }else
  541. {
  542. if($col_fields['record_id'] != '')
  543. {
  544. $attachmentid=$adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])),0,'attachmentsid');
  545. if($col_fields[$fieldname] == '' && $attachmentid != '')
  546. {
  547. $attachquery = "select * from vtiger_attachments where attachmentsid=?";
  548. $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)),0,'name');
  549. }
  550. }
  551. if($value!='')
  552. $filename=' [ '.$value. ' ]';
  553. if($filename != '')
  554. $fieldvalue[] = $filename;
  555. if($value != '')
  556. $fieldvalue[] = $value;
  557. }
  558. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  559. }
  560. elseif($uitype == 28){
  561. if($col_fields['record_id'] != '')
  562. {
  563. $attachmentid=$adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])),0,'attachmentsid');
  564. if($col_fields[$fieldname] == '' && $attachmentid != '')
  565. {
  566. $attachquery = "select * from vtiger_attachments where attachmentsid=?";
  567. $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)),0,'name');
  568. }
  569. }
  570. if($value!='' && $module_name != 'Documents')
  571. $filename=' [ '.$value. ' ]';
  572. elseif($value != '' && $module_name == 'Documents')
  573. $filename= $value;
  574. if($filename != '')
  575. $fieldvalue[] = $filename;
  576. if($value != '')
  577. $fieldvalue[] = $value;
  578. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  579. }
  580. elseif($uitype == 69)
  581. {
  582. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  583. if( $col_fields['record_id'] != "")
  584. {
  585. //This query is for Products only
  586. if($module_name == 'Products')
  587. {
  588. $query = 'select 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=?';
  589. }
  590. else
  591. {
  592. $query="select vtiger_attachments.*,vtiger_crmentity.setype from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid where vtiger_crmentity.setype='Contacts Image' and vtiger_seattachmentsrel.crmid=?";
  593. }
  594. $result_image = $adb->pquery($query, array($col_fields['record_id']));
  595. for($image_iter=0;$image_iter < $adb->num_rows($result_image);$image_iter++)
  596. {
  597. $image_id_array[] = $adb->query_result($result_image,$image_iter,'attachmentsid');
  598. //decode_html - added to handle UTF-8 characters in file names
  599. //urlencode - added to handle special characters like #, %, etc.,
  600. $image_array[] = urlencode(decode_html($adb->query_result($result_image,$image_iter,'name')));
  601. $image_orgname_array[] = decode_html($adb->query_result($result_image,$image_iter,'name'));
  602. $image_path_array[] = $adb->query_result($result_image,$image_iter,'path');
  603. }
  604. if(is_array($image_array))
  605. for($img_itr=0;$img_itr<count($image_array);$img_itr++)
  606. {
  607. $fieldvalue[] = array('name'=>$image_array[$img_itr],'path'=>$image_path_array[$img_itr].$image_id_array[$img_itr]."_","orgname"=>$image_orgname_array[$img_itr]);
  608. }
  609. else
  610. $fieldvalue[] = '';
  611. }
  612. else
  613. $fieldvalue[] = '';
  614. }
  615. elseif($uitype == 62)
  616. {
  617. if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '')
  618. $value = vtlib_purify($_REQUEST['parent_id']);
  619. if($value != '')
  620. $parent_module = getSalesEntityType($value);
  621. if(isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '')
  622. {
  623. $parent_module = "Accounts";
  624. $value = $_REQUEST['account_id'];
  625. }
  626. if($parent_module != 'Contacts')
  627. {
  628. if($parent_module == "Leads")
  629. {
  630. $displayValueArray = getEntityName($parent_module, $value);
  631. if (!empty($displayValueArray)) {
  632. foreach ($displayValueArray as $key => $field_value) {
  633. $parent_name = $field_value;
  634. }
  635. }
  636. $lead_selected = "selected";
  637. }
  638. elseif($parent_module == "Accounts")
  639. {
  640. $sql = "select * from vtiger_account where accountid=?";
  641. $result = $adb->pquery($sql, array($value));
  642. $parent_name = $adb->query_result($result,0,"accountname");
  643. $account_selected = "selected";
  644. }
  645. elseif($parent_module == "Potentials")
  646. {
  647. $sql = "select * from vtiger_potential where potentialid=?";
  648. $result = $adb->pquery($sql, array($value));
  649. $parent_name = $adb->query_result($result,0,"potentialname");
  650. $potential_selected = "selected";
  651. }
  652. elseif($parent_module == "Products")
  653. {
  654. $sql = "select * from vtiger_products where productid=?";
  655. $result = $adb->pquery($sql, array($value));
  656. $parent_name= $adb->query_result($result,0,"productname");
  657. $product_selected = "selected";
  658. }
  659. elseif($parent_module == "PurchaseOrder")
  660. {
  661. $sql = "select * from vtiger_purchaseorder where purchaseorderid=?";
  662. $result = $adb->pquery($sql, array($value));
  663. $parent_name= $adb->query_result($result,0,"subject");
  664. $porder_selected = "selected";
  665. }
  666. elseif($parent_module == "SalesOrder")
  667. {
  668. $sql = "select * from vtiger_salesorder where salesorderid=?";
  669. $result = $adb->pquery($sql, array($value));
  670. $parent_name= $adb->query_result($result,0,"subject");
  671. $sorder_selected = "selected";
  672. }
  673. elseif($parent_module == "Invoice")
  674. {
  675. $sql = "select * from vtiger_invoice where invoiceid=?";
  676. $result = $adb->pquery($sql, array($value));
  677. $parent_name= $adb->query_result($result,0,"subject");
  678. $invoice_selected = "selected";
  679. }
  680. elseif($parent_module == "Quotes")
  681. {
  682. $sql = "select * from vtiger_quotes where quoteid=?";
  683. $result = $adb->pquery($sql, array($value));
  684. $parent_name= $adb->query_result($result,0,"subject");
  685. $quote_selected = "selected";
  686. }elseif($parent_module == "HelpDesk")
  687. {
  688. $sql = "select * from vtiger_troubletickets where ticketid=?";
  689. $result = $adb->pquery($sql, array($value));
  690. $parent_name= $adb->query_result($result,0,"title");
  691. $ticket_selected = "selected";
  692. }
  693. }
  694. $editview_label[] = array($app_strings['COMBO_LEADS'],
  695. $app_strings['COMBO_ACCOUNTS'],
  696. $app_strings['COMBO_POTENTIALS'],
  697. $app_strings['COMBO_PRODUCTS'],
  698. $app_strings['COMBO_INVOICES'],
  699. $app_strings['COMBO_PORDER'],
  700. $app_strings['COMBO_SORDER'],
  701. $app_strings['COMBO_QUOTES'],
  702. $app_strings['COMBO_HELPDESK']
  703. );
  704. $editview_label[] = array($lead_selected,
  705. $account_selected,
  706. $potential_selected,
  707. $product_selected,
  708. $invoice_selected,
  709. $porder_selected,
  710. $sorder_selected,
  711. $quote_selected,
  712. $ticket_selected
  713. );
  714. $editview_label[] = array("Leads&action=Popup","Accounts&action=Popup","Potentials&action=Popup","Products&action=Popup","Invoice&action=Popup","PurchaseOrder&action=Popup","SalesOrder&action=Popup","Quotes&action=Popup","HelpDesk&action=Popup");
  715. $fieldvalue[] =$parent_name;
  716. $fieldvalue[] =$value;
  717. }
  718. elseif($uitype == 66)
  719. {
  720. if(!empty($_REQUEST['parent_id'])) {
  721. $value = vtlib_purify($_REQUEST['parent_id']);
  722. }
  723. if(!empty($value)) {
  724. $parent_module = getSalesEntityType($value);
  725. if($parent_module != "Contacts") {
  726. $entity_names = getEntityName($parent_module, $value);
  727. $parent_name = $entity_names[$value];
  728. $fieldvalue[] = $parent_name;
  729. $fieldvalue[] = $value;
  730. }
  731. }
  732. // Check for vtiger_activity type if task orders to be added in select option
  733. $act_mode = $_REQUEST['activity_mode'];
  734. $parentModulesList = array(
  735. 'Leads' => $app_strings['COMBO_LEADS'],
  736. 'Accounts' => $app_strings['COMBO_ACCOUNTS'],
  737. 'Potentials' => $app_strings['COMBO_POTENTIALS'],
  738. 'HelpDesk' => $app_strings['COMBO_HELPDESK'],
  739. 'Campaigns' => $app_strings['COMBO_CAMPAIGNS']
  740. );
  741. if($act_mode == "Task") {
  742. $parentModulesList['Quotes'] = $app_strings['COMBO_QUOTES'];
  743. $parentModulesList['PurchaseOrder'] = $app_strings['COMBO_PORDER'];
  744. $parentModulesList['SalesOrder'] = $app_strings['COMBO_SORDER'];
  745. $parentModulesList['Invoice'] = $app_strings['COMBO_INVOICES'];
  746. }
  747. $parentModuleNames = array_keys($parentModulesList);
  748. $parentModuleLabels = array_values($parentModulesList);
  749. $editview_label[0] = $parentModuleLabels;
  750. $editview_label[1] = array_fill(0, count($parentModulesList), '');
  751. $selectedModuleIndex = array_search($parent_module, $parentModuleNames);
  752. if($selectedModuleIndex > -1) {
  753. $editview_label[1][$selectedModuleIndex] = 'selected';
  754. }
  755. $parentModulePopupUrl = array();
  756. foreach($parentModuleNames as $parentModule) {
  757. $parentModulePopupUrl[] = $parentModule.'&action=Popup';
  758. }
  759. $editview_label[2] = $parentModulePopupUrl;
  760. }
  761. //added by rdhital/Raju for better email support
  762. elseif($uitype == 357)
  763. {
  764. $pmodule = $_REQUEST['pmodule'];
  765. if(empty($pmodule))
  766. $pmodule = $_REQUEST['par_module'];
  767. if($pmodule == 'Contacts')
  768. {
  769. $contact_selected = 'selected';
  770. }
  771. elseif($pmodule == 'Accounts')
  772. {
  773. $account_selected = 'selected';
  774. }
  775. elseif($pmodule == 'Leads')
  776. {
  777. $lead_selected = 'selected';
  778. }
  779. elseif($pmodule == 'Vendors')
  780. {
  781. $vendor_selected = 'selected';
  782. }
  783. elseif($pmodule == 'Users')
  784. {
  785. $user_selected = 'selected';
  786. }
  787. if(isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '')
  788. {
  789. $parent_id = $_REQUEST['emailids'];
  790. $parent_name='';
  791. $myids=explode("|",$parent_id);
  792. for ($i=0;$i<(count($myids)-1);$i++)
  793. {
  794. $realid=explode("@",$myids[$i]);
  795. $entityid=$realid[0];
  796. $nemail=count($realid);
  797. if ($pmodule=='Accounts'){
  798. require_once('modules/Accounts/Accounts.php');
  799. $myfocus = new Accounts();
  800. $myfocus->retrieve_entity_info($entityid,"Accounts");
  801. $fullname=br2nl($myfocus->column_fields['accountname']);
  802. $account_selected = 'selected';
  803. }
  804. elseif ($pmodule=='Contacts'){
  805. require_once('modules/Contacts/Contacts.php');
  806. $myfocus = new Contacts();
  807. $myfocus->retrieve_entity_info($entityid,"Contacts");
  808. $fname=br2nl($myfocus->column_fields['firstname']);
  809. $lname=br2nl($myfocus->column_fields['lastname']);
  810. $fullname=$lname.' '.$fname;
  811. $contact_selected = 'selected';
  812. }
  813. elseif ($pmodule=='Leads'){
  814. require_once('modules/Leads/Leads.php');
  815. $myfocus = new Leads();
  816. $myfocus->retrieve_entity_info($entityid,"Leads");
  817. $fname=br2nl($myfocus->column_fields['firstname']);
  818. $lname=br2nl($myfocus->column_fields['lastname']);
  819. $fullname=$lname.' '.$fname;
  820. $lead_selected = 'selected';
  821. }
  822. for ($j=1;$j<$nemail;$j++){
  823. $querystr='select columnname from vtiger_field where fieldid=? and vtiger_field.presence in (0,2)';
  824. $result=$adb->pquery($querystr, array($realid[$j]));
  825. $temp=$adb->query_result($result,0,'columnname');
  826. $temp1=br2nl($myfocus->column_fields[$temp]);
  827. //Modified to display the entities in red which don't have email id
  828. if(!empty($temp_parent_name) && strlen($temp_parent_name) > 150)
  829. {
  830. $parent_name .= '<br>';
  831. $temp_parent_name = '';
  832. }
  833. if($temp1 != '')
  834. {
  835. $parent_name .= $fullname.'&lt;'.$temp1.'&gt;; ';
  836. $temp_parent_name .= $fullname.'&lt;'.$temp1.'&gt;; ';
  837. }
  838. else
  839. {
  840. $parent_name .= "<b style='color:red'>".$fullname.'&lt;'.$temp1.'&gt;; '."</b>";
  841. $temp_parent_name .= "<b style='color:red'>".$fullname.'&lt;'.$temp1.'&gt;; '."</b>";
  842. }
  843. }
  844. }
  845. }
  846. else
  847. {
  848. if($_REQUEST['record'] != '' && $_REQUEST['record'] != NULL)
  849. {
  850. $parent_name='';
  851. $parent_id='';
  852. $myemailid= $_REQUEST['record'];
  853. $mysql = "select crmid from vtiger_seactivityrel where activityid=?";
  854. $myresult = $adb->pquery($mysql, array($myemailid));
  855. $mycount=$adb->num_rows($myresult);
  856. if($mycount >0)
  857. {
  858. for ($i=0;$i<$mycount;$i++)
  859. {
  860. $mycrmid=$adb->query_result($myresult,$i,'crmid');
  861. $parent_module = getSalesEntityType($mycrmid);
  862. if($parent_module == "Leads")
  863. {
  864. $sql = "select firstname,lastname,email from vtiger_leaddetails where leadid=?";
  865. $result = $adb->pquery($sql, array($mycrmid));
  866. $full_name = getFullNameFromQResult($result,0,"Leads");
  867. $myemail=$adb->query_result($result,0,"email");
  868. $parent_id .=$mycrmid.'@0|' ; //make it such that the email adress sent is remebered and only that one is retrived
  869. $parent_name .= $full_name.'<'.$myemail.'>; ';
  870. $lead_selected = 'selected';
  871. }
  872. elseif($parent_module == "Contacts")
  873. {
  874. $sql = "select * from vtiger_contactdetails where contactid=?";
  875. $result = $adb->pquery($sql, array($mycrmid));
  876. $full_name = getFullNameFromQResult($result,0,"Contacts");
  877. $myemail=$adb->query_result($result,0,"email");
  878. $parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived
  879. $parent_name .= $full_name.'<'.$myemail.'>; ';
  880. $contact_selected = 'selected';
  881. }
  882. elseif($parent_module == "Accounts")
  883. {
  884. $sql = "select * from vtiger_account where accountid=?";
  885. $result = $adb->pquery($sql, array($mycrmid));
  886. $account_name = $adb->query_result($result,0,"accountname");
  887. $myemail=$adb->query_result($result,0,"email1");
  888. $parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived
  889. $parent_name .= $account_name.'<'.$myemail.'>; ';
  890. $account_selected = 'selected';
  891. }elseif($parent_module == "Users")
  892. {
  893. $sql = "select user_name,email1 from vtiger_users where id=?";
  894. $result = $adb->pquery($sql, array($mycrmid));
  895. $account_name = $adb->query_result($result,0,"user_name");
  896. $myemail=$adb->query_result($result,0,"email1");
  897. $parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived
  898. $parent_name .= $account_name.'<'.$myemail.'>; ';
  899. $user_selected = 'selected';
  900. }
  901. elseif($parent_module == "Vendors")
  902. {
  903. $sql = "select * from vtiger_vendor where vendorid=?";
  904. $result = $adb->pquery($sql, array($mycrmid));
  905. $vendor_name = $adb->query_result($result,0,"vendorname");
  906. $myemail=$adb->query_result($result,0,"email");
  907. $parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived
  908. $parent_name .= $vendor_name.'<'.$myemail.'>; ';
  909. $vendor_selected = 'selected';
  910. }
  911. }
  912. }
  913. }
  914. $custfld .= '<td width="20%" class="dataLabel">'.$app_strings['To'].'&nbsp;</td>';
  915. $custfld .= '<td width="90%" colspan="3"><input name="parent_id" type="hidden" value="'.$parent_id.'"><textarea readonly name="parent_name" cols="70" rows="2">'.$parent_name.'</textarea>&nbsp;<select name="parent_type" >';
  916. $custfld .= '<OPTION value="Contacts" selected>'.$app_strings['COMBO_CONTACTS'].'</OPTION>';
  917. $custfld .= '<OPTION value="Accounts" >'.$app_strings['COMBO_ACCOUNTS'].'</OPTION>';
  918. $custfld .= '<OPTION value="Leads" >'.$app_strings['COMBO_LEADS'].'</OPTION>';
  919. $custfld .= '<OPTION value="Vendors" >'.$app_strings['COMBO_VENDORS'].'</OPTION></select><img src="' . vtiger_imageurl('select.gif', $theme) . '" alt="Select" title="Select" LANGUAGE=javascript onclick=\'$log->debug("Exiting getOutputHtml method ..."); return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&popuptype=set_$log->debug("Exiting getOutputHtml method ..."); return_emails&form=EmailEditView&form_submit=false","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");\' align="absmiddle" style=\'cursor:hand;cursor:pointer\'>&nbsp;<input type="image" src="' . vtiger_imageurl('clear_field.gif', $theme) . '" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=\'\';this.form.parent_name.value=\'\';$log->debug("Exiting getOutputHtml method ..."); return false;" align="absmiddle" style=\'cursor:hand;cursor:pointer\'></td>';
  920. $editview_label[] = array(
  921. 'Contacts'=>$contact_selected,
  922. 'Accounts'=>$account_selected,
  923. 'Vendors'=>$vendor_selected,
  924. 'Leads'=>$lead_selected,
  925. 'Users'=>$user_selected
  926. );
  927. $fieldvalue[] =$parent_name;
  928. $fieldvalue[] = $parent_id;
  929. }
  930. }
  931. //end of rdhital/Raju
  932. elseif($uitype == 68)
  933. {
  934. if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '')
  935. $value = vtlib_purify($_REQUEST['parent_id']);
  936. if($value != '')
  937. {
  938. $parent_module = getSalesEntityType($value);
  939. if($parent_module == "Contacts")
  940. {
  941. $displayValueArray = getEntityName($parent_module, $value);
  942. if (!empty($displayValueArray)) {
  943. foreach ($displayValueArray as $key => $field_value) {
  944. $parent_name = $field_value;
  945. }
  946. }
  947. $contact_selected = "selected";
  948. }
  949. elseif($parent_module == "Accounts")
  950. {
  951. $sql = "select * from vtiger_account where accountid=?";
  952. $result = $adb->pquery($sql, array($value));
  953. $parent_name = $adb->query_result($result,0,"accountname");
  954. $account_selected = "selected";
  955. }
  956. else
  957. {
  958. $parent_name = "";
  959. $value = "";
  960. }
  961. }
  962. $editview_label[] = array($app_strings['COMBO_CONTACTS'],
  963. $app_strings['COMBO_ACCOUNTS']
  964. );
  965. $editview_label[] = array($contact_selected,
  966. $account_selected
  967. );
  968. $editview_label[] = array("Contacts","Accounts");
  969. $fieldvalue[] = $parent_name;
  970. $fieldvalue[] = $value;
  971. }
  972. elseif($uitype == 71 || $uitype == 72) {
  973. $currencyField = new CurrencyField($value);
  974. // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
  975. if($col_fields['record_id'] != '' && $uitype == 72) {
  976. if($fieldname == 'unit_price') {
  977. $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'],$module_name));
  978. $currencySymbol = $rate_symbol['symbol'];
  979. } else {
  980. $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']);
  981. $currencySymbol = $currency_info['currency_symbol'];
  982. }
  983. $fieldvalue[] = $currencyField->getDisplayValue(null, true);
  984. } else {
  985. $fieldvalue[] = $currencyField->getDisplayValue();
  986. $currencySymbol = $currencyField->getCurrencySymbol();
  987. }
  988. $editview_label[]=getTranslatedString($fieldlabel, $module_name).': ('.$currencySymbol.')';
  989. }
  990. elseif($uitype == 75 || $uitype ==81)
  991. {
  992. if($value != '')
  993. {
  994. $vendor_name = getVendorName($value);
  995. }
  996. elseif(isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '')
  997. {
  998. $value = $_REQUEST['vendor_id'];
  999. $vendor_name = getVendorName($value);
  1000. }
  1001. $pop_type = 'specific';
  1002. if($uitype == 81)
  1003. {
  1004. $pop_type = 'specific_vendor_address';
  1005. }
  1006. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1007. $fieldvalue[] = $vendor_name;
  1008. $fieldvalue[] = $value;
  1009. }
  1010. elseif($uitype == 76)
  1011. {
  1012. if($value != '')
  1013. {
  1014. $potential_name = getPotentialName($value);
  1015. }
  1016. elseif(isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '')
  1017. {
  1018. $value = $_REQUEST['potental_id'];
  1019. $potential_name = getPotentialName($value);
  1020. }
  1021. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1022. $fieldvalue[] = $potential_name;
  1023. $fieldvalue[] = $value;
  1024. }
  1025. elseif($uitype == 78)
  1026. {
  1027. if($value != '')
  1028. {
  1029. $quote_name = getQuoteName($value);
  1030. }
  1031. elseif(isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '')
  1032. {
  1033. $value = $_REQUEST['quote_id'];
  1034. $potential_name = getQuoteName($value);
  1035. }
  1036. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1037. $fieldvalue[] = $quote_name;
  1038. $fieldvalue[] = $value;
  1039. }
  1040. elseif($uitype == 79)
  1041. {
  1042. if($value != '')
  1043. {
  1044. $purchaseorder_name = getPoName($value);
  1045. }
  1046. elseif(isset($_REQUEST['purchaseorder_id']) && $_REQUEST['purchaseorder_id'] != '')
  1047. {
  1048. $value = $_REQUEST['purchaseorder_id'];
  1049. $purchaseorder_name = getPoName($value);
  1050. }
  1051. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1052. $fieldvalue[] = $purchaseorder_name;
  1053. $fieldvalue[] = $value;
  1054. }
  1055. elseif($uitype == 80)
  1056. {
  1057. if($value != '')
  1058. {
  1059. $salesorder_name = getSoName($value);
  1060. }
  1061. elseif(isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '')
  1062. {
  1063. $value = $_REQUEST['salesorder_id'];
  1064. $salesorder_name = getSoName($value);
  1065. }
  1066. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1067. $fieldvalue[] = $salesorder_name;
  1068. $fieldvalue[] = $value;
  1069. }
  1070. elseif($uitype == 30)
  1071. {
  1072. $rem_days = 0;
  1073. $rem_hrs = 0;
  1074. $rem_min = 0;
  1075. if($value!='')
  1076. $SET_REM = "CHECKED";
  1077. $rem_days = floor($col_fields[$fieldname]/(24*60));
  1078. $rem_hrs = floor(($col_fields[$fieldname]-$rem_days*24*60)/60);
  1079. $rem_min = ($col_fields[$fieldname]-$rem_days*24*60)%60;
  1080. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1081. $day_options = getReminderSelectOption(0,31,'remdays',$rem_days);
  1082. $hr_options = getReminderSelectOption(0,23,'remhrs',$rem_hrs);
  1083. $min_options = getReminderSelectOption(1,59,'remmin',$rem_min);
  1084. $fieldvalue[] = array(array(0,32,'remdays',getTranslatedString('LBL_DAYS'),$rem_days),array(0,24,'remhrs',getTranslatedString('LBL_HOURS'),$rem_hrs),array(1,60,'remmin',getTranslatedString('LBL_MINUTES').'&nbsp;&nbsp;'.getTranslatedString('LBL_BEFORE_EVENT'),$rem_min));
  1085. $fieldvalue[] = array($SET_REM,getTranslatedString('LBL_YES'),getTranslatedString('LBL_NO'));
  1086. $SET_REM = '';
  1087. }
  1088. elseif($uitype == 115)
  1089. {
  1090. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1091. $pick_query="select * from vtiger_" . $adb->sql_escape_string($fieldname);
  1092. $pickListResult = $adb->pquery($pick_query, array());
  1093. $noofpickrows = $adb->num_rows($pickListResult);
  1094. //Mikecrowe fix to correctly default for custom pick lists
  1095. $options = array();
  1096. $found = false;
  1097. for($j = 0; $j < $noofpickrows; $j++)
  1098. {
  1099. $pickListValue=$adb->query_result($pickListResult,$j,strtolower($fieldname));
  1100. if($value == $pickListValue)
  1101. {
  1102. $chk_val = "selected";
  1103. $found = true;
  1104. }
  1105. else
  1106. {
  1107. $chk_val = '';
  1108. }
  1109. $options[] = array(getTranslatedString($pickListValue),$pickListValue,$chk_val );
  1110. }
  1111. $fieldvalue [] = $options;
  1112. $fieldvalue [] = $is_admin;
  1113. }
  1114. elseif($uitype == 116 || $uitype == 117)
  1115. {
  1116. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1117. $pick_query="select * from vtiger_currency_info where currency_status = 'Active' and deleted=0";
  1118. $pickListResult = $adb->pquery($pick_query, array());
  1119. $noofpickrows = $adb->num_rows($pickListResult);
  1120. //Mikecrowe fix to correctly default for custom pick lists
  1121. $options = array();
  1122. $found = false;
  1123. for($j = 0; $j < $noofpickrows; $j++)
  1124. {
  1125. $pickListValue=$adb->query_result($pickListResult,$j,'currency_name');
  1126. $currency_id=$adb->query_result($pickListResult,$j,'id');
  1127. if($value == $currency_id)
  1128. {
  1129. $chk_val = "selected";
  1130. $found = true;
  1131. }
  1132. else
  1133. {
  1134. $chk_val = '';
  1135. }
  1136. $options[$currency_id] = array($pickListValue=>$chk_val );
  1137. }
  1138. $fieldvalue [] = $options;
  1139. $fieldvalue [] = $is_admin;
  1140. }
  1141. elseif($uitype ==98)
  1142. {
  1143. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1144. $fieldvalue[]=$value;
  1145. $fieldvalue[]=getRoleName($value);
  1146. $fieldvalue[]=$is_admin;
  1147. }
  1148. elseif($uitype == 105)
  1149. {
  1150. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1151. if( isset( $col_fields['record_id']) && $col_fields['record_id'] != '') {
  1152. $query = "select vtiger_attachments.path, vtiger_attachments.name from vtiger_contactdetails left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_contactdetails.contactid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where vtiger_contactdetails.imagename=vtiger_attachments.name and contactid=?";
  1153. $result_image = $adb->pquery($query, array($col_fields['record_id']));
  1154. for($image_iter=0;$image_iter < $adb->num_rows($result_image);$image_iter++)
  1155. {
  1156. $image_array[] = $adb->query_result($result_image,$image_iter,'name');
  1157. $image_path_array[] = $adb->query_result($result_image,$image_iter,'path');
  1158. }
  1159. }
  1160. if(is_array($image_array))
  1161. for($img_itr=0;$img_itr<count($image_array);$img_itr++)
  1162. {
  1163. $fieldvalue[] = array('name'=>$image_array[$img_itr],'path'=>$image_path_array[$img_itr]);
  1164. }
  1165. else
  1166. $fieldvalue[] = '';
  1167. }elseif($uitype == 101)
  1168. {
  1169. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1170. $fieldvalue[] = getOwnerName($value);
  1171. $fieldvalue[] = $value;
  1172. }
  1173. elseif($uitype == 26){
  1174. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1175. $folderid=$col_fields['folderid'];
  1176. $foldername_query = 'select foldername from vtiger_attachmentsfolder where folderid = ?';
  1177. if(strlen($folderid) === 0) {
  1178. $folderid = '0';
  1179. }
  1180. $res = $adb->pquery($foldername_query,array($folderid));
  1181. $foldername = $adb->query_result($res,0,'foldername');
  1182. if($foldername != '' && $folderid != ''){
  1183. $fldr_name[$folderid]=$foldername;
  1184. }
  1185. $sql="select foldername,folderid from vtiger_attachmentsfolder order by foldername";
  1186. $res=$adb->pquery($sql,array());
  1187. for($i=0;$i<$adb->num_rows($res);$i++)
  1188. {
  1189. $fid=$adb->query_result($res,$i,"folderid");
  1190. $fldr_name[$fid]=$adb->query_result($res,$i,"foldername");
  1191. }
  1192. $fieldvalue[] = $fldr_name;
  1193. }
  1194. elseif($uitype == 27){
  1195. if($value == 'E'){
  1196. $external_selected = "selected";
  1197. $filename = $col_fields['filename'];
  1198. }
  1199. else{
  1200. $internal_selected = "selected";
  1201. $filename = $col_fields['filename'];
  1202. }
  1203. $editview_label[] = array(getTranslatedString('Internal'),
  1204. getTranslatedString('External')
  1205. );
  1206. $editview_label[] = array($internal_selected,
  1207. $external_selected
  1208. );
  1209. $editview_label[] = array("I","E");
  1210. $editview_label[] = getTranslatedString($fieldlabel, $module_name);
  1211. $fieldvalue[] = $value;
  1212. $fieldvalue[] = $filename;
  1213. } elseif($uitype == '31') {
  1214. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1215. $options = array();
  1216. $themeList = get_themes();
  1217. foreach ($themeList as $theme) {
  1218. if($current_user->theme == $theme) {
  1219. $selected = 'selected';
  1220. } else {
  1221. $selected = '';
  1222. }
  1223. $options[] = array(getTranslatedString($theme), $theme, $selected);
  1224. }
  1225. $fieldvalue [] = $options;
  1226. } elseif($uitype == '32') {
  1227. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1228. $options = array();
  1229. $languageList = Vtiger_Language::getAll();
  1230. foreach ($languageList as $prefix => $label) {
  1231. if($current_user->language == $prefix) {
  1232. $selected = 'selected';
  1233. } else {
  1234. $selected = '';
  1235. }
  1236. $options[] = array(getTranslatedString($label), $prefix, $selected);
  1237. }
  1238. $fieldvalue [] = $options;
  1239. }
  1240. else
  1241. {
  1242. //Added condition to set the subject if click Reply All from web mail
  1243. if($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '')
  1244. {
  1245. $value = $_REQUEST['mg_subject'];
  1246. }
  1247. $editview_label[]=getTranslatedString($fieldlabel, $module_name);
  1248. if($fieldname == 'fileversion'){
  1249. if(empty($value)){
  1250. $value = '';
  1251. }
  1252. else{
  1253. $fieldvalue[] = $value;
  1254. }
  1255. }
  1256. else
  1257. $fieldvalue[] = $value;
  1258. }
  1259. // Mike Crowe Mod --------------------------------------------------------force numerics right justified.
  1260. if ( !preg_match("/id=/i",$custfld) )
  1261. $custfld = preg_replace("/<input/iS","<input id='$fieldname' ",$custfld);
  1262. if ( in_array($uitype,array(71,72,7,9,90)) )
  1263. {
  1264. $custfld = preg_replace("/<input/iS","<input align=right ",$custfld);
  1265. }
  1266. $final_arr[]=$ui_type;
  1267. $final_arr[]=$editview_label;
  1268. $final_arr[]=$editview_fldname;
  1269. $final_arr[]=$fieldvalue;
  1270. $type_of_data = explode('~',$typeofdata);
  1271. $final_arr[]=$type_of_data[1];
  1272. $log->debug("Exiting getOutputHtml method ...");
  1273. return $final_arr;
  1274. }
  1275. /** This function returns the vtiger_invoice object populated with the details from sales order object.
  1276. * Param $focus - Invoice object
  1277. * Param $so_focus - Sales order focus
  1278. * Param $soid - sales order id
  1279. * Return type is an object array
  1280. */
  1281. function getConvertSoToInvoice($focus,$so_focus,$soid)
  1282. {
  1283. global $log,$current_user;
  1284. $log->debug("Entering getConvertSoToInvoice(".get_class($focus).",".get_class($so_focus).",".$soid.") method ...");
  1285. $log->info("in getConvertSoToInvoice ".$soid);
  1286. $xyz=array('bill_street','bill_city','bill_code','bill_pobox','bill_country','bill_state','ship_street','ship_city','ship_code','ship_pobox','ship_country','ship_state');
  1287. for($i=0;$i<count($xyz);$i++){
  1288. if (getFieldVisibilityPermission('SalesOrder', $current_user->id,$xyz[$i]) == '0'){
  1289. $so_focus->column_fields[$xyz[$i]] = $so_focus->column_fields[$xyz[$i]];
  1290. }
  1291. else
  1292. $so_focus->column_fields[$xyz[$i]] = '';
  1293. }
  1294. $focus->column_fields['salesorder_id'] = $soid;
  1295. $focus->column_fields['subject'] = $so_focus->column_fields['subject'];
  1296. $

Large files files are truncated, but you can click here to view the full file