| [ Index ] |
|
Code source de vtiger CRM 5.0.2 |
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 23 require_once ('include/database/PearDatabase.php'); 24 require_once ('include/ComboUtil.php'); //new 25 require_once ('include/utils/CommonUtils.php'); //new 26 27 /** This function returns the vtiger_field details for a given vtiger_fieldname. 28 * Param $uitype - UI type of the vtiger_field 29 * Param $fieldname - Form vtiger_field name 30 * Param $fieldlabel - Form vtiger_field label name 31 * Param $maxlength - maximum length of the vtiger_field 32 * Param $col_fields - array contains the vtiger_fieldname and values 33 * Param $generatedtype - Field generated type (default is 1) 34 * Param $module_name - module name 35 * Return type is an array 36 */ 37 38 function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields,$generatedtype,$module_name,$mode='') 39 { 40 global $log; 41 $log->debug("Entering getOutputHtml(".$uitype.",". $fieldname.",". $fieldlabel.",". $maxlength.",". $col_fields.",".$generatedtype.",".$module_name.") method ..."); 42 global $adb,$log; 43 global $theme; 44 global $mod_strings; 45 global $app_strings; 46 global $current_user; 47 global $noof_group_rows; 48 49 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 50 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 51 52 $theme_path="themes/".$theme."/"; 53 $image_path=$theme_path."images/"; 54 $fieldlabel = from_html($fieldlabel); 55 $fieldvalue = Array(); 56 $final_arr = Array(); 57 $value = $col_fields[$fieldname]; 58 $custfld = ''; 59 $ui_type[]= $uitype; 60 $editview_fldname[] = $fieldname; 61 62 if($generatedtype == 2) 63 $mod_strings[$fieldlabel] = $fieldlabel; 64 65 if($uitype == 5 || $uitype == 6 || $uitype ==23) 66 { 67 $log->info("uitype is ".$uitype); 68 if($value=='') 69 { 70 //modified to fix the issue in trac(http://vtiger.fosslabs.com/cgi-bin/trac.cgi/ticket/1469) 71 if($fieldname != 'birthday' && $generatedtype != 2)// && $fieldname != 'due_date')//due date is today's date by default 72 $disp_value=getNewDisplayDate(); 73 74 //Added to display the Contact - Support End Date as one year future instead of today's date -- 30-11-2005 75 if($fieldname == 'support_end_date' && $_REQUEST['module'] == 'Contacts') 76 { 77 $addyear = strtotime("+1 year"); 78 global $current_user; 79 $dat_fmt = (($current_user->date_format == '')?('dd-mm-yyyy'):($current_user->date_format)); 80 81 $disp_value = (($dat_fmt == 'dd-mm-yyyy')?(date('d-m-Y',$addyear)):(($dat_fmt == 'mm-dd-yyyy')?(date('m-d-Y',$addyear)):(($dat_fmt == 'yyyy-mm-dd')?(date('Y-m-d', $addyear)):('')))); 82 } 83 } 84 else 85 { 86 $disp_value = getDisplayDate($value); 87 } 88 $editview_label[]=$mod_strings[$fieldlabel]; 89 $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); 90 if($uitype == 6) 91 { 92 if($col_fields['time_start']!='') 93 { 94 $curr_time = $col_fields['time_start']; 95 } 96 else 97 { 98 $curr_time = date('H:i'); 99 } 100 } 101 if($module_name == 'Events' && $uitype == 23) 102 { 103 if($col_fields['time_end']!='') 104 { 105 $curr_time = $col_fields['time_end']; 106 } 107 else 108 { 109 $endtime = time() + (60 * 60); 110 $curr_time = date('H:i',$endtime); 111 } 112 } 113 $fieldvalue[] = array($disp_value => $curr_time) ; 114 if($uitype == 5 || $uitype == 23) 115 { 116 if($module_name == 'Events' && $uitype == 23) 117 { 118 $fieldvalue[] = array($date_format=>$current_user->date_format.' '.$app_strings['YEAR_MONTH_DATE']); 119 } 120 else 121 $fieldvalue[] = array($date_format=>$current_user->date_format); 122 } 123 else 124 { 125 $fieldvalue[] = array($date_format=>$current_user->date_format.' '.$app_strings['YEAR_MONTH_DATE']); 126 } 127 } 128 elseif($uitype == 15 || $uitype == 16 || $uitype == 111) //uitype 111 added for non editable picklist - ahmed 129 { 130 $editview_label[]=$mod_strings[$fieldlabel]; 131 $pick_query="select * from vtiger_".$fieldname; 132 $pickListResult = $adb->query($pick_query); 133 $noofpickrows = $adb->num_rows($pickListResult); 134 135 //Mikecrowe fix to correctly default for custom pick lists 136 $options = array(); 137 $found = false; 138 for($j = 0; $j < $noofpickrows; $j++) 139 { 140 $pickListValue=$adb->query_result($pickListResult,$j,strtolower($fieldname)); 141 142 if($value == $pickListValue) 143 { 144 $chk_val = "selected"; 145 $found = true; 146 } 147 else 148 { 149 $chk_val = ''; 150 } 151 $options[] = array($pickListValue=>$chk_val ); 152 } 153 $fieldvalue [] = $options; 154 } 155 elseif($uitype == 17) 156 { 157 $editview_label[]=$mod_strings[$fieldlabel]; 158 $fieldvalue [] = $value; 159 } 160 elseif($uitype == 85) //added for Skype by Minnie 161 { 162 $editview_label[]=$mod_strings[$fieldlabel]; 163 $fieldvalue [] = $value; 164 } 165 elseif($uitype == 33) 166 { 167 $editview_label[]=$mod_strings[$fieldlabel]; 168 $mulsel="select * from vtiger_".$fieldname; 169 $multiselect_result = $adb->query($mulsel); 170 $noofoptions = $adb->num_rows($multiselect_result); 171 $options = array(); 172 $found = false; 173 $valur_arr = explode(' |##| ',$value); 174 for($j = 0; $j < $noofoptions; $j++) 175 { 176 $multiselect_combo = $adb->query_result($multiselect_result,$j,strtolower($fieldname)); 177 if(in_array($multiselect_combo,$valur_arr)) 178 { 179 $chk_val = "selected"; 180 $found = true; 181 } 182 else 183 { 184 $chk_val = ''; 185 } 186 $options[] = array($multiselect_combo=>$chk_val ); 187 } 188 $fieldvalue [] = $options; 189 } 190 elseif($uitype == 19 || $uitype == 20) 191 { 192 if(isset($_REQUEST['body'])) 193 { 194 $value = ($_REQUEST['body']); 195 } 196 197 if($fieldname == 'terms_conditions')//for default Terms & Conditions 198 { 199 //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.,) 200 $value = $col_fields['terms_conditions']; 201 202 //if the value is empty then only we should get the default Terms and Conditions 203 if($value == '' && $mode != 'edit') 204 $value=getTermsandConditions(); 205 } 206 207 $editview_label[]=$mod_strings[$fieldlabel]; 208 $fieldvalue [] = $value; 209 } 210 elseif($uitype == 21 || $uitype == 24) 211 { 212 $editview_label[]=$mod_strings[$fieldlabel]; 213 $fieldvalue [] = $value; 214 } 215 elseif($uitype == 22) 216 { 217 $editview_label[]=$mod_strings[$fieldlabel]; 218 $fieldvalue[] = $value; 219 } 220 elseif($uitype == 52 || $uitype == 77) 221 { 222 $editview_label[]=$mod_strings[$fieldlabel]; 223 global $current_user; 224 if($value != '') 225 { 226 $assigned_user_id = $value; 227 } 228 else 229 { 230 $assigned_user_id = $current_user->id; 231 } 232 if($uitype == 52) 233 { 234 $combo_lbl_name = 'assigned_user_id'; 235 } 236 elseif($uitype == 77) 237 { 238 $combo_lbl_name = 'assigned_user_id1'; 239 } 240 241 242 if($fieldlabel == 'Assigned To' && $is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) 243 { 244 $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id,'private'), $assigned_user_id); 245 } 246 else 247 { 248 $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); 249 } 250 $fieldvalue [] = $users_combo; 251 } 252 elseif($uitype == 53) 253 { 254 $editview_label[]=$mod_strings[$fieldlabel]; 255 //Security Checks 256 if($fieldlabel == 'Assigned To' && $is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) 257 { 258 $result=get_current_user_access_groups($module_name); 259 } 260 else 261 { 262 $result = get_group_options(); 263 } 264 $nameArray = $adb->fetch_array($result); 265 266 267 global $current_user; 268 if($value != '' && $value != 0) 269 { 270 $assigned_user_id = $value; 271 $user_checked = "checked"; 272 $team_checked = ''; 273 $user_style='display:block'; 274 $team_style='display:none'; 275 } 276 else 277 { 278 if($value=='0') 279 { 280 $record = $col_fields["record_id"]; 281 $module = $col_fields["record_module"]; 282 283 $selected_groupname = getGroupName($record, $module); 284 $user_checked = ''; 285 $team_checked = 'checked'; 286 $user_style='display:none'; 287 $team_style='display:block'; 288 } 289 else 290 { 291 $assigned_user_id = $current_user->id; 292 $user_checked = "checked"; 293 $team_checked = ''; 294 $user_style='display:block'; 295 $team_style='display:none'; 296 } 297 } 298 299 if($fieldlabel == 'Assigned To' && $is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) 300 { 301 $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id,'private'), $assigned_user_id); 302 } 303 else 304 { 305 $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); 306 } 307 308 309 $GROUP_SELECT_OPTION = '<td width=30%><input type="radio" 310 name="assigntype" value="U" '.$user_checked.' 311 onclick="toggleAssignType(this.value)">'.$app_strings['LBL_USER']; 312 313 if($noof_group_rows!=0) 314 { 315 316 $log->debug("Has a Group, get the Radio button"); 317 $GROUP_SELECT_OPTION .= '<input 318 type="radio" name="assigntype" value="T"'.$team_checked.' 319 onclick="toggleAssignType(this.value)">'.$app_strings['LBL_GROUP']; 320 } 321 322 $GROUP_SELECT_OPTION .='<br><span 323 id="assign_user" style="'.$user_style.'"><select name="assigned_user_id">'; 324 325 $GROUP_SELECT_OPTION .= $users_combo; 326 327 $GROUP_SELECT_OPTION .= '</select></span>'; 328 329 if($noof_group_rows!=0) 330 { 331 $log->debug("Has a Group, getting the group names "); 332 $GROUP_SELECT_OPTION .='<span id="assign_team" style="'.$team_style.'"><select name="assigned_group_name">'; 333 334 do 335 { 336 $groupname=$nameArray["groupname"]; 337 $selected = ''; 338 if($groupname == $selected_groupname[0]) 339 { 340 $selected = "selected"; 341 } 342 $group_option[] = array($groupname=>$selected); 343 344 }while($nameArray = $adb->fetch_array($result)); 345 346 } 347 348 $fieldvalue[]=$users_combo; 349 $fieldvalue[] = $group_option; 350 } 351 elseif($uitype == 51 || $uitype == 50 || $uitype == 73) 352 { 353 if($_REQUEST['convertmode'] != 'update_quote_val' && $_REQUEST['convertmode'] != 'update_so_val') 354 { 355 if(isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') 356 $value = $_REQUEST['account_id']; 357 } 358 359 if($value != '') 360 { 361 $account_name = getAccountName($value); 362 } 363 $editview_label[]=$mod_strings[$fieldlabel]; 364 $fieldvalue[]=$account_name; 365 $fieldvalue[] = $value; 366 } 367 elseif($uitype == 54) 368 { 369 $options =Array(); 370 $editview_label[]=$mod_strings[$fieldlabel]; 371 $pick_query="select * from vtiger_groups"; 372 $pickListResult = $adb->query($pick_query); 373 $noofpickrows = $adb->num_rows($pickListResult); 374 for($j = 0; $j < $noofpickrows; $j++) 375 { 376 $pickListValue=$adb->query_result($pickListResult,$j,"name"); 377 378 if($value == $pickListValue) 379 { 380 $chk_val = "selected"; 381 } 382 else 383 { 384 $chk_val = ''; 385 } 386 $options[] = array($pickListValue => $chk_val ); 387 } 388 $fieldvalue[] = $options; 389 390 } 391 elseif($uitype == 55) 392 { 393 $editview_label[]=$mod_strings[$fieldlabel]; 394 $options = Array(); 395 $pick_query="select * from vtiger_salutationtype order by sortorderid"; 396 $pickListResult = $adb->query($pick_query); 397 $noofpickrows = $adb->num_rows($pickListResult); 398 $salt_value = $col_fields["salutationtype"]; 399 for($j = 0; $j < $noofpickrows; $j++) 400 { 401 $pickListValue=$adb->query_result($pickListResult,$j,"salutationtype"); 402 403 if($salt_value == $pickListValue) 404 { 405 $chk_val = "selected"; 406 } 407 else 408 { 409 $chk_val = ''; 410 } 411 $options[] = array($pickListValue => $chk_val ); 412 } 413 $fieldvalue[] = $options; 414 $fieldvalue[] = $value; 415 } 416 elseif($uitype == 59) 417 { 418 if($_REQUEST['module'] == 'HelpDesk') 419 { 420 if(isset($_REQUEST['product_id']) & $_REQUEST['product_id'] != '') 421 $value = $_REQUEST['product_id']; 422 } 423 elseif(isset($_REQUEST['parent_id']) & $_REQUEST['parent_id'] != '') 424 $value = $_REQUEST['parent_id']; 425 426 if($value != '') 427 { 428 $product_name = getProductName($value); 429 } 430 $editview_label[]=$mod_strings[$fieldlabel]; 431 $fieldvalue[]=$product_name; 432 $fieldvalue[]=$value; 433 } 434 elseif($uitype == 63) 435 { 436 $editview_label[]=$mod_strings[$fieldlabel]; 437 if($value=='') 438 $value=1; 439 $options = Array(); 440 $pick_query="select * from vtiger_duration_minutes order by sortorderid"; 441 $pickListResult = $adb->query($pick_query); 442 $noofpickrows = $adb->num_rows($pickListResult); 443 $salt_value = $col_fields["duration_minutes"]; 444 for($j = 0; $j < $noofpickrows; $j++) 445 { 446 $pickListValue=$adb->query_result($pickListResult,$j,"duration_minutes"); 447 448 if($salt_value == $pickListValue) 449 { 450 $chk_val = "selected"; 451 } 452 else 453 { 454 $chk_val = ''; 455 } 456 $options[$pickListValue] = $chk_val; 457 } 458 $fieldvalue[]=$value; 459 $fieldvalue[]=$options; 460 } 461 elseif($uitype == 64) 462 { 463 $editview_label[]=$mod_strings[$fieldlabel]; 464 $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); 465 $fieldvalue[] = $value; 466 } 467 elseif($uitype == 156) 468 { 469 $editview_label[]=$mod_strings[$fieldlabel]; 470 $fieldvalue[] = $value; 471 $fieldvalue[] = $is_admin; 472 } 473 elseif($uitype == 56) 474 { 475 $editview_label[]=$mod_strings[$fieldlabel]; 476 $fieldvalue[] = $value; 477 } 478 elseif($uitype == 57) 479 { 480 481 if($value != '') 482 { 483 $contact_name = getContactName($value); 484 } 485 elseif(isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') 486 { 487 if($_REQUEST['module'] == 'Contacts' && $fieldname = 'contact_id') 488 { 489 $contact_name = ''; 490 } 491 else 492 { 493 $value = $_REQUEST['contact_id']; 494 $contact_name = getContactName($value); 495 } 496 497 } 498 499 //Checking for contacts duplicate 500 501 $editview_label[]=$mod_strings[$fieldlabel]; 502 $fieldvalue[] = $contact_name; 503 $fieldvalue[] = $value; 504 } 505 506 elseif($uitype == 58) 507 { 508 509 if($value != '') 510 { 511 $campaign_name = getCampaignName($value); 512 } 513 elseif(isset($_REQUEST['campaignid']) && $_REQUEST['campaignid'] != '') 514 { 515 if($_REQUEST['module'] == 'Campaigns' && $fieldname = 'campaignid') 516 { 517 $campaign_name = ''; 518 } 519 else 520 { 521 $value = $_REQUEST['campaignid']; 522 $campaign_name = getCampaignName($value); 523 } 524 525 } 526 $editview_label[]=$mod_strings[$fieldlabel]; 527 $fieldvalue[]=$campaign_name; 528 $fieldvalue[] = $value; 529 } 530 531 elseif($uitype == 61) 532 { 533 global $current_user; 534 if($value != '') 535 { 536 $assigned_user_id = $value; 537 } 538 else 539 { 540 $assigned_user_id = $current_user->id; 541 } 542 if($module_name == 'Emails') 543 { 544 $attach_result = $adb->query("select * from vtiger_seattachmentsrel where crmid = ".$col_fields['record_id']); 545 for($ii=0;$ii < $adb->num_rows($attach_result);$ii++) 546 { 547 $attachmentid = $adb->query_result($attach_result,$ii,'attachmentsid'); 548 if($attachmentid != '') 549 { 550 $attachquery = "select * from vtiger_attachments where attachmentsid=".$attachmentid; 551 $attachmentsname = $adb->query_result($adb->query($attachquery),0,'name'); 552 if($attachmentsname != '') 553 $fieldvalue[$attachmentid] = '[ '.$attachmentsname.' ]'; 554 } 555 556 } 557 }else 558 { 559 if($col_fields['record_id'] != '') 560 { 561 $attachmentid=$adb->query_result($adb->query("select * from vtiger_seattachmentsrel where crmid = ".$col_fields['record_id']),0,'attachmentsid'); 562 if($col_fields[$fieldname] == '' && $attachmentid != '') 563 { 564 $attachquery = "select * from vtiger_attachments where attachmentsid=".$attachmentid; 565 $value = $adb->query_result($adb->query($attachquery),0,'name'); 566 } 567 } 568 if($value!='') 569 $filename=' [ '.$value. ' ]'; 570 $fieldvalue[] = $filename; 571 $fieldvalue[] = $value; 572 } 573 $editview_label[]=$mod_strings[$fieldlabel]; 574 } 575 elseif($uitype == 69) 576 { 577 $editview_label[]=$mod_strings[$fieldlabel]; 578 579 if( $col_fields['record_id'] != "") 580 { 581 //This query is for Products only 582 if($module_name == 'Products') 583 { 584 $query = 'select vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name 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 where productid='.$col_fields['record_id']; 585 } 586 else 587 { 588 $query = "select vtiger_attachments.* from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid inner join vtiger_contactdetails on vtiger_contactdetails.imagename=vtiger_attachments.name where vtiger_seattachmentsrel.crmid=".$col_fields['record_id']; 589 } 590 $result_image = $adb->query($query); 591 for($image_iter=0;$image_iter < $adb->num_rows($result_image);$image_iter++) 592 { 593 $image_id_array[] = $adb->query_result($result_image,$image_iter,'attachmentsid'); 594 $image_array[] = $adb->query_result($result_image,$image_iter,'name'); 595 $image_path_array[] = $adb->query_result($result_image,$image_iter,'path'); 596 } 597 if(is_array($image_array)) 598 for($img_itr=0;$img_itr<count($image_array);$img_itr++) 599 { 600 $fieldvalue[] = array('name'=>$image_array[$img_itr],'path'=>$image_path_array[$img_itr].$image_id_array[$img_itr]."_"); 601 } 602 else 603 $fieldvalue[] = ''; 604 } 605 else 606 $fieldvalue[] = ''; 607 } 608 elseif($uitype == 62) 609 { 610 if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') 611 $value = $_REQUEST['parent_id']; 612 613 if($value != '') 614 { 615 $parent_module = getSalesEntityType($value); 616 if($parent_module == "Leads") 617 { 618 $sql = "select * from vtiger_leaddetails where leadid=".$value; 619 $result = $adb->query($sql); 620 $first_name = $adb->query_result($result,0,"firstname"); 621 $last_name = $adb->query_result($result,0,"lastname"); 622 $parent_name = $last_name.' '.$first_name; 623 $lead_selected = "selected"; 624 625 } 626 elseif($parent_module == "Accounts") 627 { 628 $sql = "select * from vtiger_account where accountid=".$value; 629 $result = $adb->query($sql); 630 $parent_name = $adb->query_result($result,0,"accountname"); 631 $account_selected = "selected"; 632 633 } 634 elseif($parent_module == "Potentials") 635 { 636 $sql = "select * from vtiger_potential where potentialid=".$value; 637 $result = $adb->query($sql); 638 $parent_name = $adb->query_result($result,0,"potentialname"); 639 $potential_selected = "selected"; 640 641 } 642 elseif($parent_module == "Products") 643 { 644 $sql = "select * from vtiger_products where productid=".$value; 645 $result = $adb->query($sql); 646 $parent_name= $adb->query_result($result,0,"productname"); 647 $product_selected = "selected"; 648 649 } 650 elseif($parent_module == "PurchaseOrder") 651 { 652 $sql = "select * from vtiger_purchaseorder where purchaseorderid=".$value; 653 $result = $adb->query($sql); 654 $parent_name= $adb->query_result($result,0,"subject"); 655 $porder_selected = "selected"; 656 657 } 658 elseif($parent_module == "SalesOrder") 659 { 660 $sql = "select * from vtiger_salesorder where salesorderid=".$value; 661 $result = $adb->query($sql); 662 $parent_name= $adb->query_result($result,0,"subject"); 663 $sorder_selected = "selected"; 664 665 } 666 elseif($parent_module == "Invoice") 667 { 668 $sql = "select * from vtiger_invoice where invoiceid=".$value; 669 $result = $adb->query($sql); 670 $parent_name= $adb->query_result($result,0,"subject"); 671 $invoice_selected = "selected"; 672 673 } 674 675 676 } 677 $editview_label[] = array($app_strings['COMBO_LEADS'], 678 $app_strings['COMBO_ACCOUNTS'], 679 $app_strings['COMBO_POTENTIALS'], 680 $app_strings['COMBO_PRODUCTS'], 681 $app_strings['COMBO_INVOICES'], 682 $app_strings['COMBO_PORDER'], 683 $app_strings['COMBO_SORDER'] 684 ); 685 $editview_label[] = array($lead_selected, 686 $account_selected, 687 $potential_selected, 688 $product_selected, 689 $invoice_selected, 690 $porder_selected, 691 $sorder_selected 692 ); 693 $editview_label[] = array("Leads&action=Popup","Accounts&action=Popup","Potentials&action=Popup","Products&action=Popup","Invoice&action=Popup","PurchaseOrder&action=Popup","SalesOrder&action=Popup"); 694 $fieldvalue[] =$parent_name; 695 $fieldvalue[] =$value; 696 697 } 698 elseif($uitype == 66) 699 { 700 if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') 701 $value = $_REQUEST['parent_id']; 702 // Check for vtiger_activity type if task orders to be added in select option 703 $act_mode = $_REQUEST['activity_mode']; 704 705 if($value != '') 706 { 707 $parent_module = getSalesEntityType($value); 708 if($parent_module == "Leads") 709 { 710 $sql = "select * from vtiger_leaddetails where leadid=".$value; 711 $result = $adb->query($sql); 712 $first_name = $adb->query_result($result,0,"firstname"); 713 $last_name = $adb->query_result($result,0,"lastname"); 714 $parent_name = $last_name.' '.$first_name; 715 $lead_selected = "selected"; 716 717 } 718 elseif($parent_module == "Accounts") 719 { 720 $sql = "select * from vtiger_account where accountid=".$value; 721 $result = $adb->query($sql); 722 $parent_name = $adb->query_result($result,0,"accountname"); 723 $account_selected = "selected"; 724 725 } 726 elseif($parent_module == "Potentials") 727 { 728 $sql = "select * from vtiger_potential where potentialid=".$value; 729 $result = $adb->query($sql); 730 $parent_name = $adb->query_result($result,0,"potentialname"); 731 $potential_selected = "selected"; 732 733 } 734 elseif($parent_module == "Quotes") 735 { 736 $sql = "select * from vtiger_quotes where quoteid=".$value; 737 $result = $adb->query($sql); 738 $parent_name = $adb->query_result($result,0,"subject"); 739 $quote_selected = "selected"; 740 741 } 742 elseif($act_mode == "Task") 743 { 744 if($parent_module == "PurchaseOrder") 745 { 746 $sql = "select * from vtiger_purchaseorder where purchaseorderid=".$value; 747 $result = $adb->query($sql); 748 $parent_name = $adb->query_result($result,0,"subject"); 749 $purchase_selected = "selected"; 750 } 751 if($parent_module == "SalesOrder") 752 { 753 $sql = "select * from vtiger_salesorder where salesorderid=".$value; 754 $result = $adb->query($sql); 755 $parent_name = $adb->query_result($result,0,"subject"); 756 $sales_selected = "selected"; 757 } 758 if($parent_module == "Invoice") 759 { 760 $sql = "select * from vtiger_invoice where invoiceid=".$value; 761 $result = $adb->query($sql); 762 $parent_name = $adb->query_result($result,0,"subject"); 763 $invoice_selected = "selected"; 764 } 765 if($parent_module == "Campaigns") 766 { 767 $sql = "select campaignname from vtiger_campaign where campaignid=".$value; 768 $result = $adb->query($sql); 769 $parent_name = $adb->query_result($result,0,"campaignname"); 770 $campaign_selected = "selected"; 771 } 772 if($parent_module == "HelpDesk") 773 { 774 $sql = "select title from vtiger_troubletickets where ticketid=".$value; 775 $result = $adb->query($sql); 776 $parent_name = $adb->query_result($result,0,"title"); 777 $ticket_selected = "selected"; 778 } 779 } 780 elseif($act_mode == "Events") 781 { 782 if($parent_module == "HelpDesk") 783 { 784 $sql = "select title from vtiger_troubletickets where ticketid=".$value; 785 $result = $adb->query($sql); 786 $parent_name = $adb->query_result($result,0,"title"); 787 $ticket_selected = "selected"; 788 } 789 } 790 791 } 792 if($act_mode == "Task") 793 { 794 $editview_label[] = array($app_strings['COMBO_LEADS'], 795 $app_strings['COMBO_ACCOUNTS'], 796 $app_strings['COMBO_POTENTIALS'], 797 $app_strings['COMBO_QUOTES'], 798 $app_strings['COMBO_PORDER'], 799 $app_strings['COMBO_SORDER'], 800 $app_strings['COMBO_INVOICES'], 801 $app_strings['COMBO_CAMPAIGNS'], 802 $app_strings['COMBO_HELPDESK'] 803 ); 804 $editview_label[] = array($lead_selected, 805 $account_selected, 806 $potential_selected, 807 $quote_selected, 808 $purchase_selected, 809 $sales_selected, 810 $invoice_selected, 811 $campaign_selected, 812 $ticket_selected 813 ); 814 $editview_label[] = array("Leads&action=Popup","Accounts&action=Popup","Potentials&action=Popup","Quotes&action=Popup","PurchaseOrder&action=Popup","SalesOrder&action=Popup","Invoice&action=Popup","Campaigns&action=Popup","HelpDesk&action=Popup"); 815 } 816 elseif($act_mode == "Events") 817 { 818 $editview_label[] = array($app_strings['COMBO_LEADS'], 819 $app_strings['COMBO_ACCOUNTS'], 820 $app_strings['COMBO_POTENTIALS'], 821 $app_strings['COMBO_HELPDESK'] 822 ); 823 $editview_label[] = array($lead_selected, 824 $account_selected, 825 $potential_selected, 826 $ticket_selected 827 ); 828 $editview_label[] = array("Leads&action=Popup","Accounts&action=Popup","Potentials&action=Popup","HelpDesk&action=Popup"); 829 } 830 else 831 { 832 $editview_label[] = array($app_strings['COMBO_LEADS'], 833 $app_strings['COMBO_ACCOUNTS'], 834 $app_strings['COMBO_POTENTIALS'], 835 ); 836 $editview_label[] = array($lead_selected, 837 $account_selected, 838 $potential_selected 839 ); 840 $editview_label[] = array("Leads&action=Popup","Accounts&action=Popup","Potentials&action=Popup"); 841 842 } 843 $fieldvalue[] =$parent_name; 844 $fieldvalue[] = $value; 845 } 846 //added by rdhital/Raju for better email support 847 elseif($uitype == 357) 848 { 849 $contact_selected = 'selected'; 850 $account_selected = ''; 851 $lead_selected = ''; 852 if(isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '') 853 { 854 $parent_id = $_REQUEST['emailids']; 855 $parent_name=''; 856 $pmodule=$_REQUEST['pmodule']; 857 858 $myids=explode("|",$parent_id); 859 for ($i=0;$i<(count($myids)-1);$i++) 860 { 861 $realid=explode("@",$myids[$i]); 862 $entityid=$realid[0]; 863 $nemail=count($realid); 864 865 if ($pmodule=='Accounts'){ 866 require_once ('modules/Accounts/Accounts.php'); 867 $myfocus = new Accounts(); 868 $myfocus->retrieve_entity_info($entityid,"Accounts"); 869 $fullname=br2nl($myfocus->column_fields['accountname']); 870 $account_selected = 'selected'; 871 } 872 elseif ($pmodule=='Contacts'){ 873 require_once ('modules/Contacts/Contacts.php'); 874 $myfocus = new Contacts(); 875 $myfocus->retrieve_entity_info($entityid,"Contacts"); 876 $fname=br2nl($myfocus->column_fields['firstname']); 877 $lname=br2nl($myfocus->column_fields['lastname']); 878 $fullname=$lname.' '.$fname; 879 $contact_selected = 'selected'; 880 } 881 elseif ($pmodule=='Leads'){ 882 require_once ('modules/Leads/Leads.php'); 883 $myfocus = new Leads(); 884 $myfocus->retrieve_entity_info($entityid,"Leads"); 885 $fname=br2nl($myfocus->column_fields['firstname']); 886 $lname=br2nl($myfocus->column_fields['lastname']); 887 $fullname=$lname.' '.$fname; 888 $lead_selected = 'selected'; 889 } 890 for ($j=1;$j<$nemail;$j++){ 891 $querystr='select columnname from vtiger_field where fieldid='.$realid[$j].';'; 892 $result=$adb->query($querystr); 893 $temp=$adb->query_result($result,0,'columnname'); 894 $temp1=br2nl($myfocus->column_fields[$temp]); 895 896 //Modified to display the entities in red which don't have email id 897 if(strlen($temp_parent_name) > 150) 898 { 899 $parent_name .= '<br>'; 900 $temp_parent_name = ''; 901 } 902 903 if($temp1 != '') 904 { 905 $parent_name .= $fullname.'<'.$temp1.'>; '; 906 $temp_parent_name .= $fullname.'<'.$temp1.'>; '; 907 } 908 else 909 { 910 $parent_name .= "<b style='color:red'>".$fullname.'<'.$temp1.'>; '."</b>"; 911 $temp_parent_name .= "<b style='color:red'>".$fullname.'<'.$temp1.'>; '."</b>"; 912 } 913 914 } 915 } 916 } 917 else 918 { 919 $parent_name=''; 920 $parent_id=''; 921 $myemailid= $_REQUEST['record']; 922 $mysql = "select crmid from vtiger_seactivityrel where activityid=".$myemailid; 923 $myresult = $adb->query($mysql); 924 $mycount=$adb->num_rows($myresult); 925 if($mycount >0) 926 { 927 for ($i=0;$i<$mycount;$i++) 928 { 929 $mycrmid=$adb->query_result($myresult,$i,'crmid'); 930 $parent_module = getSalesEntityType($mycrmid); 931 if($parent_module == "Leads") 932 { 933 $sql = "select firstname,lastname,email from vtiger_leaddetails where leadid=".$mycrmid; 934 $result = $adb->query($sql); 935 $first_name = $adb->query_result($result,0,"firstname"); 936 $last_name = $adb->query_result($result,0,"lastname"); 937 $myemail=$adb->query_result($result,0,"email"); 938 $parent_id .=$mycrmid.'@0|' ; //make it such that the email adress sent is remebered and only that one is retrived 939 $parent_name .= $last_name.' '.$first_name.'<'.$myemail.'>; '; 940 $lead_selected = 'selected'; 941 } 942 elseif($parent_module == "Contacts") 943 { 944 $sql = "select * from vtiger_contactdetails where contactid=".$mycrmid; 945 $result = $adb->query($sql); 946 $first_name = $adb->query_result($result,0,"firstname"); 947 $last_name = $adb->query_result($result,0,"lastname"); 948 $myemail=$adb->query_result($result,0,"email"); 949 $parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived 950 $parent_name .= $last_name.' '.$first_name.'<'.$myemail.'>; '; 951 $contact_selected = 'selected'; 952 } 953 elseif($parent_module == "Accounts") 954 { 955 $sql = "select * from vtiger_account where accountid=".$mycrmid; 956 $result = $adb->query($sql); 957 $account_name = $adb->query_result($result,0,"accountname"); 958 $myemail=$adb->query_result($result,0,"email1"); 959 $parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived 960 $parent_name .= $account_name.'<'.$myemail.'>; '; 961 $account_selected = 'selected'; 962 }elseif($parent_module == "Users") 963 { 964 $sql = "select user_name,email1 from vtiger_users where id=".$mycrmid; 965 $result = $adb->query($sql); 966 $account_name = $adb->query_result($result,0,"user_name"); 967 $myemail=$adb->query_result($result,0,"email1"); 968 $parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived 969 $parent_name .= $account_name.'<'.$myemail.'>; '; 970 $user_selected = 'selected'; 971 } 972 } 973 } 974 } 975 $custfld .= '<td width="20%" class="dataLabel">To: </td>'; 976 $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> <select name="parent_type" >'; 977 $custfld .= '<OPTION value="Contacts" selected>'.$app_strings['COMBO_CONTACTS'].'</OPTION>'; 978 $custfld .= '<OPTION value="Accounts" >'.$app_strings['COMBO_ACCOUNTS'].'</OPTION>'; 979 $custfld .= '<OPTION value="Leads" >'.$app_strings['COMBO_LEADS'].'</OPTION></select><img src="'.$image_path.'select.gif" 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\'> <input type="image" src="'.$image_path.'clear_field.gif" 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>'; 980 $editview_label[] = array( 981 'Contacts'=>$contact_selected, 982 'Accounts'=>$account_selected, 983 'Leads'=>$lead_selected, 984 'Users'=>$user_selected 985 ); 986 $fieldvalue[] =$parent_name; 987 $fieldvalue[] = $parent_id; 988 989 } 990 //end of rdhital/Raju 991 elseif($uitype == 68) 992 { 993 if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') 994 $value = $_REQUEST['parent_id']; 995 996 if($value != '') 997 { 998 $parent_module = getSalesEntityType($value); 999 if($parent_module == "Contacts") 1000 { 1001 $sql = "select * from vtiger_contactdetails where contactid=".$value; 1002 $result = $adb->query($sql); 1003 $first_name = $adb->query_result($result,0,"firstname"); 1004 $last_name = $adb->query_result($result,0,"lastname"); 1005 $parent_name = $last_name.' '.$first_name; 1006 $contact_selected = "selected"; 1007 1008 } 1009 elseif($parent_module == "Accounts") 1010 { 1011 $sql = "select * from vtiger_account where accountid=".$value; 1012 $result = $adb->query($sql); 1013 $parent_name = $adb->query_result($result,0,"accountname"); 1014 $account_selected = "selected"; 1015 1016 } 1017 } 1018 $editview_label[] = array($app_strings['COMBO_CONTACTS'], 1019 $app_strings['COMBO_ACCOUNTS'] 1020 ); 1021 $editview_label[] = array($contact_selected, 1022 $account_selected 1023 ); 1024 $editview_label[] = array("Contacts","Accounts"); 1025 $fieldvalue[] = $parent_name; 1026 $fieldvalue[] = $value; 1027 } 1028 1029 elseif($uitype == 71 || $uitype == 72) 1030 { 1031 $rate_symbol = getCurrencySymbolandCRate($user_info['currency_id']); 1032 $rate = $rate_symbol['rate']; 1033 $currency= $rate_symbol['symbol']; 1034 $editview_label[]=$mod_strings[$fieldlabel].': ('.$currency.')'; 1035 if($value!='') 1036 $fieldvalue[] = convertFromDollar($value,$rate); 1037 else 1038 $fieldvalue[] = $value; 1039 } 1040 elseif($uitype == 75 || $uitype ==81) 1041 { 1042 if($value != '') 1043 { 1044 $vendor_name = getVendorName($value); 1045 } 1046 elseif(isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '') 1047 { 1048 $value = $_REQUEST['vendor_id']; 1049 $vendor_name = getVendorName($value); 1050 } 1051 $pop_type = 'specific'; 1052 if($uitype == 81) 1053 { 1054 $pop_type = 'specific_vendor_address'; 1055 } 1056 $editview_label[]=$mod_strings[$fieldlabel]; 1057 $fieldvalue[] = $vendor_name; 1058 $fieldvalue[] = $value; 1059 } 1060 elseif($uitype == 76) 1061 { 1062 if($value != '') 1063 { 1064 $potential_name = getPotentialName($value); 1065 } 1066 elseif(isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') 1067 { 1068 $value = $_REQUEST['potental_id']; 1069 $potential_name = getPotentialName($value); 1070 } 1071 $editview_label[]=$mod_strings[$fieldlabel]; 1072 $fieldvalue[] = $potential_name; 1073 $fieldvalue[] = $value; 1074 } 1075 elseif($uitype == 78) 1076 { 1077 if($value != '') 1078 { 1079 $quote_name = getQuoteName($value); 1080 } 1081 elseif(isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') 1082 { 1083 $value = $_REQUEST['quote_id']; 1084 $potential_name = getQuoteName($value); 1085 } 1086 $editview_label[]=$mod_strings[$fieldlabel]; 1087 $fieldvalue[] = $quote_name; 1088 $fieldvalue[] = $value; 1089 } 1090 elseif($uitype == 79) 1091 { 1092 if($value != '') 1093 { 1094 $purchaseorder_name = getPoName($value); 1095 } 1096 elseif(isset($_REQUEST['purchaseorder_id']) && $_REQUEST['purchaseorder_id'] != '') 1097 { 1098 $value = $_REQUEST['purchaseorder_id']; 1099 $purchaseorder_name = getPoName($value); 1100 } 1101 $editview_label[]=$mod_strings[$fieldlabel]; 1102 $fieldvalue[] = $purchaseorder_name; 1103 $fieldvalue[] = $value; 1104 } 1105 elseif($uitype == 80) 1106 { 1107 if($value != '') 1108 { 1109 $salesorder_name = getSoName($value); 1110 } 1111 elseif(isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') 1112 { 1113 $value = $_REQUEST['salesorder_id']; 1114 $salesorder_name = getSoName($value); 1115 } 1116 $editview_label[]=$mod_strings[$fieldlabel]; 1117 $fieldvalue[] = $salesorder_name; 1118 $fieldvalue[] = $value; 1119 } 1120 elseif($uitype == 30) 1121 { 1122 $rem_days = 0; 1123 $rem_hrs = 0; 1124 $rem_min = 0; 1125 if($value!='') 1126 $SET_REM = "CHECKED"; 1127 $rem_days = floor($col_fields[$fieldname]/(24*60)); 1128 $rem_hrs = floor(($col_fields[$fieldname]-$rem_days*24*60)/60); 1129 $rem_min = ($col_fields[$fieldname]-$rem_days*24*60)%60; 1130 $editview_label[]=$mod_strings[$fieldlabel]; 1131 $day_options = getReminderSelectOption(0,31,'remdays',$rem_days); 1132 $hr_options = getReminderSelectOption(0,23,'remhrs',$rem_hrs); 1133 $min_options = getReminderSelectOption(1,59,'remmin',$rem_min); 1134 $fieldvalue[] = array(array(0,32,'remdays',$mod_strings['LBL_DAYS'],$rem_days),array(0,24,'remhrs',$mod_strings['LBL_HOURS'],$rem_hrs),array(1,60,'remmin',$mod_strings['LBL_MINUTES'].' '.$mod_strings['LBL_BEFORE_EVENT'],$rem_min)); 1135 $fieldvalue[] = array($SET_REM,$mod_strings['LBL_YES'],$mod_strings['LBL_NO']); 1136 $SET_REM = ''; 1137 } 1138 elseif($uitype == 115) 1139 { 1140 $editview_label[]=$mod_strings[$fieldlabel]; 1141 $pick_query="select * from vtiger_".$fieldname; 1142 $pickListResult = $adb->query($pick_query); 1143 $noofpickrows = $adb->num_rows($pickListResult); 1144 1145 //Mikecrowe fix to correctly default for custom pick lists 1146 $options = array(); 1147 $found = false; 1148 for($j = 0; $j < $noofpickrows; $j++) 1149 { 1150 $pickListValue=$adb->query_result($pickListResult,$j,strtolower($fieldname)); 1151 1152 if($value == $pickListValue) 1153 { 1154 $chk_val = "selected"; 1155 $found = true; 1156 } 1157 else 1158 { 1159 $chk_val = ''; 1160 } 1161 $options[] = array($pickListValue=>$chk_val ); 1162 } 1163 $fieldvalue [] = $options; 1164 $fieldvalue [] = $is_admin; 1165 } 1166 elseif($uitype == 116) 1167 { 1168 $editview_label[]=$mod_strings[$fieldlabel]; 1169 $pick_query="select * from vtiger_currency_info where currency_status = 'Active'"; 1170 $pickListResult = $adb->query($pick_query); 1171 $noofpickrows = $adb->num_rows($pickListResult); 1172 1173 //Mikecrowe fix to correctly default for custom pick lists 1174 $options = array(); 1175 $found = false; 1176 for($j = 0; $j < $noofpickrows; $j++) 1177 { 1178 $pickListValue=$adb->query_result($pickListResult,$j,'currency_name'); 1179 $currency_id=$adb->query_result($pickListResult,$j,'id'); 1180 if($value == $currency_id) 1181 { 1182 $chk_val = "selected"; 1183 $found = true; 1184 } 1185 else 1186 { 1187 $chk_val = ''; 1188 } 1189 $options[$currency_id] = array($pickListValue=>$chk_val ); 1190 } 1191 $fieldvalue [] = $options; 1192 $fieldvalue [] = $is_admin; 1193 } 1194 elseif($uitype ==98) 1195 { 1196 $editview_label[]=$mod_strings[$fieldlabel]; 1197 $fieldvalue[]=$value; 1198 $fieldvalue[]=getRoleName($value); 1199 $fieldvalue[]=$is_admin; 1200 } 1201 elseif($uitype == 105) 1202 { 1203 $editview_label[]=$mod_strings[$fieldlabel]; 1204 if( isset( $col_fields['record_id']) && $col_fields['record_id'] != '') { 1205 $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=".$col_fields['record_id']; 1206 $result_image = $adb->query($query); 1207 for($image_iter=0;$image_iter < $adb->num_rows($result_image);$image_iter++) 1208 { 1209 $image_array[] = $adb->query_result($result_image,$image_iter,'name'); 1210 $image_path_array[] = $adb->query_result($result_image,$image_iter,'path'); 1211 } 1212 } 1213 if(is_array($image_array)) 1214 for($img_itr=0;$img_itr<count($image_array);$img_itr++) 1215 { 1216 $fieldvalue[] = array('name'=>$image_array[$img_itr],'path'=>$image_path_array[$img_itr]); 1217 } 1218 else 1219 $fieldvalue[] = ''; 1220 }elseif($uitype == 101) 1221 { 1222 $editview_label[]=$mod_strings[$fieldlabel]; 1223 $fieldvalue[] = getUserName($value); 1224 $fieldvalue[] = $value; 1225 } 1226 else 1227 { 1228 //Added condition to set the subject if click Reply All from web mail 1229 if($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '') 1230 { 1231 $value = $_REQUEST['mg_subject']; 1232 } 1233 $editview_label[]=$mod_strings[$fieldlabel]; 1234 if($uitype == 1 && ($fieldname=='expectedrevenue' || $fieldname=='budgetcost' || $fieldname=='actualcost' || $fieldname=='expectedroi' || $fieldname=='actualroi' ) && ($module_name=='Campaigns')) 1235 { 1236 $rate_symbol = getCurrencySymbolandCRate($user_info['currency_id']); 1237 $fieldvalue[] = convertFromDollar($value,$rate_symbol['rate']); 1238 } 1239 else 1240 $fieldvalue[] = $value; 1241 } 1242 1243 // Mike Crowe Mod --------------------------------------------------------force numerics right justified. 1244 if ( !eregi("id=",$custfld) ) 1245 $custfld = preg_replace("/<input/iS","<input id='$fieldname' ",$custfld); 1246 1247 if ( in_array($uitype,array(71,72,7,9,90)) ) 1248 { 1249 $custfld = preg_replace("/<input/iS","<input align=right ",$custfld); 1250 } 1251 $final_arr[]=$ui_type; 1252 $final_arr[]=$editview_label; 1253 $final_arr[]=$editview_fldname; 1254 $final_arr[]=$fieldvalue; 1255 $log->debug("Exiting getOutputHtml method ..."); 1256 return $final_arr; 1257 } 1258 1259 /** This function returns the vtiger_invoice object populated with the details from sales order object. 1260 * Param $focus - Invoice object 1261 * Param $so_focus - Sales order focus 1262 * Param $soid - sales order id 1263 * Return type is an object array 1264 */ 1265 1266 function getConvertSoToInvoice($focus,$so_focus,$soid) 1267 { 1268 global $log; 1269 $log->debug("Entering getConvertSoToInvoice(".$focus.",".$so_focus.",".$soid.") method ..."); 1270 $log->info("in getConvertSoToInvoice ".$soid); 1271 1272 $focus->column_fields['salesorder_id'] = $soid; 1273 $focus->column_fields['subject'] = $so_focus->column_fields['subject']; 1274 $focus->column_fields['customerno'] = $so_focus->column_fields['customerno']; 1275 $focus->column_fields['duedate'] = $so_focus->column_fields['duedate']; 1276 $focus->column_fields['contact_id'] = $so_focus->column_fields['contact_id'];//to include contact name in Invoice 1277 $focus->column_fields['account_id'] = $so_focus->column_fields['account_id']; 1278 $focus->column_fields['exciseduty'] = $so_focus->column_fields['exciseduty']; 1279 $focus->column_fields['salescommission'] = $so_focus->column_fields['salescommission']; 1280 $focus->column_fields['purchaseorder'] = $so_focus->column_fields['purchaseorder']; 1281 $focus->column_fields['bill_street'] = $so_focus->column_fields['bill_street']; 1282 $focus->column_fields['ship_street'] = $so_focus->column_fields['ship_street']; 1283 $focus->column_fields['bill_city'] = $so_focus->column_fields['bill_city']; 1284 $focus->column_fields['ship_city'] = $so_focus->column_fields['ship_city']; 1285 $focus->column_fields['bill_state'] = $so_focus->column_fields['bill_state']; 1286 $focus->column_fields['ship_state'] = $so_focus->column_fields['ship_state']; 1287 $focus->column_fields['bill_code'] = $so_focus->column_fields['bill_code']; 1288 $focus->column_fields['ship_code'] = $so_focus->column_fields['ship_code']; 1289 $focus->column_fields['bill_country'] = $so_focus->column_fields['bill_country']; 1290 $focus->column_fields['ship_country'] = $so_focus->column_fields['ship_country']; 1291 $focus->column_fields['bill_pobox'] = $so_focus->column_fields['bill_pobox']; 1292 $focus->column_fields['ship_pobox'] = $so_focus->column_fields['ship_pobox']; 1293 $focus->column_fields['description'] = $so_focus->column_fields['description']; 1294 $focus->column_fields['terms_conditions'] = $so_focus->column_fields['terms_conditions']; 1295 1296 $log->debug("Exiting getConvertSoToInvoice method ..."); 1297 return $focus; 1298 1299 } 1300 1301 /** This function returns the vtiger_invoice object populated with the details from quote object. 1302 * Param $focus - Invoice object 1303 * Param $quote_focus - Quote order focus 1304 * Param $quoteid - quote id 1305 * Return type is an object array 1306 */ 1307 1308 1309 function getConvertQuoteToInvoice($focus,$quote_focus,$quoteid) 1310 { 1311 global $log; 1312 $log->debug("Entering getConvertQuoteToInvoice(".$focus.",".$quote_focus.",".$quoteid.") method ..."); 1313 $log->info("in getConvertQuoteToInvoice ".$quoteid); 1314 1315 $focus->column_fields['subject'] = $quote_focus->column_fields['subject']; 1316 $focus->column_fields['account_id'] = $quote_focus->column_fields['account_id']; 1317 $focus->column_fields['bill_street'] = $quote_focus->column_fields['bill_street']; 1318 $focus->column_fields['ship_street'] = $quote_focus->column_fields['ship_street']; 1319 $focus->column_fields['bill_city'] = $quote_focus->column_fields['bill_city']; 1320 $focus->column_fields['ship_city'] = $quote_focus->column_fields['ship_city']; 1321 $focus->column_fields['bill_state'] = $quote_focus->column_fields['bill_state']; 1322 $focus->column_fields['ship_state'] = $quote_focus->column_fields['ship_state']; 1323 $focus->column_fields['bill_code'] = $quote_focus->column_fields['bill_code']; 1324 $focus->column_fields['ship_code'] = $quote_focus->column_fields['ship_code']; 1325 $focus->column_fields['bill_country'] = $quote_focus->column_fields['bill_country']; 1326 $focus->column_fields['ship_country'] = $quote_focus->column_fields['ship_country']; 1327 $focus->column_fields['bill_pobox'] = $quote_focus->column_fields['bill_pobox']; 1328 $focus->column_fields['ship_pobox'] = $quote_focus->column_fields['ship_pobox']; 1329 $focus->column_fields['description'] = $quote_focus->column_fields['description']; 1330 $focus->column_fields['terms_conditions'] = $quote_focus->column_fields['terms_conditions']; 1331 1332 $log->debug("Exiting getConvertQuoteToInvoice method ..."); 1333 return $focus; 1334 1335 } 1336 1337 /** This function returns the sales order object populated with the details from quote object. 1338 * Param $focus - Sales order object 1339 * Param $quote_focus - Quote order focus 1340 * Param $quoteid - quote id 1341 * Return type is an object array 1342 */ 1343 1344 function getConvertQuoteToSoObject($focus,$quote_focus,$quoteid) 1345 { 1346 global $log; 1347 $log->debug("Entering getConvertQuoteToSoObject(".$focus.",".$quote_focus.",".$quoteid.") method ..."); 1348 $log->info("in getConvertQuoteToSoObject ".$quoteid); 1349 1350 $focus->column_fields['quote_id'] = $quoteid; 1351 $focus->column_fields['subject'] = $quote_focus->column_fields['subject']; 1352 $focus->column_fields['contact_id'] = $quote_focus->column_fields['contact_id']; 1353 $focus->column_fields['potential_id'] = $quote_focus->column_fields['potential_id']; 1354 $focus->column_fields['account_id'] = $quote_focus->column_fields['account_id']; 1355 $focus->column_fields['carrier'] = $quote_focus->column_fields['carrier']; 1356 $focus->column_fields['bill_street'] = $quote_focus->column_fields['bill_street']; 1357 $focus->column_fields['ship_street'] = $quote_focus->column_fields['ship_street']; 1358 $focus->column_fields['bill_city'] = $quote_focus->column_fields['bill_city']; 1359 $focus->column_fields['ship_city'] = $quote_focus->column_fields['ship_city']; 1360 $focus->column_fields['bill_state'] = $quote_focus->column_fields['bill_state']; 1361 $focus->column_fields['ship_state'] = $quote_focus->column_fields['ship_state']; 1362 $focus->column_fields['bill_code'] = $quote_focus->column_fields['bill_code']; 1363 $focus->column_fields['ship_code'] = $quote_focus->column_fields['ship_code']; 1364 $focus->column_fields['bill_country'] = $quote_focus->column_fields['bill_country']; 1365 $focus->column_fields['ship_country'] = $quote_focus->column_fields['ship_country']; 1366 $focus->column_fields['bill_pobox'] = $quote_focus->column_fields['bill_pobox']; 1367 $focus->column_fields['ship_pobox'] = $quote_focus->column_fields['ship_pobox']; 1368 $focus->column_fields['description'] = $quote_focus->column_fields['description']; 1369 $focus->column_fields['terms_conditions'] = $quote_focus->column_fields['terms_conditions']; 1370 1371 $log->debug("Exiting getConvertQuoteToSoObject method ..."); 1372 return $focus; 1373 1374 } 1375 1376 /** This function returns the detailed list of vtiger_products associated to a given entity or a record. 1377 * Param $module - module name 1378 * Param $focus - module object 1379 * Param $seid - sales entity id 1380 * Return type is an object array 1381 */ 1382 1383 1384 function getAssociatedProducts($module,$focus,$seid='') 1385 { 1386 global $log; 1387 $log->debug("Entering getAssociatedProducts($module,$focus,$seid='') method ..."); 1388 global $adb; 1389 $output = ''; 1390 global $theme,$current_user; 1391 1392 $theme_path="themes/".$theme."/"; 1393 $image_path=$theme_path."images/"; 1394 $product_Detail = Array(); 1395 1396 // DG 15 Aug 2006 1397 // Add "ORDER BY sequence_no" to retain add order on all inventoryproductrel items 1398 1399 if($module == 'Quotes') 1400 { 1401 $query="select vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price, vtiger_products.qtyinstock, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=".$focus->id." ORDER BY sequence_no"; 1402 } 1403 elseif($module == 'PurchaseOrder') 1404 { 1405 $query="select vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price, vtiger_products.qtyinstock, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=".$focus->id." ORDER BY sequence_no"; 1406 } 1407 elseif($module == 'SalesOrder') 1408 { 1409 $query="select vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price, vtiger_products.qtyinstock, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=".$focus->id." ORDER BY sequence_no"; 1410 } 1411 elseif($module == 'Invoice') 1412 { 1413 $query="select vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price, vtiger_products.qtyinstock, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=".$focus->id." ORDER BY sequence_no"; 1414 } 1415 elseif($module == 'Potentials') 1416 { 1417 $query="select vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_seproductsrel.* from vtiger_products inner join vtiger_seproductsrel on vtiger_seproductsrel.productid=vtiger_products.productid where crmid=".$seid; 1418 } 1419 elseif($module == 'Products') 1420 { 1421 $query="select vtiger_products.productid, vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_crmentity.* from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid where vtiger_crmentity.deleted=0 and productid=".$seid; 1422 } 1423 1424 $result = $adb->query($query); 1425 $num_rows=$adb->num_rows($result); 1426 for($i=1;$i<=$num_rows;$i++) 1427 { 1428 $hdnProductId = $adb->query_result($result,$i-1,'productid'); 1429 $productname=$adb->query_result($result,$i-1,'productname'); 1430 $productdescription=$adb->query_result($result,$i-1,'product_description'); 1431 $comment=$adb->query_result($result,$i-1,'comment'); 1432 $qtyinstock=$adb->query_result($result,$i-1,'qtyinstock'); 1433 $qty=$adb->query_result($result,$i-1,'quantity'); 1434 $unitprice=$adb->query_result($result,$i-1,'unit_price'); 1435 $listprice=$adb->query_result($result,$i-1,'listprice'); 1436 1437 if($listprice == '') 1438 $listprice = $unitprice; 1439 if($qty =='') 1440 $qty = 1; 1441 1442 //calculate productTotal 1443 $productTotal = $qty*$listprice; 1444 1445 //Delete link in First column 1446 if($i != 1) 1447 { 1448 $product_Detail[$i]['delRow'.$i]="Del"; 1449 } 1450 1451 $product_Detail[$i]['hdnProductId'.$i] = $hdnProductId; 1452 $product_Detail[$i]['productName'.$i]= $productname; 1453 $product_Detail[$i]['productDescription'.$i]= $productdescription; 1454 $product_Detail[$i]['comment'.$i]= $comment; 1455 1456 if($module != 'PurchaseOrder' && $focus->object_name != 'Order') 1457 { 1458 $product_Detail[$i]['qtyInStock'.$i]=$qtyinstock; 1459 } 1460 $listprice = getConvertedPriceFromDollar($listprice); 1461 $productTotal = getConvertedPriceFromDollar($productTotal); 1462 $product_Detail[$i]['qty'.$i]=$qty; 1463 $product_Detail[$i]['listPrice'.$i]=$listprice; 1464 $product_Detail[$i]['unitPrice'.$i]=$unitprice; 1465 $product_Detail[$i]['productTotal'.$i]=$productTotal; 1466 1467 $discount_percent=$adb->query_result($result,$i-1,'discount_percent'); 1468 $discount_amount=$adb->query_result($result,$i-1,'discount_amount'); 1469 $discountTotal = '0.00'; 1470 //Based on the discount percent or amount we will show the discount details 1471 if($discount_percent != 'NULL' && $discount_percent != '') 1472 { 1473 $product_Detail[$i]['discount_type'.$i] = "percentage"; 1474 $product_Detail[$i]['discount_percent'.$i] = $discount_percent; 1475 $product_Detail[$i]['checked_discount_percent'.$i] = ' checked'; 1476 $product_Detail[$i]['style_discount_percent'.$i] = ' style="visibility:visible"'; 1477 $product_Detail[$i]['style_discount_amount'.$i] = ' style="visibility:hidden"'; 1478 $discountTotal = $productTotal*$discount_percent/100; 1479 } 1480 elseif($discount_amount != 'NULL' && $discount_amount != '') 1481 { 1482 $discount_amount = getConvertedPriceFromDollar($discount_amount); 1483 1484 $product_Detail[$i]['discount_type'.$i] = "amount"; 1485 $product_Detail[$i]['discount_amount'.$i] = $discount_amount; 1486 $product_Detail[$i]['checked_discount_amount'.$i] = ' checked'; 1487 $product_Detail[$i]['style_discount_amount'.$i] = ' style="visibility:visible"'; 1488 $product_Detail[$i]['style_discount_percent'.$i] = ' style="visibility:hidden"'; 1489 $discountTotal = $discount_amount; 1490 } 1491 else 1492 { 1493 $product_Detail[$i]['checked_discount_zero'.$i] = ' checked'; 1494 } 1495 $totalAfterDiscount = $productTotal-$discountTotal; 1496 $product_Detail[$i]['discountTotal'.$i] = $discountTotal; 1497 $product_Detail[$i]['totalAfterDiscount'.$i] = $totalAfterDiscount; 1498 1499 //First we will get all associated taxes as array 1500 $tax_details = getTaxDetailsForProduct($hdnProductId,'all'); 1501 //Now retrieve the tax values from the current query with the name 1502 for($tax_count=0;$tax_count<count($tax_details);$tax_count++) 1503 { 1504 $tax_name = $tax_details[$tax_count]['taxname']; 1505 $tax_label = $tax_details[$tax_count]['taxlabel']; 1506 $tax_value = '0.00'; 1507 1508 //condition to avoid this function call when create new PO/SO/Quotes/Invoice from Product module 1509 if($focus->id != '') 1510 $tax_value = getInventoryProductTaxValue($focus->id, $hdnProductId, $tax_name); 1511 else//if the above function not called then assign the default associated value of the product 1512 $tax_value = $tax_details[$tax_count]['percentage']; 1513 1514 $product_Detail[$i]['taxes'][$tax_count]['taxname'] = $tax_name; 1515 $product_Detail[$i]['taxes'][$tax_count]['taxlabel'] = $tax_label; 1516 $product_Detail[$i]['taxes'][$tax_count]['percentage'] = $tax_value; 1517 } 1518 1519 $taxTotal = '0.00'; 1520 $product_Detail[$i]['taxTotal'.$i] = $taxTotal; 1521 1522 //Calculate netprice 1523 $netPrice = $totalAfterDiscount+$taxTotal; 1524 //if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module 1525 if($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice') 1526 { 1527 $taxtype = getInventoryTaxType($module,$focus->id); 1528 if($taxtype == 'individual') 1529 { 1530 //Add the tax with product total and assign to netprice 1531 $netPrice = $netPrice+$taxTotal; 1532 } 1533 } 1534 $product_Detail[$i]['netPrice'.$i] = $netPrice; 1535 } 1536 1537 //set the taxtype 1538 $product_Detail[1]['final_details']['taxtype'] = $taxtype; 1539 1540 //Get the Final Discount, S&H charge, Tax for S&H and Adjustment values 1541 //To set the Final Discount details 1542 $finalDiscount = '0.00'; 1543 $product_Detail[1]['final_details']['discount_type_final'] = 'zero'; 1544 1545 $subTotal = ($focus->column_fields['hdnSubTotal'] != '')?$focus->column_fields['hdnSubTotal']:'0.00'; 1546 $subTotal = getConvertedPriceFromDollar($subTotal); 1547 1548 $discountPercent = ($focus->column_fields['hdnDiscountPercent'] != '')?$focus->column_fields['hdnDiscountPercent']:'0.00'; 1549 $discountAmount = ($focus->column_fields['hdnDiscountAmount'] != '')?$focus->column_fields['hdnDiscountAmount']:'0.00'; 1550 1551 if($focus->column_fields['hdnDiscountPercent'] != '') 1552 { 1553 $finalDiscount = ($subTotal*$discountPercent/100); 1554 $product_Detail[1]['final_details']['discount_type_final'] = 'percentage'; 1555 $product_Detail[1]['final_details']['discount_percentage_final'] = $discountPercent; 1556 $product_Detail[1]['final_details']['checked_discount_percentage_final'] = ' checked'; 1557 $product_Detail[1]['final_details']['style_discount_percentage_final'] = ' style="visibility:visible"'; 1558 $product_Detail[1]['final_details']['style_discount_amount_final'] = ' style="visibility:hidden"'; 1559 } 1560 elseif($focus->column_fields['hdnDiscountAmount'] != '') 1561 { 1562 $finalDiscount = $focus->column_fields['hdnDiscountAmount']; 1563 $finalDiscount = getConvertedPriceFromDollar($finalDiscount); 1564 $discountAmount = getConvertedPriceFromDollar($discountAmount); 1565 1566 $product_Detail[1]['final_details']['discount_type_final'] = 'amount'; 1567 $product_Detail[1]['final_details']['discount_amount_final'] = $discountAmount; 1568 $product_Detail[1]['final_details']['checked_discount_amount_final'] = ' checked'; 1569 $product_Detail[1]['final_details']['style_discount_amount_final'] = ' style="visibility:visible"'; 1570 $product_Detail[1]['final_details']['style_discount_percentage_final'] = ' style="visibility:hidden"'; 1571 } 1572 $product_Detail[1]['final_details']['discountTotal_final'] = $finalDiscount; 1573 1574 //To set the Final Tax values 1575 if($taxtype == 'group') 1576 { 1577 $taxtotal = '0.00'; 1578 //First we should get all available taxes and then retrieve the corresponding tax values 1579 $tax_details = getAllTaxes('available'); 1580 //if taxtype is group then the tax will be same for all products in vtiger_inventoryproductrel table 1581 for($tax_count=0;$tax_count<count($tax_details);$tax_count++) 1582 { 1583 $tax_name = $tax_details[$tax_count]['taxname']; 1584 $tax_label = $tax_details[$tax_count]['taxlabel']; 1585 $tax_percent = $adb->query_result($result,0,$tax_name); 1586 if($tax_percent == '' || $tax_percent == 'NULL') 1587 $tax_percent = '0.00'; 1588 $taxamount = ($subTotal-$finalDiscount)*$tax_percent/100; 1589 $taxtotal = $taxtotal + $taxamount; 1590 $product_Detail[1]['final_details']['taxes'][$tax_count]['taxname'] = $tax_name; 1591 $product_Detail[1]['final_details']['taxes'][$tax_count]['taxlabel'] = $tax_label; 1592 $product_Detail[1]['final_details']['taxes'][$tax_count]['percentage'] = $tax_percent; 1593 $product_Detail[1]['final_details']['taxes'][$tax_count]['amount'] = $taxamount; 1594 } 1595 $product_Detail[1]['final_details']['tax_totalamount'] = $taxtotal; 1596 } 1597 1598 //To set the Shipping & Handling charge 1599 $shCharge = ($focus->column_fields['hdnS_H_Amount'] != '')?$focus->column_fields['hdnS_H_Amount']:'0.00'; 1600 $shCharge = getConvertedPriceFromDollar($shCharge); 1601 $product_Detail[1]['final_details']['shipping_handling_charge'] = $shCharge; 1602 1603 //To set the Shipping & Handling tax values 1604 //calculate S&H tax 1605 $shtaxtotal = '0.00'; 1606 //First we should get all available taxes and then retrieve the corresponding tax values 1607 $shtax_details = getAllTaxes('available','sh'); 1608 1609 //if taxtype is group then the tax should be same for all products in vtiger_inventoryproductrel table 1610 for($shtax_count=0;$shtax_count<count($shtax_details);$shtax_count++) 1611 { 1612 $shtax_name = $shtax_details[$shtax_count]['taxname']; 1613 $shtax_label = $shtax_details[$shtax_count]['taxlabel']; 1614 $shtax_percent = '0.00'; 1615 //if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module 1616 if($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice') 1617 { 1618 $shtax_percent = getInventorySHTaxPercent($focus->id,$shtax_name); 1619 } 1620 $shtaxamount = $shCharge*$shtax_percent/100; 1621 $shtaxtotal = $shtaxtotal + $shtaxamount; 1622 $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['taxname'] = $shtax_name; 1623 $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['taxlabel'] = $shtax_label; 1624 $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['percentage'] = $shtax_percent; 1625 $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['amount'] = $shtaxamount; 1626 } 1627 $product_Detail[1]['final_details']['shtax_totalamount'] = $shtaxtotal; 1628 1629 //To set the Adjustment value 1630 $adjustment = ($focus->column_fields['txtAdjustment'] != '')?$focus->column_fields['txtAdjustment']:'0.00'; 1631 $adjustment = getConvertedPriceFromDollar($adjustment); 1632 $product_Detail[1]['final_details']['adjustment'] = $adjustment; 1633 1634 //To set the grand total 1635 $grandTotal = ($focus->column_fields['hdnGrandTotal'] != '')?$focus->column_fields['hdnGrandTotal']:'0.00'; 1636 $grandTotal = getConvertedPriceFromDollar($grandTotal); 1637 $product_Detail[1]['final_details']['grandTotal'] = $grandTotal; 1638 1639 $log->debug("Exiting getAssociatedProducts method ..."); 1640 1641 return $product_Detail; 1642 1643 } 1644 1645 /** This function returns the no of vtiger_products associated to the given entity or a record. 1646 * Param $module - module name 1647 * Param $focus - module object 1648 * Param $seid - sales entity id 1649 * Return type is an object array 1650 */ 1651 1652 function getNoOfAssocProducts($module,$focus,$seid='') 1653 { 1654 global $log; 1655 $log->debug("Entering getNoOfAssocProducts($module,$focus,$seid='') method ..."); 1656 global $adb; 1657 $output = ''; 1658 if($module == 'Quotes') 1659 { 1660 $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=".$focus->id; 1661 } 1662 elseif($module == 'PurchaseOrder') 1663 { 1664 $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=".$focus->id; 1665 } 1666 elseif($module == 'SalesOrder') 1667 { 1668 $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=".$focus->id; 1669 } 1670 elseif($module == 'Invoice') 1671 { 1672 $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=".$focus->id; 1673 } 1674 elseif($module == 'Potentials') 1675 { 1676 $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=".$seid; 1677 } 1678 elseif($module == 'Products') 1679 { 1680 $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=".$seid; 1681 } 1682 1683 1684 $result = $adb->query($query); 1685 $num_rows=$adb->num_rows($result); 1686 $log->debug("Exiting getNoOfAssocProducts method ..."); 1687 return $num_rows; 1688 } 1689 1690 /** This function returns the detail block information of a record for given block id. 1691 * Param $module - module name 1692 * Param $block - block name 1693 * Param $mode - view type (detail/edit/create) 1694 * Param $col_fields - vtiger_fields array 1695 * Param $tabid - vtiger_tab id 1696 * Param $info_type - information type (basic/advance) default "" 1697 * Return type is an object array 1698 */ 1699 1700 function getBlockInformation($module, $result, $col_fields,$tabid,$block_label,$mode) 1701 { 1702 global $log; 1703 $log->debug("Entering getBlockInformation(".$module.",". $result.",". $col_fields.",".$tabid.",".$block_label.") method ..."); 1704 global $adb; 1705 $editview_arr = Array(); 1706 1707 global $current_user,$mod_strings; 1708 1709 $noofrows = $adb->num_rows($result); 1710 if (($module == 'Accounts' || $module == 'Contacts' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder'|| $module == 'Invoice') && $block == 2) 1711 { 1712 global $log; 1713 $log->info("module is ".$module); 1714 1715 $mvAdd_flag = true; 1716 $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='»' style='padding:0px 2px 0px 2px;font-size:12px'><br><br> 1717 <input title='Copy shipping address to billing address' class='button' onclick='return copyAddressLeft(EditView)' type='button' name='copyleft' value='«' style='padding:0px 2px 0px 2px;font-size:12px'></td>"; 1718 } 1719 1720 1721 for($i=0; $i<$noofrows; $i++) 1722 { 1723 $fieldtablename = $adb->query_result($result,$i,"tablename"); 1724 $fieldcolname = $adb->query_result($result,$i,"columnname"); 1725 $uitype = $adb->query_result($result,$i,"uitype"); 1726 $fieldname = $adb->query_result($result,$i,"fieldname"); 1727 $fieldlabel = $adb->query_result($result,$i,"fieldlabel"); 1728 $block = $adb->query_result($result,$i,"block"); 1729 $maxlength = $adb->query_result($result,$i,"maximumlength"); 1730 $generatedtype = $adb->query_result($result,$i,"generatedtype"); 1731 1732 $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields,$generatedtype,$module,$mode); 1733 $editview_arr[$block][]=$custfld; 1734 if ($mvAdd_flag == true) 1735 $mvAdd_flag = false; 1736 $i++; 1737 if($i<$noofrows) 1738 { 1739 $fieldtablename = $adb->query_result($result,$i,"tablename"); 1740 $fieldcolname = $adb->query_result($result,$i,"columnname"); 1741 $uitype = $adb->query_result($result,$i,"uitype"); 1742 $fieldname = $adb->query_result($result,$i,"fieldname"); 1743 $fieldlabel = $adb->query_result($result,$i,"fieldlabel"); 1744 $block = $adb->query_result($result,$i,"block"); 1745 $maxlength = $adb->query_result($result,$i,"maximumlength"); 1746 $generatedtype = $adb->query_result($result,$i,"generatedtype"); 1747 $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields,$generatedtype,$module,$mode); 1748 $editview_arr[$block][]=$custfld; 1749 } 1750 } 1751 foreach($editview_arr as $headerid=>$editview_value) 1752 { 1753 $editview_data = Array(); 1754 for ($i=0,$j=0;$i<count($editview_value);$i=$i+2,$j++) 1755 { 1756 $key1=$editview_value[$i]; 1757 if(is_array($editview_value[$i+1])) 1758 { 1759 $key2=$editview_value[$i+1]; 1760 } 1761 else 1762 { 1763 $key2 =array(); 1764 } 1765 $editview_data[$j]=array(0 => $key1,1 => $key2); 1766 } 1767 $editview_arr[$headerid] = $editview_data; 1768 } 1769 foreach($block_label as $blockid=>$label) 1770 { 1771 if($label == '') 1772 { 1773 $returndata[$mod_strings[$curBlock]]=array_merge((array)$returndata[$mod_strings[$curBlock]],(array)$editview_arr[$blockid]); 1774 } 1775 else 1776 { 1777 $curBlock = $label; 1778 if(is_array($editview_arr[$blockid])) 1779 $returndata[$mod_strings[$label]]=array_merge((array)$returndata[$mod_strings[$label]],(array)$editview_arr[$blockid]); 1780 } 1781 } 1782 $log->debug("Exiting getBlockInformation method ..."); 1783 return $returndata; 1784 1785 } 1786 1787 /** This function returns the data type of the vtiger_fields, with vtiger_field label, which is used for javascript validation. 1788 * Param $validationData - array of vtiger_fieldnames with datatype 1789 * Return type array 1790 */ 1791 1792 1793 function split_validationdataArray($validationData) 1794 { 1795 global $log; 1796 $log->debug("Entering split_validationdataArray(".$validationData.") method ..."); 1797 $fieldName = ''; 1798 $fieldLabel = ''; 1799 $fldDataType = ''; 1800 $rows = count($validationData); 1801 foreach($validationData as $fldName => $fldLabel_array) 1802 { 1803 if($fieldName == '') 1804 { 1805 $fieldName="'".$fldName."'"; 1806 } 1807 else 1808 { 1809 $fieldName .= ",'".$fldName ."'"; 1810 } 1811 foreach($fldLabel_array as $fldLabel => $datatype) 1812 { 1813 if($fieldLabel == '') 1814 { 1815 $fieldLabel = "'".$fldLabel ."'"; 1816 } 1817 else 1818 { 1819 $fieldLabel .= ",'".$fldLabel ."'"; 1820 } 1821 if($fldDataType == '') 1822 { 1823 $fldDataType = "'".$datatype ."'"; 1824 } 1825 else 1826 { 1827 $fldDataType .= ",'".$datatype ."'"; 1828 } 1829 } 1830 } 1831 $data['fieldname'] = $fieldName; 1832 $data['fieldlabel'] = $fieldLabel; 1833 $data['datatype'] = $fldDataType; 1834 $log->debug("Exiting split_validationdataArray method ..."); 1835 return $data; 1836 } 1837 1838 1839 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |