PageRenderTime 73ms CodeModel.GetById 21ms 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
  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. $focus->column_fields['customerno'] = $so_focus->column_fields['customerno'];
  1297. $focus->column_fields['duedate'] = $so_focus->column_fields['duedate'];
  1298. $focus->column_fields['contact_id'] = $so_focus->column_fields['contact_id'];//to include contact name in Invoice
  1299. $focus->column_fields['account_id'] = $so_focus->column_fields['account_id'];
  1300. $focus->column_fields['exciseduty'] = $so_focus->column_fields['exciseduty'];
  1301. $focus->column_fields['salescommission'] = $so_focus->column_fields['salescommission'];
  1302. $focus->column_fields['purchaseorder'] = $so_focus->column_fields['purchaseorder'];
  1303. $focus->column_fields['bill_street'] = $so_focus->column_fields['bill_street'];
  1304. $focus->column_fields['ship_street'] = $so_focus->column_fields['ship_street'];
  1305. $focus->column_fields['bill_city'] = $so_focus->column_fields['bill_city'];
  1306. $focus->column_fields['ship_city'] = $so_focus->column_fields['ship_city'];
  1307. $focus->column_fields['bill_state'] = $so_focus->column_fields['bill_state'];
  1308. $focus->column_fields['ship_state'] = $so_focus->column_fields['ship_state'];
  1309. $focus->column_fields['bill_code'] = $so_focus->column_fields['bill_code'];
  1310. $focus->column_fields['ship_code'] = $so_focus->column_fields['ship_code'];
  1311. $focus->column_fields['bill_country'] = $so_focus->column_fields['bill_country'];
  1312. $focus->column_fields['ship_country'] = $so_focus->column_fields['ship_country'];
  1313. $focus->column_fields['bill_pobox'] = $so_focus->column_fields['bill_pobox'];
  1314. $focus->column_fields['ship_pobox'] = $so_focus->column_fields['ship_pobox'];
  1315. $focus->column_fields['description'] = $so_focus->column_fields['description'];
  1316. $focus->column_fields['terms_conditions'] = $so_focus->column_fields['terms_conditions'];
  1317. $focus->column_fields['currency_id'] = $so_focus->column_fields['currency_id'];
  1318. $focus->column_fields['conversion_rate'] = $so_focus->column_fields['conversion_rate'];
  1319. $log->debug("Exiting getConvertSoToInvoice method ...");
  1320. return $focus;
  1321. }
  1322. /** This function returns the vtiger_invoice object populated with the details from quote object.
  1323. * Param $focus - Invoice object
  1324. * Param $quote_focus - Quote order focus
  1325. * Param $quoteid - quote id
  1326. * Return type is an object array
  1327. */
  1328. function getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)
  1329. {
  1330. global $log,$current_user;
  1331. $log->debug("Entering getConvertQuoteToInvoice(".get_class($focus).",".get_class($quote_focus).",".$quoteid.") method ...");
  1332. $log->info("in getConvertQuoteToInvoice ".$quoteid);
  1333. $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');
  1334. for($i=0;$i<12;$i++){
  1335. if (getFieldVisibilityPermission('Quotes', $current_user->id,$xyz[$i]) == '0'){
  1336. $quote_focus->column_fields[$xyz[$i]] = $quote_focus->column_fields[$xyz[$i]];
  1337. }
  1338. else
  1339. $quote_focus->column_fields[$xyz[$i]] = '';
  1340. }
  1341. $focus->column_fields['subject'] = $quote_focus->column_fields['subject'];
  1342. $focus->column_fields['account_id'] = $quote_focus->column_fields['account_id'];
  1343. $focus->column_fields['bill_street'] = $quote_focus->column_fields['bill_street'];
  1344. $focus->column_fields['ship_street'] = $quote_focus->column_fields['ship_street'];
  1345. $focus->column_fields['bill_city'] = $quote_focus->column_fields['bill_city'];
  1346. $focus->column_fields['ship_city'] = $quote_focus->column_fields['ship_city'];
  1347. $focus->column_fields['bill_state'] = $quote_focus->column_fields['bill_state'];
  1348. $focus->column_fields['ship_state'] = $quote_focus->column_fields['ship_state'];
  1349. $focus->column_fields['bill_code'] = $quote_focus->column_fields['bill_code'];
  1350. $focus->column_fields['ship_code'] = $quote_focus->column_fields['ship_code'];
  1351. $focus->column_fields['bill_country'] = $quote_focus->column_fields['bill_country'];
  1352. $focus->column_fields['ship_country'] = $quote_focus->column_fields['ship_country'];
  1353. $focus->column_fields['bill_pobox'] = $quote_focus->column_fields['bill_pobox'];
  1354. $focus->column_fields['ship_pobox'] = $quote_focus->column_fields['ship_pobox'];
  1355. $focus->column_fields['description'] = $quote_focus->column_fields['description'];
  1356. $focus->column_fields['terms_conditions'] = $quote_focus->column_fields['terms_conditions'];
  1357. $focus->column_fields['currency_id'] = $quote_focus->column_fields['currency_id'];
  1358. $focus->column_fields['conversion_rate'] = $quote_focus->column_fields['conversion_rate'];
  1359. $log->debug("Exiting getConvertQuoteToInvoice method ...");
  1360. return $focus;
  1361. }
  1362. /** This function returns the sales order object populated with the details from quote object.
  1363. * Param $focus - Sales order object
  1364. * Param $quote_focus - Quote order focus
  1365. * Param $quoteid - quote id
  1366. * Return type is an object array
  1367. */
  1368. function getConvertQuoteToSoObject($focus,$quote_focus,$quoteid)
  1369. {
  1370. global $log,$current_user;
  1371. $log->debug("Entering getConvertQuoteToSoObject(".get_class($focus).",".get_class($quote_focus).",".$quoteid.") method ...");
  1372. $log->info("in getConvertQuoteToSoObject ".$quoteid);
  1373. $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');
  1374. for($i=0;$i<12;$i++){
  1375. if (getFieldVisibilityPermission('Quotes', $current_user->id,$xyz[$i]) == '0'){
  1376. $quote_focus->column_fields[$xyz[$i]] = $quote_focus->column_fields[$xyz[$i]];
  1377. }
  1378. else
  1379. $quote_focus->column_fields[$xyz[$i]] = '';
  1380. }
  1381. $focus->column_fields['quote_id'] = $quoteid;
  1382. $focus->column_fields['subject'] = $quote_focus->column_fields['subject'];
  1383. $focus->column_fields['contact_id'] = $quote_focus->column_fields['contact_id'];
  1384. $focus->column_fields['potential_id'] = $quote_focus->column_fields['potential_id'];
  1385. $focus->column_fields['account_id'] = $quote_focus->column_fields['account_id'];
  1386. $focus->column_fields['carrier'] = $quote_focus->column_fields['carrier'];
  1387. $focus->column_fields['bill_street'] = $quote_focus->column_fields['bill_street'];
  1388. $focus->column_fields['ship_street'] = $quote_focus->column_fields['ship_street'];
  1389. $focus->column_fields['bill_city'] = $quote_focus->column_fields['bill_city'];
  1390. $focus->column_fields['ship_city'] = $quote_focus->column_fields['ship_city'];
  1391. $focus->column_fields['bill_state'] = $quote_focus->column_fields['bill_state'];
  1392. $focus->column_fields['ship_state'] = $quote_focus->column_fields['ship_state'];
  1393. $focus->column_fields['bill_code'] = $quote_focus->column_fields['bill_code'];
  1394. $focus->column_fields['ship_code'] = $quote_focus->column_fields['ship_code'];
  1395. $focus->column_fields['bill_country'] = $quote_focus->column_fields['bill_country'];
  1396. $focus->column_fields['ship_country'] = $quote_focus->column_fields['ship_country'];
  1397. $focus->column_fields['bill_pobox'] = $quote_focus->column_fields['bill_pobox'];
  1398. $focus->column_fields['ship_pobox'] = $quote_focus->column_fields['ship_pobox'];
  1399. $focus->column_fields['description'] = $quote_focus->column_fields['description'];
  1400. $focus->column_fields['terms_conditions'] = $quote_focus->column_fields['terms_conditions'];
  1401. $focus->column_fields['currency_id'] = $quote_focus->column_fields['currency_id'];
  1402. $focus->column_fields['conversion_rate'] = $quote_focus->column_fields['conversion_rate'];
  1403. $log->debug("Exiting getConvertQuoteToSoObject method ...");
  1404. return $focus;
  1405. }
  1406. /** This function returns the detailed list of vtiger_products associated to a given entity or a record.
  1407. * Param $module - module name
  1408. * Param $focus - module object
  1409. * Param $seid - sales entity id
  1410. * Return type is an object array
  1411. */
  1412. function getAssociatedProducts($module,$focus,$seid='')
  1413. {
  1414. global $log;
  1415. $log->debug("Entering getAssociatedProducts(".$module.",".get_class($focus).",".$seid."='') method ...");
  1416. global $adb;
  1417. $output = '';
  1418. global $theme,$current_user;
  1419. $theme_path="themes/".$theme."/";
  1420. $image_path=$theme_path."images/";
  1421. $product_Detail = Array();
  1422. // DG 15 Aug 2006
  1423. // Add "ORDER BY sequence_no" to retain add order on all inventoryproductrel items
  1424. if($module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Invoice')
  1425. {
  1426. $query="SELECT
  1427. case when vtiger_products.productid != '' then vtiger_products.productname else vtiger_service.servicename end as productname,
  1428. case when vtiger_products.productid != '' then vtiger_products.productcode else vtiger_service.service_no end as productcode,
  1429. case when vtiger_products.productid != '' then vtiger_products.unit_price else vtiger_service.unit_price end as unit_price,
  1430. case when vtiger_products.productid != '' then vtiger_products.qtyinstock else 'NA' end as qtyinstock,
  1431. case when vtiger_products.productid != '' then 'Products' else 'Services' end as entitytype,
  1432. vtiger_inventoryproductrel.listprice,
  1433. vtiger_inventoryproductrel.description AS product_description,
  1434. vtiger_inventoryproductrel.*
  1435. FROM vtiger_inventoryproductrel
  1436. LEFT JOIN vtiger_products
  1437. ON vtiger_products.productid=vtiger_inventoryproductrel.productid
  1438. LEFT JOIN vtiger_service
  1439. ON vtiger_service.serviceid=vtiger_inventoryproductrel.productid
  1440. WHERE id=?
  1441. ORDER BY sequence_no";
  1442. $params = array($focus->id);
  1443. }
  1444. elseif($module == 'Potentials')
  1445. {
  1446. $query="SELECT
  1447. vtiger_products.productname,
  1448. vtiger_products.productcode,
  1449. vtiger_products.unit_price,
  1450. vtiger_products.qtyinstock,
  1451. vtiger_seproductsrel.*,
  1452. vtiger_crmentity.description AS product_description
  1453. FROM vtiger_products
  1454. INNER JOIN vtiger_crmentity
  1455. ON vtiger_crmentity.crmid=vtiger_products.productid
  1456. INNER JOIN vtiger_seproductsrel
  1457. ON vtiger_seproductsrel.productid=vtiger_products.productid
  1458. WHERE vtiger_seproductsrel.crmid=?";
  1459. $params = array($seid);
  1460. }
  1461. elseif($module == 'Products')
  1462. {
  1463. $query="SELECT
  1464. vtiger_products.productid,
  1465. vtiger_products.productcode,
  1466. vtiger_products.productname,
  1467. vtiger_products.unit_price,
  1468. vtiger_products.qtyinstock,
  1469. vtiger_crmentity.description AS product_description,
  1470. 'Products' AS entitytype
  1471. FROM vtiger_products
  1472. INNER JOIN vtiger_crmentity
  1473. ON vtiger_crmentity.crmid=vtiger_products.productid
  1474. WHERE vtiger_crmentity.deleted=0
  1475. AND productid=?";
  1476. $params = array($seid);
  1477. }
  1478. elseif($module == 'Services')
  1479. {
  1480. $query="SELECT
  1481. vtiger_service.serviceid AS productid,
  1482. 'NA' AS productcode,
  1483. vtiger_service.servicename AS productname,
  1484. vtiger_service.unit_price AS unit_price,
  1485. 'NA' AS qtyinstock,
  1486. vtiger_crmentity.description AS product_description,
  1487. 'Services' AS entitytype
  1488. FROM vtiger_service
  1489. INNER JOIN vtiger_crmentity
  1490. ON vtiger_crmentity.crmid=vtiger_service.serviceid
  1491. WHERE vtiger_crmentity.deleted=0
  1492. AND serviceid=?";
  1493. $params = array($seid);
  1494. }
  1495. $result = $adb->pquery($query, $params);
  1496. $num_rows=$adb->num_rows($result);
  1497. for($i=1;$i<=$num_rows;$i++)
  1498. {
  1499. $hdnProductId = $adb->query_result($result,$i-1,'productid');
  1500. $hdnProductcode = $adb->query_result($result,$i-1,'productcode');
  1501. $productname=$adb->query_result($result,$i-1,'productname');
  1502. $productdescription=$adb->query_result($result,$i-1,'product_description');
  1503. $comment=$adb->query_result($result,$i-1,'comment');
  1504. $qtyinstock=$adb->query_result($result,$i-1,'qtyinstock');
  1505. $qty=$adb->query_result($result,$i-1,'quantity');
  1506. $unitprice=$adb->query_result($result,$i-1,'unit_price');
  1507. $listprice=$adb->query_result($result,$i-1,'listprice');
  1508. $entitytype=$adb->query_result($result,$i-1,'entitytype');
  1509. if (!empty($entitytype)) {
  1510. $product_Detail[$i]['entityType'.$i]=$entitytype;
  1511. }
  1512. if($listprice == '')
  1513. $listprice = $unitprice;
  1514. if($qty =='')
  1515. $qty = 1;
  1516. //calculate productTotal
  1517. $productTotal = $qty*$listprice;
  1518. //Delete link in First column
  1519. if($i != 1)
  1520. {
  1521. $product_Detail[$i]['delRow'.$i]="Del";
  1522. }
  1523. if(empty($focus->mode) && $seid!=''){
  1524. $sub_prod_query = $adb->pquery("SELECT crmid as prod_id from vtiger_seproductsrel WHERE productid=? AND setype='Products'",array($seid));
  1525. } else {
  1526. $sub_prod_query = $adb->pquery("SELECT productid as prod_id from vtiger_inventorysubproductrel WHERE id=? AND sequence_no=?",array($focus->id,$i));
  1527. }
  1528. $subprodid_str='';
  1529. $subprodname_str='';
  1530. $subProductArray = array();
  1531. if($adb->num_rows($sub_prod_query)>0){
  1532. for($j=0;$j<$adb->num_rows($sub_prod_query);$j++){
  1533. $sprod_id = $adb->query_result($sub_prod_query,$j,'prod_id');
  1534. $sprod_name = $subProductArray[] = getProductName($sprod_id);
  1535. $str_sep = "";
  1536. if($j>0) $str_sep = ":";
  1537. $subprodid_str .= $str_sep.$sprod_id;
  1538. $subprodname_str .= $str_sep." - ".$sprod_name;
  1539. }
  1540. }
  1541. $subprodname_str = str_replace(":","<br>",$subprodname_str);
  1542. $product_Detail[$i]['subProductArray'.$i] = $subProductArray;
  1543. $product_Detail[$i]['hdnProductId'.$i] = $hdnProductId;
  1544. $product_Detail[$i]['productName'.$i]= from_html($productname);
  1545. /* Added to fix the issue Product Pop-up name display*/
  1546. if($_REQUEST['action'] == 'CreateSOPDF' || $_REQUEST['action'] == 'CreatePDF' || $_REQUEST['action'] == 'SendPDFMail')
  1547. $product_Detail[$i]['productName'.$i]= htmlspecialchars($product_Detail[$i]['productName'.$i]);
  1548. $product_Detail[$i]['hdnProductcode'.$i] = $hdnProductcode;
  1549. $product_Detail[$i]['productDescription'.$i]= from_html($productdescription);
  1550. if($module == 'Potentials' || $module == 'Products' || $module == 'Services') {
  1551. $product_Detail[$i]['comment'.$i]= $productdescription;
  1552. }else {
  1553. $product_Detail[$i]['comment'.$i]= $comment;
  1554. }
  1555. if($module != 'PurchaseOrder' && $focus->object_name != 'Order')
  1556. {
  1557. $product_Detail[$i]['qtyInStock'.$i]=$qtyinstock;
  1558. }
  1559. $qty = number_format($qty, 2,'.',''); //Convert to 2 decimals
  1560. $listprice = number_format($listprice, 2,'.',''); //Convert to 2 decimals
  1561. $product_Detail[$i]['qty'.$i]=$qty;
  1562. $product_Detail[$i]['listPrice'.$i]=$listprice;
  1563. $product_Detail[$i]['unitPrice'.$i]=$unitprice;
  1564. $product_Detail[$i]['productTotal'.$i]=$productTotal;
  1565. $product_Detail[$i]['subproduct_ids'.$i]=$subprodid_str;
  1566. $product_Detail[$i]['subprod_names'.$i]=$subprodname_str;
  1567. $discount_percent=$adb->query_result($result,$i-1,'discount_percent');
  1568. $discount_amount=$adb->query_result($result,$i-1,'discount_amount');
  1569. $discount_amount = number_format($discount_amount, 2,'.',''); //Convert to 2 decimals
  1570. $discountTotal = '0.00';
  1571. //Based on the discount percent or amount we will show the discount details
  1572. //To avoid NaN javascript error, here we assign 0 initially to' %of price' and 'Direct Price reduction'(for Each Product)
  1573. $product_Detail[$i]['discount_percent'.$i] = 0;
  1574. $product_Detail[$i]['discount_amount'.$i] = 0;
  1575. if($discount_percent != 'NULL' && $discount_percent != '')
  1576. {
  1577. $product_Detail[$i]['discount_type'.$i] = "percentage";
  1578. $product_Detail[$i]['discount_percent'.$i] = $discount_percent;
  1579. $product_Detail[$i]['checked_discount_percent'.$i] = ' checked';
  1580. $product_Detail[$i]['style_discount_percent'.$i] = ' style="visibility:visible"';
  1581. $product_Detail[$i]['style_discount_amount'.$i] = ' style="visibility:hidden"';
  1582. $discountTotal = $productTotal*$discount_percent/100;
  1583. }
  1584. elseif($discount_amount != 'NULL' && $discount_amount != '')
  1585. {
  1586. $product_Detail[$i]['discount_type'.$i] = "amount";
  1587. $product_Detail[$i]['discount_amount'.$i] = $discount_amount;
  1588. $product_Detail[$i]['checked_discount_amount'.$i] = ' checked';
  1589. $product_Detail[$i]['style_discount_amount'.$i] = ' style="visibility:visible"';
  1590. $product_Detail[$i]['style_discount_percent'.$i] = ' style="visibility:hidden"';
  1591. $discountTotal = $discount_amount;
  1592. }
  1593. else
  1594. {
  1595. $product_Detail[$i]['checked_discount_zero'.$i] = ' checked';
  1596. }
  1597. $totalAfterDiscount = $productTotal-$discountTotal;
  1598. $product_Detail[$i]['discountTotal'.$i] = $discountTotal;
  1599. $product_Detail[$i]['totalAfterDiscount'.$i] = $totalAfterDiscount;
  1600. $taxTotal = '0.00';
  1601. $product_Detail[$i]['taxTotal'.$i] = $taxTotal;
  1602. //Calculate netprice
  1603. $netPrice = $totalAfterDiscount+$taxTotal;
  1604. //if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module
  1605. if($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice')
  1606. {
  1607. $taxtype = getInventoryTaxType($module,$focus->id);
  1608. if($taxtype == 'individual')
  1609. {
  1610. //Add the tax with product total and assign to netprice
  1611. $netPrice = $netPrice+$taxTotal;
  1612. }
  1613. }
  1614. $product_Detail[$i]['netPrice'.$i] = $netPrice;
  1615. //First we will get all associated taxes as array
  1616. $tax_details = getTaxDetailsForProduct($hdnProductId,'all');
  1617. //Now retrieve the tax values from the current query with the name
  1618. for($tax_count=0;$tax_count<count($tax_details);$tax_count++)
  1619. {
  1620. $tax_name = $tax_details[$tax_count]['taxname'];
  1621. $tax_label = $tax_details[$tax_count]['taxlabel'];
  1622. $tax_value = '0.00';
  1623. //condition to avoid this function call when create new PO/SO/Quotes/Invoice from Product module
  1624. if($focus->id != '')
  1625. {
  1626. if($taxtype == 'individual')//if individual then show the entered tax percentage
  1627. $tax_value = getInventoryProductTaxValue($focus->id, $hdnProductId, $tax_name);
  1628. else//if group tax then we have to show the default value when change to individual tax
  1629. $tax_value = $tax_details[$tax_count]['percentage'];
  1630. }
  1631. else//if the above function not called then assign the default associated value of the product
  1632. $tax_value = $tax_details[$tax_count]['percentage'];
  1633. $product_Detail[$i]['taxes'][$tax_count]['taxname'] = $tax_name;
  1634. $product_Detail[$i]['taxes'][$tax_count]['taxlabel'] = $tax_label;
  1635. $product_Detail[$i]['taxes'][$tax_count]['percentage'] = $tax_value;
  1636. }
  1637. }
  1638. //set the taxtype
  1639. $product_Detail[1]['final_details']['taxtype'] = $taxtype;
  1640. //Get the Final Discount, S&H charge, Tax for S&H and Adjustment values
  1641. //To set the Final Discount details
  1642. $finalDiscount = '0.00';
  1643. $product_Detail[1]['final_details']['discount_type_final'] = 'zero';
  1644. $subTotal = ($focus->column_fields['hdnSubTotal'] != '')?$focus->column_fields['hdnSubTotal']:'0.00';
  1645. $subTotal = number_format($subTotal, 2,'.',''); //Convert to 2 decimals
  1646. $product_Detail[1]['final_details']['hdnSubTotal'] = $subTotal;
  1647. $discountPercent = ($focus->column_fields['hdnDiscountPercent'] != '')?$focus->column_fields['hdnDiscountPercent']:'0.00';
  1648. $discountAmount = ($focus->column_fields['hdnDiscountAmount'] != '')?$focus->column_fields['hdnDiscountAmount']:'0.00';
  1649. $discountAmount = number_format($discountAmount, 2,'.',''); //Convert to 2 decimals
  1650. //To avoid NaN javascript error, here we assign 0 initially to' %of price' and 'Direct Price reduction'(For Final Discount)
  1651. $product_Detail[1]['final_details']['discount_percentage_final'] = 0;
  1652. $product_Detail[1]['final_details']['discount_amount_final'] = 0;
  1653. if($focus->column_fields['hdnDiscountPercent'] != '0')
  1654. {
  1655. $finalDiscount = ($subTotal*$discountPercent/100);
  1656. $product_Detail[1]['final_details']['discount_type_final'] = 'percentage';
  1657. $product_Detail[1]['final_details']['discount_percentage_final'] = $discountPercent;
  1658. $product_Detail[1]['final_details']['checked_discount_percentage_final'] = ' checked';
  1659. $product_Detail[1]['final_details']['style_discount_percentage_final'] = ' style="visibility:visible"';
  1660. $product_Detail[1]['final_details']['style_discount_amount_final'] = ' style="visibility:hidden"';
  1661. }
  1662. elseif($focus->column_fields['hdnDiscountAmount'] != '0')
  1663. {
  1664. $finalDiscount = $focus->column_fields['hdnDiscountAmount'];
  1665. $product_Detail[1]['final_details']['discount_type_final'] = 'amount';
  1666. $product_Detail[1]['final_details']['discount_amount_final'] = $discountAmount;
  1667. $product_Detail[1]['final_details']['checked_discount_amount_final'] = ' checked';
  1668. $product_Detail[1]['final_details']['style_discount_amount_final'] = ' style="visibility:visible"';
  1669. $product_Detail[1]['final_details']['style_discount_percentage_final'] = ' style="visibility:hidden"';
  1670. }
  1671. $finalDiscount = number_format($finalDiscount, 2,'.',''); //Convert to 2 decimals
  1672. $product_Detail[1]['final_details']['discountTotal_final'] = $finalDiscount;
  1673. //To set the Final Tax values
  1674. //we will get all taxes. if individual then show the product related taxes only else show all taxes
  1675. //suppose user want to change individual to group or vice versa in edit time the we have to show all taxes. so that here we will store all the taxes and based on need we will show the corresponding taxes
  1676. $taxtotal = '0.00';
  1677. //First we should get all available taxes and then retrieve the corresponding tax values
  1678. $tax_details = getAllTaxes('available','','edit',$focus->id);
  1679. for($tax_count=0;$tax_count<count($tax_details);$tax_count++)
  1680. {
  1681. $tax_name = $tax_details[$tax_count]['taxname'];
  1682. $tax_label = $tax_details[$tax_count]['taxlabel'];
  1683. //if taxtype is individual and want to change to group during edit time then we have to show the all available taxes and their default values
  1684. //Also taxtype is group and want to change to individual during edit time then we have to provide the asspciated taxes and their default tax values for individual products
  1685. if($taxtype == 'group')
  1686. $tax_percent = $adb->query_result($result,0,$tax_name);
  1687. else
  1688. $tax_percent = $tax_details[$tax_count]['percentage'];//$adb->query_result($result,0,$tax_name);
  1689. if($tax_percent == '' || $tax_percent == 'NULL')
  1690. $tax_percent = '0.00';
  1691. $taxamount = ($subTotal-$finalDiscount)*$tax_percent/100;
  1692. $taxamount = number_format($taxamount, 2,'.',''); //Convert to 2 decimals
  1693. $taxtotal = $taxtotal + $taxamount;
  1694. $product_Detail[1]['final_details']['taxes'][$tax_count]['taxname'] = $tax_name;
  1695. $product_Detail[1]['final_details']['taxes'][$tax_count]['taxlabel'] = $tax_label;
  1696. $product_Detail[1]['final_details']['taxes'][$tax_count]['percentage'] = $tax_percent;
  1697. $product_Detail[1]['final_details']['taxes'][$tax_count]['amount'] = $taxamount;
  1698. }
  1699. $product_Detail[1]['final_details']['tax_totalamount'] = $taxtotal;
  1700. //To set the Shipping & Handling charge
  1701. $shCharge = ($focus->column_fields['hdnS_H_Amount'] != '')?$focus->column_fields['hdnS_H_Amount']:'0.00';
  1702. $shCharge = number_format($shCharge, 2,'.',''); //Convert to 2 decimals
  1703. $product_Detail[1]['final_details']['shipping_handling_charge'] = $shCharge;
  1704. //To set the Shipping & Handling tax values
  1705. //calculate S&H tax
  1706. $shtaxtotal = '0.00';
  1707. //First we should get all available taxes and then retrieve the corresponding tax values
  1708. $shtax_details = getAllTaxes('available','sh','edit',$focus->id);
  1709. //if taxtype is group then the tax should be same for all products in vtiger_inventoryproductrel table
  1710. for($shtax_count=0;$shtax_count<count($shtax_details);$shtax_count++)
  1711. {
  1712. $shtax_name = $shtax_details[$shtax_count]['taxname'];
  1713. $shtax_label = $shtax_details[$shtax_count]['taxlabel'];
  1714. $shtax_percent = '0.00';
  1715. //if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module
  1716. if($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice')
  1717. {
  1718. $shtax_percent = getInventorySHTaxPercent($focus->id,$shtax_name);
  1719. }
  1720. $shtaxamount = $shCharge*$shtax_percent/100;
  1721. $shtaxtotal = $shtaxtotal + $shtaxamount;
  1722. $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['taxname'] = $shtax_name;
  1723. $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['taxlabel'] = $shtax_label;
  1724. $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['percentage'] = $shtax_percent;
  1725. $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['amount'] = $shtaxamount;
  1726. }
  1727. $product_Detail[1]['final_details']['shtax_totalamount'] = $shtaxtotal;
  1728. //To set the Adjustment value
  1729. $adjustment = ($focus->column_fields['txtAdjustment'] != '')?$focus->column_fields['txtAdjustment']:'0.00';
  1730. $adjustment = number_format($adjustment, 2,'.',''); //Convert to 2 decimals
  1731. $product_Detail[1]['final_details']['adjustment'] = $adjustment;
  1732. //To set the grand total
  1733. $grandTotal = ($focus->column_fields['hdnGrandTotal'] != '')?$focus->column_fields['hdnGrandTotal']:'0.00';
  1734. $grandTotal = number_format($grandTotal, 2,'.',''); //Convert to 2 decimals
  1735. $product_Detail[1]['final_details']['grandTotal'] = $grandTotal;
  1736. $log->debug("Exiting getAssociatedProducts method ...");
  1737. return $product_Detail;
  1738. }
  1739. /** This function returns the no of vtiger_products associated to the given entity or a record.
  1740. * Param $module - module name
  1741. * Param $focus - module object
  1742. * Param $seid - sales entity id
  1743. * Return type is an object array
  1744. */
  1745. function getNoOfAssocProducts($module,$focus,$seid='')
  1746. {
  1747. global $log;
  1748. $log->debug("Entering getNoOfAssocProducts(".$module.",".get_class($focus).",".$seid."='') method ...");
  1749. global $adb;
  1750. $output = '';
  1751. if($module == 'Quotes')
  1752. {
  1753. $query="select vtiger_products.productname, vtiger_products.unit_price, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=?";
  1754. $params = array($focus->id);
  1755. }
  1756. elseif($module == 'PurchaseOrder')
  1757. {
  1758. $query="select vtiger_products.productname, vtiger_products.unit_price, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=?";
  1759. $params = array($focus->id);
  1760. }
  1761. elseif($module == 'SalesOrder')
  1762. {
  1763. $query="select vtiger_products.productname, vtiger_products.unit_price, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=?";
  1764. $params = array($focus->id);
  1765. }
  1766. elseif($module == 'Invoice')
  1767. {
  1768. $query="select vtiger_products.productname, vtiger_products.unit_price, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=?";
  1769. $params = array($focus->id);
  1770. }
  1771. elseif($module == 'Potentials')
  1772. {
  1773. $query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_seproductsrel.* from vtiger_products inner join vtiger_seproductsrel on vtiger_seproductsrel.productid=vtiger_products.productid where crmid=?";
  1774. $params = array($seid);
  1775. }
  1776. elseif($module == 'Products')
  1777. {
  1778. $query="select vtiger_products.productname,vtiger_products.unit_price, vtiger_crmentity.* from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid where vtiger_crmentity.deleted=0 and productid=?";
  1779. $params = array($seid);
  1780. }
  1781. $result = $adb->pquery($query, $params);
  1782. $num_rows=$adb->num_rows($result);
  1783. $log->debug("Exiting getNoOfAssocProducts method ...");
  1784. return $num_rows;
  1785. }
  1786. /** This function returns the detail block information of a record for given block id.
  1787. * Param $module - module name
  1788. * Param $block - block name
  1789. * Param $mode - view type (detail/edit/create)
  1790. * Param $col_fields - vtiger_fields array
  1791. * Param $tabid - vtiger_tab id
  1792. * Param $info_type - information type (basic/advance) default ""
  1793. * Return type is an object array
  1794. */
  1795. function getBlockInformation($module, $result, $col_fields,$tabid,$block_label,$mode)
  1796. {
  1797. global $log;
  1798. $log->debug("Entering getBlockInformation(".$module.",". $result.",". $col_fields.",".$tabid.",".$block_label.") method ...");
  1799. global $adb;
  1800. $editview_arr = Array();
  1801. global $current_user,$mod_strings;
  1802. $noofrows = $adb->num_rows($result);
  1803. if (($module == 'Accounts' || $module == 'Contacts' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder'|| $module == 'Invoice') && $block == 2)
  1804. {
  1805. global $log;
  1806. $log->info("module is ".$module);
  1807. $mvAdd_flag = true;
  1808. $moveAddress = "<td rowspan='6' valign='middle' align='center'><input title='Copy billing address to shipping address' class='button' onclick='return copyAddressRight(EditView)' type='button' name='copyright' value='&raquo;' style='padding:0px 2px 0px 2px;font-size:12px'><br><br>
  1809. <input title='Copy shipping address to billing address' class='button' onclick='return copyAddressLeft(EditView)' type='button' name='copyleft' value='&laquo;' style='padding:0px 2px 0px 2px;font-size:12px'></td>";
  1810. }
  1811. for($i=0; $i<$noofrows; $i++) {
  1812. $fieldtablename = $adb->query_result($result,$i,"tablename");
  1813. $fieldcolname = $adb->query_result($result,$i,"columnname");
  1814. $uitype = $adb->query_result($result,$i,"uitype");
  1815. $fieldname = $adb->query_result($result,$i,"fieldname");
  1816. $fieldlabel = $adb->query_result($result,$i,"fieldlabel");
  1817. $block = $adb->query_result($result,$i,"block");
  1818. $maxlength = $adb->query_result($result,$i,"maximumlength");
  1819. $generatedtype = $adb->query_result($result,$i,"generatedtype");
  1820. $typeofdata = $adb->query_result($result,$i,"typeofdata");
  1821. $defaultvalue = $adb->query_result($result,$i,"defaultvalue");
  1822. if($mode == '' && empty($col_fields[$fieldname])) {
  1823. $col_fields[$fieldname] = $defaultvalue;
  1824. }
  1825. $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields,$generatedtype,$module,$mode,$typeofdata);
  1826. $editview_arr[$block][]=$custfld;
  1827. if ($mvAdd_flag == true)
  1828. $mvAdd_flag = false;
  1829. }
  1830. foreach($editview_arr as $headerid=>$editview_value)
  1831. {
  1832. $editview_data = Array();
  1833. for ($i=0,$j=0;$i<count($editview_value);$j++)
  1834. {
  1835. $key1=$editview_value[$i];
  1836. if(is_array($editview_value[$i+1]) && ($key1[0][0]!=19 && $key1[0][0]!=20))
  1837. {
  1838. $key2=$editview_value[$i+1];
  1839. }
  1840. else
  1841. {
  1842. $key2 =array();
  1843. }
  1844. if($key1[0][0]!=19 && $key1[0][0]!=20){
  1845. $editview_data[$j]=array(0 => $key1,1 => $key2);
  1846. $i+=2;
  1847. }
  1848. else{
  1849. $editview_data[$j]=array(0 => $key1);
  1850. $i++;
  1851. }
  1852. }
  1853. $editview_arr[$headerid] = $editview_data;
  1854. }
  1855. foreach($block_label as $blockid=>$label)
  1856. {
  1857. if($editview_arr[$blockid] != null) {
  1858. if($label == '') {
  1859. $returndata[getTranslatedString($curBlock,$module)]=array_merge((array)$returndata[getTranslatedString($curBlock,$module)],(array)$editview_arr[$blockid]);
  1860. }
  1861. else {
  1862. $curBlock = $label;
  1863. if(is_array($editview_arr[$blockid]))
  1864. $returndata[getTranslatedString($curBlock,$module)]=array_merge((array)$returndata[getTranslatedString($curBlock,$module)],(array)$editview_arr[$blockid]);
  1865. }
  1866. }
  1867. }
  1868. $log->debug("Exiting getBlockInformation method ...");
  1869. return $returndata;
  1870. }
  1871. /** This function returns the data type of the vtiger_fields, with vtiger_field label, which is used for javascript validation.
  1872. * Param $validationData - array of vtiger_fieldnames with datatype
  1873. * Return type array
  1874. */
  1875. function split_validationdataArray($validationData)
  1876. {
  1877. global $log;
  1878. $log->debug("Entering split_validationdataArray(".$validationData.") method ...");
  1879. $fieldName = '';
  1880. $fieldLabel = '';
  1881. $fldDataType = '';
  1882. $rows = count($validationData);
  1883. foreach($validationData as $fldName => $fldLabel_array)
  1884. {
  1885. if($fieldName == '')
  1886. {
  1887. $fieldName="'".$fldName."'";
  1888. }
  1889. else
  1890. {
  1891. $fieldName .= ",'".$fldName ."'";
  1892. }
  1893. foreach($fldLabel_array as $fldLabel => $datatype)
  1894. {
  1895. if($fieldLabel == '')
  1896. {
  1897. $fieldLabel = "'".addslashes($fldLabel)."'";
  1898. }
  1899. else
  1900. {
  1901. $fieldLabel .= ",'".addslashes($fldLabel)."'";
  1902. }
  1903. if($fldDataType == '')
  1904. {
  1905. $fldDataType = "'".$datatype ."'";
  1906. }
  1907. else
  1908. {
  1909. $fldDataType .= ",'".$datatype ."'";
  1910. }
  1911. }
  1912. }
  1913. $data['fieldname'] = $fieldName;
  1914. $data['fieldlabel'] = $fieldLabel;
  1915. $data['datatype'] = $fldDataType;
  1916. $log->debug("Exiting split_validationdataArray method ...");
  1917. return $data;
  1918. }
  1919. ?>