[ 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$ 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/utils.php'); //new 26 require_once ('include/utils/RecurringType.php'); 27 28 /** 29 * Check if user id belongs to a system admin. 30 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 31 * All Rights Reserved. 32 * Contributor(s): ______________________________________.. 33 */ 34 function is_admin($user) { 35 global $log; 36 $log->debug("Entering is_admin(".$user.") method ..."); 37 38 if ($user->is_admin == 'on') 39 { 40 $log->debug("Exiting is_admin method ..."); 41 return true; 42 } 43 else 44 { 45 $log->debug("Exiting is_admin method ..."); 46 return false; 47 } 48 } 49 50 /** 51 * THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED; USE get_select_options_with_id() 52 * Create HTML to display select options in a dropdown list. To be used inside 53 * of a select statement in a form. 54 * param $option_list - the array of strings to that contains the option list 55 * param $selected - the string which contains the default value 56 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 57 * All Rights Reserved. 58 * Contributor(s): ______________________________________.. 59 */ 60 function get_select_options (&$option_list, $selected, $advsearch='false') { 61 global $log; 62 $log->debug("Entering get_select_options (".$option_list.",".$selected.",".$advsearch.") method ..."); 63 $log->debug("Exiting get_select_options method ..."); 64 return get_select_options_with_id($option_list, $selected, $advsearch); 65 } 66 67 /** 68 * Create HTML to display select options in a dropdown list. To be used inside 69 * of a select statement in a form. This method expects the option list to have keys and values. The keys are the ids. The values is an array of the datas 70 * param $option_list - the array of strings to that contains the option list 71 * param $selected - the string which contains the default value 72 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 73 * All Rights Reserved. 74 * Contributor(s): ______________________________________.. 75 */ 76 function get_select_options_with_id (&$option_list, $selected_key, $advsearch='false') { 77 global $log; 78 $log->debug("Entering get_select_options_with_id (".$option_list.",".$selected_key.",".$advsearch.") method ..."); 79 $log->debug("Exiting get_select_options_with_id method ..."); 80 return get_select_options_with_id_separate_key($option_list, $option_list, $selected_key, $advsearch); 81 } 82 83 /** 84 * Create HTML to display select options in a dropdown list. To be used inside 85 * of a select statement in a form. This method expects the option list to have keys and values. The keys are the ids. 86 * The values are the display strings. 87 */ 88 function get_select_options_array (&$option_list, $selected_key, $advsearch='false') { 89 global $log; 90 $log->debug("Entering get_select_options_array (".$option_list.",".$selected_key.",".$advsearch.") method ..."); 91 $log->debug("Exiting get_select_options_array method ..."); 92 return get_options_array_seperate_key($option_list, $option_list, $selected_key, $advsearch); 93 } 94 95 /** 96 * Create HTML to display select options in a dropdown list. To be used inside 97 * of a select statement in a form. This method expects the option list to have keys and values. The keys are the ids. The value is an array of data 98 * param $label_list - the array of strings to that contains the option list 99 * param $key_list - the array of strings to that contains the values list 100 * param $selected - the string which contains the default value 101 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 102 * All Rights Reserved. 103 * Contributor(s): ______________________________________.. 104 */ 105 function get_options_array_seperate_key (&$label_list, &$key_list, $selected_key, $advsearch='false') { 106 global $log; 107 $log->debug("Entering get_options_array_seperate_key (".$label_list.",".$key_list.",".$selected_key.",".$advsearch.") method ..."); 108 global $app_strings; 109 if($advsearch=='true') 110 $select_options = "\n<OPTION value=''>--NA--</OPTION>"; 111 else 112 $select_options = ""; 113 114 //for setting null selection values to human readable --None-- 115 $pattern = "/'0?'></"; 116 $replacement = "''>".$app_strings['LBL_NONE']."<"; 117 if (!is_array($selected_key)) $selected_key = array($selected_key); 118 119 //create the type dropdown domain and set the selected value if $opp value already exists 120 foreach ($key_list as $option_key=>$option_value) { 121 $selected_string = ''; 122 // the system is evaluating $selected_key == 0 || '' to true. Be very careful when changing this. Test all cases. 123 // The vtiger_reported bug was only happening with one of the vtiger_users in the drop down. It was being replaced by none. 124 if (($option_key != '' && $selected_key == $option_key) || ($selected_key == '' && $option_key == '') || (in_array($option_key, $selected_key))) 125 { 126 $selected_string = 'selected'; 127 } 128 129 $html_value = $option_key; 130 131 $select_options .= "\n<OPTION ".$selected_string."value='$html_value'>$label_list[$option_key]</OPTION>"; 132 $options[$html_value]=array($label_list[$option_key]=>$selected_string); 133 } 134 $select_options = preg_replace($pattern, $replacement, $select_options); 135 136 $log->debug("Exiting get_options_array_seperate_key method ..."); 137 return $options; 138 } 139 140 /** 141 * Create HTML to display select options in a dropdown list. To be used inside 142 * of a select statement in a form. This method expects the option list to have keys and values. The keys are the ids. 143 * The values are the display strings. 144 */ 145 146 function get_select_options_with_id_separate_key(&$label_list, &$key_list, $selected_key, $advsearch='false') 147 { 148 global $log; 149 $log->debug("Entering get_select_options_with_id_separate_key(".$label_list.",".$key_list.",".$selected_key.",".$advsearch.") method ..."); 150 global $app_strings; 151 if($advsearch=='true') 152 $select_options = "\n<OPTION value=''>--NA--</OPTION>"; 153 else 154 $select_options = ""; 155 156 $pattern = "/'0?'></"; 157 $replacement = "''>".$app_strings['LBL_NONE']."<"; 158 if (!is_array($selected_key)) $selected_key = array($selected_key); 159 160 foreach ($key_list as $option_key=>$option_value) { 161 $selected_string = ''; 162 if (($option_key != '' && $selected_key == $option_key) || ($selected_key == '' && $option_key == '') || (in_array($option_key, $selected_key))) 163 { 164 $selected_string = 'selected '; 165 } 166 167 $html_value = $option_key; 168 169 $select_options .= "\n<OPTION ".$selected_string."value='$html_value'>$label_list[$option_key]</OPTION>"; 170 } 171 $select_options = preg_replace($pattern, $replacement, $select_options); 172 $log->debug("Exiting get_select_options_with_id_separate_key method ..."); 173 return $select_options; 174 175 } 176 177 /** 178 * Converts localized date format string to jscalendar format 179 * Example: $array = array_csort($array,'town','age',SORT_DESC,'name'); 180 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 181 * All Rights Reserved. 182 * Contributor(s): ______________________________________.. 183 */ 184 function parse_calendardate($local_format) { 185 global $log; 186 $log->debug("Entering parse_calendardate(".$local_format.") method ..."); 187 global $current_user; 188 if($current_user->date_format == 'dd-mm-yyyy') 189 { 190 $dt_popup_fmt = "%d-%m-%Y"; 191 } 192 elseif($current_user->date_format == 'mm-dd-yyyy') 193 { 194 $dt_popup_fmt = "%m-%d-%Y"; 195 } 196 elseif($current_user->date_format == 'yyyy-mm-dd') 197 { 198 $dt_popup_fmt = "%Y-%m-%d"; 199 } 200 $log->debug("Exiting parse_calendardate method ..."); 201 return $dt_popup_fmt; 202 //return "%Y-%m-%d"; 203 } 204 205 /** 206 * Decodes the given set of special character 207 * input values $string - string to be converted, $encode - flag to decode 208 * returns the decoded value in string fromat 209 */ 210 211 function from_html($string, $encode=true){ 212 global $log; 213 $log->debug("Entering from_html(".$string.",".$encode.") method ..."); 214 global $toHtml; 215 //if($encode && is_string($string))$string = html_entity_decode($string, ENT_QUOTES); 216 if($encode && is_string($string)){ 217 $string = str_replace(array_values($toHtml), array_keys($toHtml), $string); 218 } 219 $log->debug("Exiting from_html method ..."); 220 return $string; 221 } 222 223 /** 224 * Function used to decodes the given single quote and double quote only. This function used for popup selection 225 * @param string $string - string to be converted, $encode - flag to decode 226 * @return string $string - the decoded value in string fromat where as only single and double quotes will be decoded 227 */ 228 229 function popup_from_html($string, $encode=true) 230 { 231 global $log; 232 $log->debug("Entering popup_from_html(".$string.",".$encode.") method ..."); 233 234 $popup_toHtml = array( 235 '"' => '"', 236 "'" => ''', 237 ); 238 239 //if($encode && is_string($string))$string = html_entity_decode($string, ENT_QUOTES); 240 if($encode && is_string($string)) 241 { 242 $string = addslashes(str_replace(array_values($popup_toHtml), array_keys($popup_toHtml), $string)); 243 } 244 245 $log->debug("Exiting popup_from_html method ..."); 246 return $string; 247 } 248 249 250 /** To get the Currency of the specified user 251 * @param $id -- The user Id:: Type integer 252 * @returns vtiger_currencyid :: Type integer 253 */ 254 function fetchCurrency($id) 255 { 256 global $log; 257 $log->debug("Entering fetchCurrency(".$id.") method ..."); 258 global $adb; 259 $sql = "select currency_id from vtiger_users where id=" .$id; 260 $result = $adb->query($sql); 261 $currencyid= $adb->query_result($result,0,"currency_id"); 262 $log->debug("Exiting fetchCurrency method ..."); 263 return $currencyid; 264 } 265 266 /** Function to get the Currency name from the vtiger_currency_info 267 * @param $currencyid -- vtiger_currencyid:: Type integer 268 * @returns $currencyname -- Currency Name:: Type varchar 269 * 270 */ 271 function getCurrencyName($currencyid) 272 { 273 global $log; 274 $log->debug("Entering getCurrencyName(".$currencyid.") method ..."); 275 global $adb; 276 $sql1 = "select * from vtiger_currency_info where id=".$currencyid; 277 $result = $adb->query($sql1); 278 $currencyname = $adb->query_result($result,0,"currency_name"); 279 $curr_symbol = $adb->query_result($result,0,"currency_symbol"); 280 $log->debug("Exiting getCurrencyName method ..."); 281 return $currencyname.' : '.$curr_symbol; 282 } 283 284 285 /** 286 * Function to fetch the list of vtiger_groups from group vtiger_table 287 * Takes no value as input 288 * returns the query result set object 289 */ 290 291 function get_group_options() 292 { 293 global $log; 294 $log->debug("Entering get_group_options() method ..."); 295 global $adb,$noof_group_rows;; 296 $sql = "select groupname,groupid from vtiger_groups"; 297 $result = $adb->query($sql); 298 $noof_group_rows=$adb->num_rows($result); 299 $log->debug("Exiting get_group_options method ..."); 300 return $result; 301 } 302 303 /** 304 * Function to get the tabid 305 * Takes the input as $module - module name 306 * returns the tabid, integer type 307 */ 308 309 function getTabid($module) 310 { 311 global $log; 312 $log->debug("Entering getTabid(".$module.") method ..."); 313 314 if (file_exists('tabdata.php') && (filesize('tabdata.php') != 0)) 315 { 316 include ('tabdata.php'); 317 $tabid= $tab_info_array[$module]; 318 } 319 else 320 { 321 322 $log->info("module is ".$module); 323 global $adb; 324 $sql = "select tabid from vtiger_tab where name='".$module."'"; 325 $result = $adb->query($sql); 326 $tabid= $adb->query_result($result,0,"tabid"); 327 } 328 $log->debug("Exiting getTabid method ..."); 329 return $tabid; 330 331 } 332 333 /** 334 * Function to get the tabid 335 * Takes the input as $module - module name 336 * returns the tabid, integer type 337 */ 338 339 function getSalesEntityType($crmid) 340 { 341 global $log; 342 $log->debug("Entering getSalesEntityType(".$crmid.") method ..."); 343 $log->info("in getSalesEntityType ".$crmid); 344 global $adb; 345 $sql = "select * from vtiger_crmentity where crmid=".$crmid; 346 $result = $adb->query($sql); 347 $parent_module = $adb->query_result($result,0,"setype"); 348 $log->debug("Exiting getSalesEntityType method ..."); 349 return $parent_module; 350 } 351 352 /** 353 * Function to get the AccountName when a vtiger_account id is given 354 * Takes the input as $acount_id - vtiger_account id 355 * returns the vtiger_account name in string format. 356 */ 357 358 function getAccountName($account_id) 359 { 360 global $log; 361 $log->debug("Entering getAccountName(".$account_id.") method ..."); 362 $log->info("in getAccountName ".$account_id); 363 364 global $adb; 365 if($account_id != '') 366 { 367 $sql = "select accountname from vtiger_account where accountid=".$account_id; 368 $result = $adb->query($sql); 369 $accountname = $adb->query_result($result,0,"accountname"); 370 } 371 $log->debug("Exiting getAccountName method ..."); 372 return $accountname; 373 } 374 375 /** 376 * Function to get the ProductName when a product id is given 377 * Takes the input as $product_id - product id 378 * returns the product name in string format. 379 */ 380 381 function getProductName($product_id) 382 { 383 global $log; 384 $log->debug("Entering getProductName(".$product_id.") method ..."); 385 386 $log->info("in getproductname ".$product_id); 387 388 global $adb; 389 $sql = "select productname from vtiger_products where productid=".$product_id; 390 $result = $adb->query($sql); 391 $productname = $adb->query_result($result,0,"productname"); 392 $log->debug("Exiting getProductName method ..."); 393 return $productname; 394 } 395 396 /** 397 * Function to get the Potentail Name when a vtiger_potential id is given 398 * Takes the input as $potential_id - vtiger_potential id 399 * returns the vtiger_potential name in string format. 400 */ 401 402 function getPotentialName($potential_id) 403 { 404 global $log; 405 $log->debug("Entering getPotentialName(".$potential_id.") method ..."); 406 $log->info("in getPotentialName ".$potential_id); 407 408 global $adb; 409 $potentialname = ''; 410 if($potential_id != '') 411 { 412 $sql = "select potentialname from vtiger_potential where potentialid=".$potential_id; 413 $result = $adb->query($sql); 414 $potentialname = $adb->query_result($result,0,"potentialname"); 415 } 416 $log->debug("Exiting getPotentialName method ..."); 417 return $potentialname; 418 } 419 420 /** 421 * Function to get the Contact Name when a contact id is given 422 * Takes the input as $contact_id - contact id 423 * returns the Contact Name in string format. 424 */ 425 426 function getContactName($contact_id) 427 { 428 global $log; 429 $log->debug("Entering getContactName(".$contact_id.") method ..."); 430 $log->info("in getContactName ".$contact_id); 431 432 global $adb; 433 $sql = "select * from vtiger_contactdetails where contactid=".$contact_id; 434 $result = $adb->query($sql); 435 $firstname = $adb->query_result($result,0,"firstname"); 436 $lastname = $adb->query_result($result,0,"lastname"); 437 $contact_name = $lastname.' '.$firstname; 438 $log->debug("Exiting getContactName method ..."); 439 return $contact_name; 440 } 441 442 /** 443 * Function to get the Campaign Name when a campaign id is given 444 * Takes the input as $campaign_id - campaign id 445 * returns the Campaign Name in string format. 446 */ 447 448 function getCampaignName($campaign_id) 449 { 450 global $log; 451 $log->debug("Entering getCampaignName(".$campaign_id.") method ..."); 452 $log->info("in getCampaignName ".$campaign_id); 453 454 global $adb; 455 $sql = "select * from vtiger_campaign where campaignid=".$campaign_id; 456 $result = $adb->query($sql); 457 $campaign_name = $adb->query_result($result,0,"campaignname"); 458 $log->debug("Exiting getCampaignName method ..."); 459 return $campaign_name; 460 } 461 462 463 /** 464 * Function to get the Vendor Name when a vtiger_vendor id is given 465 * Takes the input as $vendor_id - vtiger_vendor id 466 * returns the Vendor Name in string format. 467 */ 468 469 function getVendorName($vendor_id) 470 { 471 global $log; 472 $log->debug("Entering getVendorName(".$vendor_id.") method ..."); 473 $log->info("in getVendorName ".$vendor_id); 474 global $adb; 475 $sql = "select * from vtiger_vendor where vendorid=".$vendor_id; 476 $result = $adb->query($sql); 477 $vendor_name = $adb->query_result($result,0,"vendorname"); 478 $log->debug("Exiting getVendorName method ..."); 479 return $vendor_name; 480 } 481 482 /** 483 * Function to get the Quote Name when a vtiger_vendor id is given 484 * Takes the input as $quote_id - quote id 485 * returns the Quote Name in string format. 486 */ 487 488 function getQuoteName($quote_id) 489 { 490 global $log; 491 $log->debug("Entering getQuoteName(".$quote_id.") method ..."); 492 $log->info("in getQuoteName ".$quote_id); 493 global $adb; 494 if($quote_id != NULL && $quote_id != '') 495 { 496 $sql = "select * from vtiger_quotes where quoteid=".$quote_id; 497 $result = $adb->query($sql); 498 $quote_name = $adb->query_result($result,0,"subject"); 499 } 500 else 501 { 502 $log->debug("Quote Id is empty."); 503 $quote_name = ''; 504 } 505 $log->debug("Exiting getQuoteName method ..."); 506 return $quote_name; 507 } 508 509 /** 510 * Function to get the PriceBook Name when a vtiger_pricebook id is given 511 * Takes the input as $pricebook_id - vtiger_pricebook id 512 * returns the PriceBook Name in string format. 513 */ 514 515 function getPriceBookName($pricebookid) 516 { 517 global $log; 518 $log->debug("Entering getPriceBookName(".$pricebookid.") method ..."); 519 $log->info("in getPriceBookName ".$pricebookid); 520 global $adb; 521 $sql = "select * from vtiger_pricebook where pricebookid=".$pricebookid; 522 $result = $adb->query($sql); 523 $pricebook_name = $adb->query_result($result,0,"bookname"); 524 $log->debug("Exiting getPriceBookName method ..."); 525 return $pricebook_name; 526 } 527 528 /** This Function returns the Purchase Order Name. 529 * The following is the input parameter for the function 530 * $po_id --> Purchase Order Id, Type:Integer 531 */ 532 function getPoName($po_id) 533 { 534 global $log; 535 $log->debug("Entering getPoName(".$po_id.") method ..."); 536 $log->info("in getPoName ".$po_id); 537 global $adb; 538 $sql = "select * from vtiger_purchaseorder where purchaseorderid=".$po_id; 539 $result = $adb->query($sql); 540 $po_name = $adb->query_result($result,0,"subject"); 541 $log->debug("Exiting getPoName method ..."); 542 return $po_name; 543 } 544 /** 545 * Function to get the Sales Order Name when a vtiger_salesorder id is given 546 * Takes the input as $salesorder_id - vtiger_salesorder id 547 * returns the Salesorder Name in string format. 548 */ 549 550 function getSoName($so_id) 551 { 552 global $log; 553 $log->debug("Entering getSoName(".$so_id.") method ..."); 554 $log->info("in getSoName ".$so_id); 555 global $adb; 556 $sql = "select * from vtiger_salesorder where salesorderid=".$so_id; 557 $result = $adb->query($sql); 558 $so_name = $adb->query_result($result,0,"subject"); 559 $log->debug("Exiting getSoName method ..."); 560 return $so_name; 561 } 562 563 /** 564 * Function to get the Group Information for a given groupid 565 * Takes the input $id - group id and $module - module name 566 * returns the group information in an array format. 567 */ 568 569 function getGroupName($id, $module) 570 { 571 global $log; 572 $log->debug("Entering getGroupName(".$id.",".$module.") method ..."); 573 $group_info = Array(); 574 $log->info("in getGroupName, entityid is ".$id.' module is '.$module); 575 global $adb; 576 if($module == 'Leads') 577 { 578 $sql = "select vtiger_leadgrouprelation.groupname,vtiger_groups.groupid from vtiger_leadgrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_leadgrouprelation.groupname where vtiger_leadgrouprelation.leadid=".$id; 579 } 580 elseif($module == 'Accounts') 581 { 582 $sql = "select vtiger_accountgrouprelation.groupname,vtiger_groups.groupid from vtiger_accountgrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_accountgrouprelation.groupname where vtiger_accountgrouprelation.accountid=".$id; 583 } 584 elseif($module == 'Contacts') 585 { 586 $sql = "select vtiger_contactgrouprelation.groupname,vtiger_groups.groupid from vtiger_contactgrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname where vtiger_contactgrouprelation.contactid=".$id; 587 } 588 elseif($module == 'Potentials') 589 { 590 $sql = "select vtiger_potentialgrouprelation.groupname,vtiger_groups.groupid from vtiger_potentialgrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname where vtiger_potentialgrouprelation.potentialid=".$id; 591 } 592 elseif($module == 'Quotes') 593 { 594 $sql = "select vtiger_quotegrouprelation.groupname,vtiger_groups.groupid from vtiger_quotegrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname where vtiger_quotegrouprelation.quoteid=".$id; 595 } 596 elseif($module == 'SalesOrder') 597 { 598 $sql = "select vtiger_sogrouprelation.groupname,vtiger_groups.groupid from vtiger_sogrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_sogrouprelation.salesorderid=".$id; 599 } 600 elseif($module == 'Invoice') 601 { 602 $sql = "select vtiger_invoicegrouprelation.groupname,vtiger_groups.groupid from vtiger_invoicegrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_invoicegrouprelation.groupname where vtiger_invoicegrouprelation.invoiceid=".$id; 603 } 604 elseif($module == 'PurchaseOrder') 605 { 606 $sql = "select vtiger_pogrouprelation.groupname,vtiger_groups.groupid from vtiger_pogrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_pogrouprelation.groupname where vtiger_pogrouprelation.purchaseorderid=".$id; 607 } 608 elseif($module == 'HelpDesk') 609 { 610 $sql = "select vtiger_ticketgrouprelation.groupname,vtiger_groups.groupid from vtiger_ticketgrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_ticketgrouprelation.groupname where vtiger_ticketgrouprelation.ticketid=".$id; 611 } 612 elseif($module == 'Campaigns') 613 { 614 $sql = "select vtiger_campaigngrouprelation.groupname,vtiger_groups.groupid from vtiger_campaigngrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_campaigngrouprelation.groupname where vtiger_campaigngrouprelation.campaignid=".$id; 615 } 616 elseif($module == 'Calendar' || $module == 'Emails' || $module == 'Events') 617 { 618 $sql = "select vtiger_activitygrouprelation.groupname,vtiger_groups.groupid from vtiger_activitygrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_activitygrouprelation.activityid=".$id; 619 } 620 $result = $adb->query($sql); 621 $group_info[] = $adb->query_result($result,0,"groupname"); 622 $group_info[] = $adb->query_result($result,0,"groupid"); 623 $log->debug("Exiting getGroupName method ..."); 624 return $group_info; 625 626 } 627 628 /** 629 * Get the username by giving the user id. This method expects the user id 630 */ 631 632 function getUserName($userid) 633 { 634 global $log; 635 $log->debug("Entering getUserName(".$userid.") method ..."); 636 $log->info("in getUserName ".$userid); 637 638 global $adb; 639 if($userid != '') 640 { 641 $sql = "select user_name from vtiger_users where id=".$userid; 642 $result = $adb->query($sql); 643 $user_name = $adb->query_result($result,0,"user_name"); 644 } 645 $log->debug("Exiting getUserName method ..."); 646 return $user_name; 647 } 648 649 /** 650 * Get the user full name by giving the user id. This method expects the user id 651 * DG 30 Aug 2006 652 */ 653 654 function getUserFullName($userid) 655 { 656 global $log; 657 $log->debug("Entering getUserFullName(".$userid.") method ..."); 658 $log->info("in getUserFullName ".$userid); 659 global $adb; 660 if($userid != '') 661 { 662 $sql = "select first_name, last_name from vtiger_users where id=".$userid; 663 $result = $adb->query($sql); 664 $first_name = $adb->query_result($result,0,"first_name"); 665 $last_name = $adb->query_result($result,0,"last_name"); 666 $user_name = $first_name." ".$last_name; 667 } 668 $log->debug("Exiting getUserFullName method ..."); 669 return $user_name; 670 } 671 672 /** 673 * Creates and returns database query. To be used for search and other text links. This method expects the module object. 674 * param $focus - the module object contains the column vtiger_fields 675 */ 676 677 function getURLstring($focus) 678 { 679 global $log; 680 $log->debug("Entering getURLstring(".$focus.") method ..."); 681 $qry = ""; 682 foreach($focus->column_fields as $fldname=>$val) 683 { 684 if(isset($_REQUEST[$fldname]) && $_REQUEST[$fldname] != '') 685 { 686 if($qry == '') 687 $qry = "&".$fldname."=".$_REQUEST[$fldname]; 688 else 689 $qry .="&".$fldname."=".$_REQUEST[$fldname]; 690 } 691 } 692 if(isset($_REQUEST['current_user_only']) && $_REQUEST['current_user_only'] !='') 693 { 694 $qry .="¤t_user_only=".$_REQUEST['current_user_only']; 695 } 696 if(isset($_REQUEST['advanced']) && $_REQUEST['advanced'] =='true') 697 { 698 $qry .="&advanced=true"; 699 } 700 701 if($qry !='') 702 { 703 $qry .="&query=true"; 704 } 705 $log->debug("Exiting getURLstring method ..."); 706 return $qry; 707 708 } 709 710 /** This function returns the date in user specified format. 711 * param $cur_date_val - the default date format 712 */ 713 714 function getDisplayDate($cur_date_val) 715 { 716 global $log; 717 $log->debug("Entering getDisplayDate(".$cur_date_val.") method ..."); 718 global $current_user; 719 $dat_fmt = $current_user->date_format; 720 if($dat_fmt == '') 721 { 722 $dat_fmt = 'dd-mm-yyyy'; 723 } 724 725 $date_value = explode(' ',$cur_date_val); 726 list($y,$m,$d) = split('-',$date_value[0]); 727 if($dat_fmt == 'dd-mm-yyyy') 728 { 729 $display_date = $d.'-'.$m.'-'.$y; 730 } 731 elseif($dat_fmt == 'mm-dd-yyyy') 732 { 733 734 $display_date = $m.'-'.$d.'-'.$y; 735 } 736 elseif($dat_fmt == 'yyyy-mm-dd') 737 { 738 739 $display_date = $y.'-'.$m.'-'.$d; 740 } 741 742 if($date_value[1] != '') 743 { 744 $display_date = $display_date.' '.$date_value[1]; 745 } 746 $log->debug("Exiting getDisplayDate method ..."); 747 return $display_date; 748 749 } 750 751 /** This function returns the date in user specified format. 752 * Takes no param, receives the date format from current user object 753 */ 754 755 function getNewDisplayDate() 756 { 757 global $log; 758 $log->debug("Entering getNewDisplayDate() method ..."); 759 $log->info("in getNewDisplayDate "); 760 761 global $current_user; 762 $dat_fmt = $current_user->date_format; 763 if($dat_fmt == '') 764 { 765 $dat_fmt = 'dd-mm-yyyy'; 766 } 767 //echo $dat_fmt; 768 //echo '<BR>'; 769 $display_date=''; 770 if($dat_fmt == 'dd-mm-yyyy') 771 { 772 $display_date = date('d-m-Y'); 773 } 774 elseif($dat_fmt == 'mm-dd-yyyy') 775 { 776 $display_date = date('m-d-Y'); 777 } 778 elseif($dat_fmt == 'yyyy-mm-dd') 779 { 780 $display_date = date('Y-m-d'); 781 } 782 783 //echo $display_date; 784 $log->debug("Exiting getNewDisplayDate method ..."); 785 return $display_date; 786 } 787 788 /** This function returns the default vtiger_currency information. 789 * Takes no param, return type array. 790 */ 791 792 function getDisplayCurrency() 793 { 794 global $log; 795 global $adb; 796 $log->debug("Entering getDisplayCurrency() method ..."); 797 $curr_array = Array(); 798 $sql1 = "select * from vtiger_currency_info where currency_status='Active'"; 799 $result = $adb->query($sql1); 800 $num_rows=$adb->num_rows($result); 801 for($i=0; $i<$num_rows;$i++) 802 { 803 $curr_id = $adb->query_result($result,$i,"id"); 804 $curr_name = $adb->query_result($result,$i,"currency_name"); 805 $curr_symbol = $adb->query_result($result,$i,"currency_symbol"); 806 $curr_array[$curr_id] = $curr_name.' : '.$curr_symbol; 807 } 808 $log->debug("Exiting getDisplayCurrency method ..."); 809 return $curr_array; 810 } 811 812 /** This function returns the amount converted to dollar. 813 * param $amount - amount to be converted. 814 * param $crate - conversion rate. 815 */ 816 817 function convertToDollar($amount,$crate){ 818 global $log; 819 $log->debug("Entering convertToDollar(".$amount.",".$crate.") method ..."); 820 $log->debug("Exiting convertToDollar method ..."); 821 return $amount / $crate; 822 } 823 824 /** This function returns the amount converted from dollar. 825 * param $amount - amount to be converted. 826 * param $crate - conversion rate. 827 */ 828 function convertFromDollar($amount,$crate){ 829 global $log; 830 $log->debug("Entering convertFromDollar(".$amount.",".$crate.") method ..."); 831 $log->debug("Exiting convertFromDollar method ..."); 832 return $amount * $crate; 833 } 834 835 /** This function returns the amount converted from master currency. 836 * param $amount - amount to be converted. 837 * param $crate - conversion rate. 838 */ 839 function convertFromMasterCurrency($amount,$crate){ 840 global $log; 841 $log->debug("Entering convertFromDollar(".$amount.",".$crate.") method ..."); 842 $log->debug("Exiting convertFromDollar method ..."); 843 return $amount * $crate; 844 } 845 846 /** This function returns the conversion rate and vtiger_currency symbol 847 * in array format for a given id. 848 * param $id - vtiger_currency id. 849 */ 850 851 function getCurrencySymbolandCRate($id) 852 { 853 global $log; 854 $log->debug("Entering getCurrencySymbolandCRate(".$id.") method ..."); 855 global $adb; 856 $sql1 = "select conversion_rate,currency_symbol from vtiger_currency_info where id=".$id; 857 $result = $adb->query($sql1); 858 $rate_symbol['rate'] = $adb->query_result($result,0,"conversion_rate"); 859 $rate_symbol['symbol'] = $adb->query_result($result,0,"currency_symbol"); 860 $log->debug("Exiting getCurrencySymbolandCRate method ..."); 861 return $rate_symbol; 862 } 863 864 /** This function returns the terms and condition from the database. 865 * Takes no param and the return type is text. 866 */ 867 868 function getTermsandConditions() 869 { 870 global $log; 871 $log->debug("Entering getTermsandConditions() method ..."); 872 global $adb; 873 $sql1 = "select * from vtiger_inventory_tandc"; 874 $result = $adb->query($sql1); 875 $tandc = $adb->query_result($result,0,"tandc"); 876 $log->debug("Exiting getTermsandConditions method ..."); 877 return $tandc; 878 } 879 880 /** 881 * Create select options in a dropdown list. To be used inside 882 * a reminder select statement in a vtiger_activity form. 883 * param $start - start value 884 * param $end - end value 885 * param $fldname - vtiger_field name 886 * param $selvalue - selected value 887 */ 888 889 function getReminderSelectOption($start,$end,$fldname,$selvalue='') 890 { 891 global $log; 892 $log->debug("Entering getReminderSelectOption(".$start.",".$end.",".$fldname.",".$selvalue=''.") method ..."); 893 global $mod_strings; 894 global $app_strings; 895 896 $def_sel =""; 897 $OPTION_FLD = "<SELECT name=".$fldname.">"; 898 for($i=$start;$i<=$end;$i++) 899 { 900 if($i==$selvalue) 901 $def_sel = "SELECTED"; 902 $OPTION_FLD .= "<OPTION VALUE=".$i." ".$def_sel.">".$i."</OPTION>\n"; 903 $def_sel = ""; 904 } 905 $OPTION_FLD .="</SELECT>"; 906 $log->debug("Exiting getReminderSelectOption method ..."); 907 return $OPTION_FLD; 908 } 909 910 /** This function returns the List price of a given product in a given price book. 911 * param $productid - product id. 912 * param $pbid - vtiger_pricebook id. 913 */ 914 915 function getListPrice($productid,$pbid) 916 { 917 global $log; 918 $log->debug("Entering getListPrice(".$productid.",".$pbid.") method ..."); 919 $log->info("in getListPrice productid ".$productid); 920 921 global $adb; 922 $query = "select listprice from vtiger_pricebookproductrel where pricebookid=".$pbid." and productid=".$productid; 923 $result = $adb->query($query); 924 $lp = $adb->query_result($result,0,'listprice'); 925 $log->debug("Exiting getListPrice method ..."); 926 return $lp; 927 } 928 929 /** This function returns a string with removed new line character, single quote, and back slash double quoute. 930 * param $str - string to be converted. 931 */ 932 933 function br2nl($str) { 934 global $log; 935 $log->debug("Entering br2nl(".$str.") method ..."); 936 $str = preg_replace("/(\r\n)/", " ", $str); 937 $str = preg_replace("/'/", " ", $str); 938 $str = preg_replace("/\"/", " ", $str); 939 $log->debug("Exiting br2nl method ..."); 940 return $str; 941 } 942 943 /** This function returns a text, which escapes the html encode for link tag/ a href tag 944 *param $text - string/text 945 */ 946 947 function make_clickable($text) 948 { 949 global $log; 950 $log->debug("Entering make_clickable(".$text.") method ..."); 951 $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); 952 // pad it with a space so we can match things at the start of the 1st line. 953 $ret = ' ' . $text; 954 955 // matches an "xxxx://yyyy" URL at the start of a line, or after a space. 956 // xxxx can only be alpha characters. 957 // yyyy is anything up to the first space, newline, comma, double quote or < 958 $ret = preg_replace("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret); 959 960 // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing 961 // Must contain at least 2 dots. xxxx contains either alphanum, or "-" 962 // zzzz is optional.. will contain everything up to the first space, newline, 963 // comma, double quote or <. 964 $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret); 965 966 // matches an email@domain type address at the start of a line, or after a space. 967 // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".". 968 $ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret); 969 970 // Remove our padding.. 971 $ret = substr($ret, 1); 972 973 //remove comma, fullstop at the end of url 974 $ret = preg_replace("#,\"|\.\"|\)\"|\)\.\"|\.\)\"#", "\"", $ret); 975 976 $log->debug("Exiting make_clickable method ..."); 977 return($ret); 978 } 979 /** 980 * This function returns the vtiger_blocks and its related information for given module. 981 * Input Parameter are $module - module name, $disp_view = display view (edit,detail or create),$mode - edit, $col_fields - * column vtiger_fields/ 982 * This function returns an array 983 */ 984 985 function getBlocks($module,$disp_view,$mode,$col_fields='',$info_type='') 986 { 987 global $log; 988 $log->debug("Entering getBlocks(".$module.",".$disp_view.",".$mode.",".$col_fields.",".$info_type.") method ..."); 989 global $adb,$current_user; 990 global $mod_strings; 991 $tabid = getTabid($module); 992 $block_detail = Array(); 993 $getBlockinfo = ""; 994 $query="select blockid,blocklabel,show_title from vtiger_blocks where tabid=$tabid and $disp_view=0 and visible = 0 order by sequence"; 995 996 $result = $adb->query($query); 997 $noofrows = $adb->num_rows($result); 998 $prev_header = ""; 999 $blockid_list ='('; 1000 for($i=0; $i<$noofrows; $i++) 1001 { 1002 $blockid = $adb->query_result($result,$i,"blockid"); 1003 if($i != 0) 1004 $blockid_list .= ', '; 1005 $blockid_list .= $blockid; 1006 $block_label[$blockid] = $adb->query_result($result,$i,"blocklabel"); 1007 } 1008 $blockid_list .= ')'; 1009 if($mode == 'edit') 1010 { 1011 $display_type_check = 'vtiger_field.displaytype = 1'; 1012 }else 1013 { 1014 $display_type_check = 'vtiger_field.displaytype in (1,4)'; 1015 } 1016 //retreive the vtiger_profileList from database 1017 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 1018 if($disp_view == "detail_view") 1019 { 1020 if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == "Users") 1021 { 1022 $sql = "SELECT vtiger_field.* FROM vtiger_field WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN $blockid_list AND vtiger_field.displaytype IN (1,2,4) ORDER BY block,sequence"; 1023 } 1024 else 1025 { 1026 $profileList = getCurrentUserProfileList(); 1027 $sql = "SELECT vtiger_field.* FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN ".$blockid_list." AND vtiger_field.displaytype IN (1,2,4) AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN ".$profileList." GROUP BY vtiger_field.fieldid ORDER BY block,sequence"; 1028 //Postgres 8 fixes 1029 if( $adb->dbType == "pgsql") 1030 $sql = fixPostgresQuery( $sql, $log, 0); 1031 } 1032 $result = $adb->query($sql); 1033 $getBlockInfo=getDetailBlockInformation($module,$result,$col_fields,$tabid,$block_label); 1034 } 1035 else 1036 { 1037 if ($info_type != '') 1038 { 1039 if($is_admin==true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2]== 0 || $module == 'Users') 1040 { 1041 $sql = "SELECT vtiger_field.* FROM vtiger_field WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN ".$blockid_list ." AND ".$display_type_check." AND info_type = '".$info_type."' ORDER BY block,sequence"; 1042 } 1043 else 1044 { 1045 $profileList = getCurrentUserProfileList(); 1046 $sql = "SELECT vtiger_field.* FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN ".$blockid_list." AND ".$display_type_check." AND info_type = '".$info_type."' AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN ".$profileList.=" GROUP BY vtiger_field.fieldid ORDER BY block,sequence"; 1047 //Postgres 8 fixes 1048 if( $adb->dbType == "pgsql") 1049 $sql = fixPostgresQuery( $sql, $log, 0); 1050 } 1051 } 1052 else 1053 { 1054 if($is_admin==true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == 'Users') 1055 { 1056 $sql = "SELECT vtiger_field.* FROM vtiger_field WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN ".$blockid_list." AND ".$display_type_check." ORDER BY block,sequence"; 1057 } 1058 else 1059 { 1060 $profileList = getCurrentUserProfileList(); 1061 $sql = "SELECT vtiger_field.* FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN ".$blockid_list." AND ".$display_type_check." AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN ".$profileList.=" GROUP BY vtiger_field.fieldid ORDER BY block,sequence"; 1062 //Postgres 8 fixes 1063 if( $adb->dbType == "pgsql") 1064 $sql = fixPostgresQuery( $sql, $log, 0); 1065 } 1066 } 1067 $result = $adb->query($sql); 1068 $getBlockInfo=getBlockInformation($module,$result,$col_fields,$tabid,$block_label,$mode); 1069 } 1070 $log->debug("Exiting getBlocks method ..."); 1071 $index_count =1; 1072 $max_index =0; 1073 foreach($getBlockInfo as $label=>$contents) 1074 { 1075 $no_rows = count($contents); 1076 $index_count = $max_index+1; 1077 foreach($contents as $block_row => $elements) 1078 { 1079 $max_index= $no_rows+$index_count; 1080 1081 for($i=0;$i<count($elements);$i++) 1082 { 1083 if(sizeof($getBlockInfo[$label][$block_row][$i])!=0) 1084 { 1085 if($i==0) 1086 $getBlockInfo[$label][$block_row][$i][]=array($index_count); 1087 else 1088 $getBlockInfo[$label][$block_row][$i][]=array($max_index); 1089 } 1090 } 1091 $index_count++; 1092 1093 } 1094 } 1095 return $getBlockInfo; 1096 } 1097 /** 1098 * This function is used to get the display type. 1099 * Takes the input parameter as $mode - edit (mostly) 1100 * This returns string type value 1101 */ 1102 1103 function getView($mode) 1104 { 1105 global $log; 1106 $log->debug("Entering getView(".$mode.") method ..."); 1107 if($mode=="edit") 1108 $disp_view = "edit_view"; 1109 else 1110 $disp_view = "create_view"; 1111 $log->debug("Exiting getView method ..."); 1112 return $disp_view; 1113 } 1114 /** 1115 * This function is used to get the blockid of the customblock for a given module. 1116 * Takes the input parameter as $tabid - module tabid and $label - custom label 1117 * This returns string type value 1118 */ 1119 1120 function getBlockId($tabid,$label) 1121 { 1122 global $log; 1123 $log->debug("Entering getBlockId(".$tabid.",".$label.") method ..."); 1124 global $adb; 1125 $blockid = ''; 1126 $query = "select blockid from vtiger_blocks where tabid=$tabid and blocklabel = '$label'"; 1127 $result = $adb->query($query); 1128 $noofrows = $adb->num_rows($result); 1129 if($noofrows == 1) 1130 { 1131 $blockid = $adb->query_result($result,0,"blockid"); 1132 } 1133 $log->debug("Exiting getBlockId method ..."); 1134 return $blockid; 1135 } 1136 1137 /** 1138 * This function is used to get the Parent and Child vtiger_tab relation array. 1139 * Takes no parameter and get the data from parent_tabdata.php and vtiger_tabdata.php 1140 * This returns array type value 1141 */ 1142 1143 function getHeaderArray() 1144 { 1145 global $log; 1146 $log->debug("Entering getHeaderArray() method ..."); 1147 global $adb; 1148 global $current_user; 1149 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 1150 include ('parent_tabdata.php'); 1151 include ('tabdata.php'); 1152 $noofrows = count($parent_tab_info_array); 1153 foreach($parent_tab_info_array as $parid=>$parval) 1154 { 1155 $subtabs = Array(); 1156 $tablist=$parent_child_tab_rel_array[$parid]; 1157 $noofsubtabs = count($tablist); 1158 1159 foreach($tablist as $childTabId) 1160 { 1161 $module = array_search($childTabId,$tab_info_array); 1162 1163 if($is_admin) 1164 { 1165 $subtabs[] = $module; 1166 } 1167 elseif($profileGlobalPermission[2]==0 ||$profileGlobalPermission[1]==0 || $profileTabsPermission[$childTabId]==0) 1168 { 1169 $subtabs[] = $module; 1170 } 1171 } 1172 1173 $parenttab = getParentTabName($parid); 1174 if($parenttab == 'Settings' && $is_admin) 1175 { 1176 $subtabs[] = 'Settings'; 1177 } 1178 1179 if($parenttab != 'Settings' ||($parenttab == 'Settings' && $is_admin)) 1180 { 1181 if(!empty($subtabs)) 1182 $relatedtabs[$parenttab] = $subtabs; 1183 } 1184 } 1185 $log->debug("Exiting getHeaderArray method ..."); 1186 return $relatedtabs; 1187 } 1188 1189 /** 1190 * This function is used to get the Parent Tab name for a given parent vtiger_tab id. 1191 * Takes the input parameter as $parenttabid - Parent vtiger_tab id 1192 * This returns value string type 1193 */ 1194 1195 function getParentTabName($parenttabid) 1196 { 1197 global $log; 1198 $log->debug("Entering getParentTabName(".$parenttabid.") method ..."); 1199 global $adb; 1200 if (file_exists('parent_tabdata.php') && (filesize('parent_tabdata.php') != 0)) 1201 { 1202 include ('parent_tabdata.php'); 1203 $parent_tabname= $parent_tab_info_array[$parenttabid]; 1204 } 1205 else 1206 { 1207 $sql = "select parenttab_label from vtiger_parenttab where parenttabid=".$parenttabid; 1208 $result = $adb->query($sql); 1209 $parent_tabname= $adb->query_result($result,0,"parenttab_label"); 1210 } 1211 $log->debug("Exiting getParentTabName method ..."); 1212 return $parent_tabname; 1213 } 1214 1215 /** 1216 * This function is used to get the Parent Tab name for a given module. 1217 * Takes the input parameter as $module - module name 1218 * This returns value string type 1219 */ 1220 1221 1222 function getParentTabFromModule($module) 1223 { 1224 global $log; 1225 $log->debug("Entering getParentTabFromModule(".$module.") method ..."); 1226 global $adb; 1227 if (file_exists('tabdata.php') && (filesize('tabdata.php') != 0) && file_exists('parent_tabdata.php') && (filesize('parent_tabdata.php') != 0)) 1228 { 1229 include ('tabdata.php'); 1230 include ('parent_tabdata.php'); 1231 $tabid=$tab_info_array[$module]; 1232 foreach($parent_child_tab_rel_array as $parid=>$childArr) 1233 { 1234 if(in_array($tabid,$childArr)) 1235 { 1236 $parent_tabname= $parent_tab_info_array[$parid]; 1237 } 1238 } 1239 $log->debug("Exiting getParentTabFromModule method ..."); 1240 return $parent_tabname; 1241 } 1242 else 1243 { 1244 $sql = "select vtiger_parenttab.* from vtiger_parenttab inner join vtiger_parenttabrel on vtiger_parenttabrel.parenttabid=vtiger_parenttab.parenttabid inner join vtiger_tab on vtiger_tab.tabid=vtiger_parenttabrel.tabid where vtiger_tab.name='".$module."'"; 1245 $result = $adb->query($sql); 1246 $tab = $adb->query_result($result,0,"parenttab_label"); 1247 $log->debug("Exiting getParentTabFromModule method ..."); 1248 return $tab; 1249 } 1250 } 1251 1252 /** 1253 * This function is used to get the Parent Tab name for a given module. 1254 * Takes no parameter but gets the vtiger_parenttab value from form request 1255 * This returns value string type 1256 */ 1257 1258 function getParentTab() 1259 { 1260 global $log; 1261 $log->debug("Entering getParentTab() method ..."); 1262 if(isset($_REQUEST['parenttab']) && $_REQUEST['parenttab'] !='') 1263 { 1264 $log->debug("Exiting getParentTab method ..."); 1265 return $_REQUEST['parenttab']; 1266 } 1267 else 1268 { 1269 $log->debug("Exiting getParentTab method ..."); 1270 return getParentTabFromModule($_REQUEST['module']); 1271 } 1272 1273 } 1274 /** 1275 * This function is used to get the days in between the current time and the modified time of an entity . 1276 * Takes the input parameter as $id - crmid it will calculate the number of days in between the 1277 * the current time and the modified time from the vtiger_crmentity vtiger_table and return the result as a string. 1278 * The return format is updated <No of Days> day ago <(date when updated)> 1279 */ 1280 1281 function updateInfo($id) 1282 { 1283 global $log; 1284 $log->debug("Entering updateInfo(".$id.") method ..."); 1285 1286 global $adb; 1287 global $app_strings; 1288 $query='select modifiedtime from vtiger_crmentity where crmid ='.$id ; 1289 $result = $adb->query($query); 1290 $modifiedtime = $adb->query_result($result,0,'modifiedtime'); 1291 $values=explode(' ',$modifiedtime); 1292 $date_info=explode('-',$values[0]); 1293 $time_info=explode(':',$values[1]); 1294 $date = $date_info[2].' '.$app_strings[date("M", mktime(0, 0, 0, $date_info[1], $date_info[2],$date_info[0]))].' '.$date_info[0]; 1295 $time_modified = mktime($time_info[0], $time_info[1], $time_info[2], $date_info[1], $date_info[2],$date_info[0]); 1296 $time_now = time(); 1297 $days_diff = (int)(($time_now - $time_modified) / (60 * 60 * 24)); 1298 if($days_diff == 0) 1299 $update_info = $app_strings['LBL_UPDATED_TODAY']." (".$date.")"; 1300 elseif($days_diff == 1) 1301 $update_info = $app_strings['LBL_UPDATED']." ".$days_diff." ".$app_strings['LBL_DAY_AGO']." (".$date.")"; 1302 else 1303 $update_info = $app_strings['LBL_UPDATED']." ".$days_diff." ".$app_strings['LBL_DAYS_AGO']." (".$date.")"; 1304 1305 $log->debug("Exiting updateInfo method ..."); 1306 return $update_info; 1307 } 1308 1309 1310 /** 1311 * This function is used to get the Product Images for the given Product . 1312 * It accepts the product id as argument and returns the Images with the script for 1313 * rotating the product Images 1314 */ 1315 1316 function getProductImages($id) 1317 { 1318 global $log; 1319 $log->debug("Entering getProductImages(".$id.") method ..."); 1320 global $adb; 1321 $image_lists=array(); 1322 $script_images=array(); 1323 $script = '<script>var ProductImages = new Array('; 1324 $i=0; 1325 $query='select imagename from vtiger_products where productid='.$id; 1326 $result = $adb->query($query); 1327 $imagename=$adb->query_result($result,0,'imagename'); 1328 $image_lists=explode('###',$imagename); 1329 for($i=0;$i<count($image_lists);$i++) 1330 { 1331 $script_images[] = '"'.$image_lists[$i].'"'; 1332 } 1333 $script .=implode(',',$script_images).');</script>'; 1334 if($imagename != '') 1335 { 1336 $log->debug("Exiting getProductImages method ..."); 1337 return $script; 1338 } 1339 } 1340 1341 /** 1342 * This function is used to save the Images . 1343 * It acceps the File lists,modulename,id and the mode as arguments 1344 * It returns the array details of the upload 1345 */ 1346 1347 function SaveImage($_FILES,$module,$id,$mode) 1348 { 1349 global $log; 1350 $log->debug("Entering SaveImage(".$_FILES.",".$module.",".$id.",".$mode.") method ..."); 1351 global $adb; 1352 $uploaddir = $root_directory."test/".$module."/" ;//set this to which location you need to give the contact image 1353 $log->info("The Location to Save the Contact Image is ".$uploaddir); 1354 $file_path_name = $_FILES['imagename']['name']; 1355 $image_error="false"; 1356 $saveimage="true"; 1357 $file_name = basename($file_path_name); 1358 if($file_name!="") 1359 { 1360 1361 $log->debug("Contact Image is given for uploading"); 1362 $image_name_val=file_exist_fn($file_name,0); 1363 1364 $encode_field_values=""; 1365 $errormessage=""; 1366 1367 $move_upload_status=move_uploaded_file($_FILES["imagename"]["tmp_name"],$uploaddir.$image_name_val); 1368 $image_error="false"; 1369 1370 //if there is an error in the uploading of image 1371 1372 $filetype= $_FILES['imagename']['type']; 1373 $filesize = $_FILES['imagename']['size']; 1374 1375 $filetype_array=explode("/",$filetype); 1376 1377 $file_type_val_image=strtolower($filetype_array[0]); 1378 $file_type_val=strtolower($filetype_array[1]); 1379 $log->info("The File type of the Contact Image is :: ".$file_type_val); 1380 //checking the uploaded image is if an image type or not 1381 if(!$move_upload_status) //if any error during file uploading 1382 { 1383 $log->debug("Error is present in uploading Contact Image."); 1384 $errorCode = $_FILES['imagename']['error']; 1385 if($errorCode == 4) 1386 { 1387 $errorcode="no-image"; 1388 $saveimage="false"; 1389 $image_error="true"; 1390 } 1391 else if($errorCode == 2) 1392 { 1393 $errormessage = 2; 1394 $saveimage="false"; 1395 $image_error="true"; 1396 } 1397 else if($errorCode == 3 ) 1398 { 1399 $errormessage = 3; 1400 $saveimage="false"; 1401 $image_error="true"; 1402 } 1403 } 1404 else 1405 { 1406 $log->debug("Successfully uploaded the Contact Image."); 1407 if($filesize != 0) 1408 { 1409 if (($file_type_val == "jpeg" ) || ($file_type_val == "png") || ($file_type_val == "jpg" ) || ($file_type_val == "pjpeg" ) || ($file_type_val == "x-png") || ($file_type_val == "gif") ) //Checking whether the file is an image or not 1410 { 1411 $saveimage="true"; 1412 $image_error="false"; 1413 } 1414 else 1415 { 1416 $savelogo="false"; 1417 $image_error="true"; 1418 $errormessage = "image"; 1419 } 1420 } 1421 else 1422 { 1423 $savelogo="false"; 1424 $image_error="true"; 1425 $errormessage = "invalid"; 1426 } 1427 1428 } 1429 } 1430 else //if image is not given 1431 { 1432 $log->debug("Contact Image is not given for uploading."); 1433 if($mode=="edit" && $image_error=="false" ) 1434 { 1435 if($module='contact') 1436 $image_name_val=getContactImageName($id); 1437 elseif($module='user') 1438 $image_name_val=getUserImageName($id); 1439 $saveimage="true"; 1440 } 1441 else 1442 { 1443 $image_name_val=""; 1444 } 1445 } 1446 $return_value=array('imagename'=>$image_name_val, 1447 'imageerror'=>$image_error, 1448 'errormessage'=>$errormessage, 1449 'saveimage'=>$saveimage, 1450 'mode'=>$mode); 1451 $log->debug("Exiting SaveImage method ..."); 1452 return $return_value; 1453 } 1454 1455 /** 1456 * This function is used to generate file name if more than one image with same name is added to a given Product. 1457 * Param $filename - product file name 1458 * Param $exist - number time the file name is repeated. 1459 */ 1460 1461 function file_exist_fn($filename,$exist) 1462 { 1463 global $log; 1464 $log->debug("Entering file_exist_fn(".$filename.",".$exist.") method ..."); 1465 global $uploaddir; 1466 1467 if(!isset($exist)) 1468 { 1469 $exist=0; 1470 } 1471 $filename_path=$uploaddir.$filename; 1472 if (file_exists($filename_path)) //Checking if the file name already exists in the directory 1473 { 1474 if($exist!=0) 1475 { 1476 $previous=$exist-1; 1477 $next=$exist+1; 1478 $explode_name=explode("_",$filename); 1479 $implode_array=array(); 1480 for($j=0;$j<count($explode_name); $j++) 1481 { 1482 if($j!=0) 1483 { 1484 $implode_array[]=$explode_name[$j]; 1485 } 1486 } 1487 $implode_name=implode("_", $implode_array); 1488 $test_name=$implode_name; 1489 } 1490 else 1491 { 1492 $implode_name=$filename; 1493 } 1494 $exist++; 1495 $filename_val=$exist."_".$implode_name; 1496 $testfilename = file_exist_fn($filename_val,$exist); 1497 if($testfilename!="") 1498 { 1499 $log->debug("Exiting file_exist_fn method ..."); 1500 return $testfilename; 1501 } 1502 } 1503 else 1504 { 1505 $log->debug("Exiting file_exist_fn method ..."); 1506 return $filename; 1507 } 1508 } 1509 1510 /** 1511 * This function is used get the User Count. 1512 * It returns the array which has the total vtiger_users ,admin vtiger_users,and the non admin vtiger_users 1513 */ 1514 1515 function UserCount() 1516 { 1517 global $log; 1518 $log->debug("Entering UserCount() method ..."); 1519 global $adb; 1520 $result=$adb->query("select * from vtiger_users where deleted =0;"); 1521 $user_count=$adb->num_rows($result); 1522 $result=$adb->query("select * from vtiger_users where deleted =0 AND is_admin != 'on';"); 1523 $nonadmin_count = $adb->num_rows($result); 1524 $admin_count = $user_count-$nonadmin_count; 1525 $count=array('user'=>$user_count,'admin'=>$admin_count,'nonadmin'=>$nonadmin_count); 1526 $log->debug("Exiting UserCount method ..."); 1527 return $count; 1528 } 1529 1530 /** 1531 * This function is used to create folders recursively. 1532 * Param $dir - directory name 1533 * Param $mode - directory access mode 1534 * Param $recursive - create directory recursive, default true 1535 */ 1536 1537 function mkdirs($dir, $mode = 0777, $recursive = true) 1538 { 1539 global $log; 1540 $log->debug("Entering mkdirs(".$dir.",".$mode.",".$recursive.") method ..."); 1541 if( is_null($dir) || $dir === "" ){ 1542 $log->debug("Exiting mkdirs method ..."); 1543 return FALSE; 1544 } 1545 if( is_dir($dir) || $dir === "/" ){ 1546 $log->debug("Exiting mkdirs method ..."); 1547 return TRUE; 1548 } 1549 if( mkdirs(dirname($dir), $mode, $recursive) ){ 1550 $log->debug("Exiting mkdirs method ..."); 1551 return mkdir($dir, $mode); 1552 } 1553 $log->debug("Exiting mkdirs method ..."); 1554 return FALSE; 1555 } 1556 1557 /**This function returns the module name which has been set as default home view for a given user. 1558 * Takes no parameter, but uses the user object $current_user. 1559 */ 1560 function DefHomeView() 1561 { 1562 global $log; 1563 $log->debug("Entering DefHomeView() method ..."); 1564 global $adb; 1565 global $current_user; 1566 $query="select defhomeview from vtiger_users where id = ".$current_user->id; 1567 $result=$adb->query($query); 1568 $defaultview=$adb->query_result($result,0,'defhomeview'); 1569 $log->debug("Exiting DefHomeView method ..."); 1570 return $defaultview; 1571 1572 } 1573 1574 1575 /** 1576 * This function is used to set the Object values from the REQUEST values. 1577 * @param object reference $focus - reference of the object 1578 */ 1579 function setObjectValuesFromRequest($focus) 1580 { 1581 global $log; 1582 $log->debug("Entering setObjectValuesFromRequest(".$focus.") method ..."); 1583 global $current_user; 1584 $currencyid=fetchCurrency($current_user->id); 1585 $rate_symbol = getCurrencySymbolandCRate($currencyid); 1586 $rate = $rate_symbol['rate']; 1587 if(isset($_REQUEST['record'])) 1588 { 1589 $focus->id = $_REQUEST['record']; 1590 } 1591 if(isset($_REQUEST['mode'])) 1592 { 1593 $focus->mode = $_REQUEST['mode']; 1594 } 1595 foreach($focus->column_fields as $fieldname => $val) 1596 { 1597 if(isset($_REQUEST[$fieldname])) 1598 { 1599 $value = $_REQUEST[$fieldname]; 1600 $focus->column_fields[$fieldname] = $value; 1601 } 1602 if(isset($_REQUEST['txtTax'])) 1603 { 1604 $value = convertToDollar($_REQUEST['txtTax'],$rate); 1605 $focus->column_fields['txtTax'] = $value; 1606 } 1607 if(isset($_REQUEST['txtAdjustment'])) 1608 { 1609 $value = convertToDollar($_REQUEST['txtAdjustment'],$rate); 1610 $focus->column_fields['txtAdjustment'] = $value; 1611 } 1612 if(isset($_REQUEST['hdnSubTotal'])) 1613 { 1614 $value = convertToDollar($_REQUEST['hdnSubTotal'],$rate); 1615 $focus->column_fields['hdnSubTotal'] = $value; 1616 } 1617 if(isset($_REQUEST['hdnGrandTotal'])) 1618 { 1619 $value = convertToDollar($_REQUEST['hdnGrandTotal'],$rate); 1620 $focus->column_fields['hdnGrandTotal'] = $value; 1621 } 1622 1623 } 1624 $log->debug("Exiting setObjectValuesFromRequest method ..."); 1625 } 1626 1627 /** 1628 * Function to write the tabid and name to a flat file vtiger_tabdata.txt so that the data 1629 * is obtained from the file instead of repeated queries 1630 * returns null 1631 */ 1632 1633 function create_tab_data_file() 1634 { 1635 global $log; 1636 $log->debug("Entering create_tab_data_file() method ..."); 1637 $log->info("creating vtiger_tabdata file"); 1638 global $adb; 1639 $sql = "select * from vtiger_tab"; 1640 $result = $adb->query($sql); 1641 $num_rows=$adb->num_rows($result); 1642 $result_array=Array(); 1643 $seq_array=Array(); 1644 for($i=0;$i<$num_rows;$i++) 1645 { 1646 $tabid=$adb->query_result($result,$i,'tabid'); 1647 $tabname=$adb->query_result($result,$i,'name'); 1648 $presence=$adb->query_result($result,$i,'presence'); 1649 $result_array[$tabname]=$tabid; 1650 $seq_array[$tabid]=$presence; 1651 1652 } 1653 1654 //Constructing the actionname=>actionid array 1655 $actionid_array=Array(); 1656 $sql1="select * from vtiger_actionmapping"; 1657 $result1=$adb->query($sql1); 1658 $num_seq1=$adb->num_rows($result1); 1659 for($i=0;$i<$num_seq1;$i++) 1660 { 1661 $actionname=$adb->query_result($result1,$i,'actionname'); 1662 $actionid=$adb->query_result($result1,$i,'actionid'); 1663 $actionid_array[$actionname]=$actionid; 1664 } 1665 1666 //Constructing the actionid=>actionname array with securitycheck=0 1667 $actionname_array=Array(); 1668 $sql2="select * from vtiger_actionmapping where securitycheck=0"; 1669 $result2=$adb->query($sql2); 1670 $num_seq2=$adb->num_rows($result2); 1671 for($i=0;$i<$num_seq2;$i++) 1672 { 1673 $actionname=$adb->query_result($result2,$i,'actionname'); 1674 $actionid=$adb->query_result($result2,$i,'actionid'); 1675 $actionname_array[$actionid]=$actionname; 1676 } 1677 1678 $filename = 'tabdata.php'; 1679 1680 1681 if (file_exists($filename)) { 1682 1683 if (is_writable($filename)) 1684 { 1685 1686 if (!$handle = fopen($filename, 'w+')) { 1687 echo "Cannot open file ($filename)"; 1688 exit; 1689 } 1690 require_once ('modules/Users/CreateUserPrivilegeFile.php'); 1691 $newbuf=''; 1692 $newbuf .="<?php\n\n"; 1693 $newbuf .="\n"; 1694 $newbuf .= "//This file contains the commonly used variables \n"; 1695 $newbuf .= "\n"; 1696 $newbuf .= "\$tab_info_array=".constructArray($result_array).";\n"; 1697 $newbuf .= "\n"; 1698 $newbuf .= "\$tab_seq_array=".constructArray($seq_array).";\n"; 1699 $newbuf .= "\n"; 1700 $newbuf .= "\$action_id_array=".constructSingleStringKeyAndValueArray($actionid_array).";\n"; 1701 $newbuf .= "\n"; 1702 $newbuf .= "\$action_name_array=".constructSingleStringValueArray($actionname_array).";\n"; 1703 $newbuf .= "?>"; 1704 fputs($handle, $newbuf); 1705 fclose($handle); 1706 1707 } 1708 else 1709 { 1710 echo "The file $filename is not writable"; 1711 } 1712 1713 } 1714 else 1715 { 1716 echo "The file $filename does not exist"; 1717 $log->debug("Exiting create_tab_data_file method ..."); 1718 return; 1719 } 1720 } 1721 1722 1723 /** 1724 * Function to write the vtiger_parenttabid and name to a flat file parent_tabdata.txt so that the data 1725 * is obtained from the file instead of repeated queries 1726 * returns null 1727 */ 1728 1729 function create_parenttab_data_file() 1730 { 1731 global $log; 1732 $log->debug("Entering create_parenttab_data_file() method ..."); 1733 $log->info("creating parent_tabdata file"); 1734 global $adb; 1735 $sql = "select parenttabid,parenttab_label from vtiger_parenttab order by sequence"; 1736 $result = $adb->query($sql); 1737 $num_rows=$adb->num_rows($result); 1738 $result_array=Array(); 1739 for($i=0;$i<$num_rows;$i++) 1740 { 1741 $parenttabid=$adb->query_result($result,$i,'parenttabid'); 1742 $parenttab_label=$adb->query_result($result,$i,'parenttab_label'); 1743 $result_array[$parenttabid]=$parenttab_label; 1744 1745 } 1746 1747 $filename = 'parent_tabdata.php'; 1748 1749 1750 if (file_exists($filename)) { 1751 1752 if (is_writable($filename)) 1753 { 1754 1755 if (!$handle = fopen($filename, 'w+')) 1756 { 1757 echo "Cannot open file ($filename)"; 1758 exit; 1759 } 1760 require_once ('modules/Users/CreateUserPrivilegeFile.php'); 1761 $newbuf=''; 1762 $newbuf .="<?php\n\n"; 1763 $newbuf .="\n"; 1764 $newbuf .= "//This file contains the commonly used variables \n"; 1765 $newbuf .= "\n"; 1766 $newbuf .= "\$parent_tab_info_array=".constructSingleStringValueArray($result_array).";\n"; 1767 $newbuf .="\n"; 1768 1769 1770 $parChildTabRelArray=Array(); 1771 1772 foreach($result_array as $parid=>$parvalue) 1773 { 1774 $childArray=Array(); 1775 $sql = "select * from vtiger_parenttabrel where parenttabid=".$parid." order by sequence"; 1776 $result = $adb->query($sql); 1777 $num_rows=$adb->num_rows($result); 1778 $result_array=Array(); 1779 for($i=0;$i<$num_rows;$i++) 1780 { 1781 $tabid=$adb->query_result($result,$i,'tabid'); 1782 $childArray[]=$tabid; 1783 } 1784 $parChildTabRelArray[$parid]=$childArray; 1785 1786 } 1787 $newbuf .= "\n"; 1788 $newbuf .= "\$parent_child_tab_rel_array=".constructTwoDimensionalValueArray($parChildTabRelArray).";\n"; 1789 $newbuf .="\n"; 1790 $newbuf .="\n"; 1791 $newbuf .="\n"; 1792 $newbuf .= "?>"; 1793 fputs($handle, $newbuf); 1794 fclose($handle); 1795 1796 } 1797 else 1798 { 1799 echo "The file $filename is not writable"; 1800 } 1801 1802 } 1803 else 1804 { 1805 echo "The file $filename does not exist"; 1806 $log->debug("Exiting create_parenttab_data_file method ..."); 1807 return; 1808 } 1809 } 1810 1811 /** 1812 * This function is used to get the all the modules that have Quick Create Feature. 1813 * Returns Tab Name and Tablabel. 1814 */ 1815 1816 function getQuickCreateModules() 1817 { 1818 global $log; 1819 $log->debug("Entering getQuickCreateModules() method ..."); 1820 global $adb; 1821 global $mod_strings; 1822 1823 1824 $new_label=Array('Leads'=>'LNK_NEW_LEAD', 1825 'Accounts'=>'LNK_NEW_ACCOUNT', 1826 'Calendar'=>'LNK_NEW_TASK', 1827 'Campaigns'=>'LNK_NEW_CAMPAIGN', 1828 'Emails'=>'LNK_NEW_EMAIL', 1829 'Events'=>'LNK_NEW_EVENT', 1830 'HelpDesk'=>'LNK_NEW_HDESK', 1831 'Notes'=>'LNK_NEW_NOTE', 1832 'Potentials'=>'LNK_NEW_OPPORTUNITY', 1833 'PriceBooks'=>'LNK_NEW_PRICEBOOK', 1834 'Products'=>'LNK_NEW_PRODUCT', 1835 'Contacts'=>'LNK_NEW_CONTACT', 1836 'Vendors'=>'LNK_NEW_VENDOR'); 1837 1838 $qc_query = "select distinct vtiger_tab.tablabel,vtiger_tab.name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where quickcreate=0 order by vtiger_tab.tablabel"; 1839 $result = $adb->query($qc_query); 1840 $noofrows = $adb->num_rows($result); 1841 $return_qcmodule = Array(); 1842 for($i = 0; $i < $noofrows; $i++) 1843 { 1844 $tablabel = $adb->query_result($result,$i,'tablabel'); 1845 1846 $tabname = $adb->query_result($result,$i,'name'); 1847 $tablabel = $new_label[$tabname]; 1848 if(isPermitted($tabname,'EditView','') == 'yes') 1849 { 1850 $return_qcmodule[] = $tablabel; 1851 $return_qcmodule[] = $tabname; 1852 } 1853 } 1854 if(sizeof($return_qcmodule >0)) 1855 { 1856 $return_qcmodule = array_chunk($return_qcmodule,2); 1857 } 1858 1859 $log->debug("Exiting getQuickCreateModules method ..."); 1860 return $return_qcmodule; 1861 } 1862 1863 /** 1864 * This function is used to get the Quick create form vtiger_field parameters for a given module. 1865 * Param $module - module name 1866 * returns the value in array format 1867 */ 1868 1869 1870 function QuickCreate($module) 1871 { 1872 global $log; 1873 $log->debug("Entering QuickCreate(".$module.") method ..."); 1874 global $adb; 1875 global $current_user; 1876 global $mod_strings; 1877 1878 $tabid = getTabid($module); 1879 1880 //Adding Security Check 1881 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 1882 if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) 1883 { 1884 $quickcreate_query = "select * from vtiger_field where quickcreate=0 and tabid = ".$tabid." order by quickcreatesequence"; 1885 } 1886 else 1887 { 1888 $profileList = getCurrentUserProfileList(); 1889 $quickcreate_query = "SELECT vtiger_field.* FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=".$tabid." AND quickcreate=0 AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN ".$profileList." ORDER BY quickcreatesequence"; 1890 //Postgres 8 fixes 1891 if( $adb->dbType == "pgsql") 1892 $quickcreate_query = fixPostgresQuery( $quickcreate_query, $log, 0); 1893 } 1894 1895 $category = getParentTab(); 1896 $result = $adb->query($quickcreate_query); 1897 $noofrows = $adb->num_rows($result); 1898 $fieldName_array = Array(); 1899 for($i=0; $i<$noofrows; $i++) 1900 { 1901 $fieldtablename = $adb->query_result($result,$i,'tablename'); 1902 $uitype = $adb->query_result($result,$i,"uitype"); 1903 $fieldname = $adb->query_result($result,$i,"fieldname"); 1904 $fieldlabel = $adb->query_result($result,$i,"fieldlabel"); 1905 $maxlength = $adb->query_result($result,$i,"maximumlength"); 1906 $generatedtype = $adb->query_result($result,$i,"generatedtype"); 1907 $typeofdata = $adb->query_result($result,$i,"typeofdata"); 1908 1909 //to get validationdata 1910 $fldLabel_array = Array(); 1911 $fldLabel_array[$fieldlabel] = $typeofdata; 1912 $fieldName_array[$fieldname] = $fldLabel_array; 1913 $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields,$generatedtype,$module); 1914 $qcreate_arr[]=$custfld; 1915 } 1916 for ($i=0,$j=0;$i<count($qcreate_arr);$i=$i+2,$j++) 1917 { 1918 $key1=$qcreate_arr[$i]; 1919 if(is_array($qcreate_arr[$i+1])) 1920 { 1921 $key2=$qcreate_arr[$i+1]; 1922 } 1923 else 1924 { 1925 $key2 =array(); 1926 } 1927 $return_data[$j]=array(0 => $key1,1 => $key2); 1928 } 1929 $form_data['form'] = $return_data; 1930 $form_data['data'] = $fieldName_array; 1931 $log->debug("Exiting QuickCreate method ..."); 1932 return $form_data; 1933 } 1934 1935 /** Function to send the Notification mail to the assigned to owner about the entity creation or updation 1936 * @param string $module -- module name 1937 * @param object $focus -- reference of the object 1938 **/ 1939 function sendNotificationToOwner($module,$focus) 1940 { 1941 global $log; 1942 $log->debug("Entering sendNotificationToOwner(".$module.",".$focus.") method ..."); 1943 require_once ("modules/Emails/mail.php"); 1944 global $current_user; 1945 1946 $ownername = getUserName($focus->column_fields['assigned_user_id']); 1947 $ownermailid = getUserEmailId('id',$focus->column_fields['assigned_user_id']); 1948 1949 if($module == 'Contacts') 1950 { 1951 $objectname = $focus->column_fields['lastname'].' '.$focus->column_fields['firstname']; 1952 $mod_name = 'Contact'; 1953 $object_column_fields = array( 1954 'lastname'=>'Last Name', 1955 'firstname'=>'First Name', 1956 'leadsource'=>'Lead Source', 1957 'department'=>'Department', 1958 'description'=>'Description', 1959 ); 1960 } 1961 if($module == 'Accounts') 1962 { 1963 $objectname = $focus->column_fields['accountname']; 1964 $mod_name = 'Account'; 1965 $object_column_fields = array( 1966 'accountname'=>'Account Name', 1967 'rating'=>'Rating', 1968 'industry'=>'Industry', 1969 'accounttype'=>'Account Type', 1970 'description'=>'Description', 1971 ); 1972 } 1973 if($module == 'Potentials') 1974 { 1975 $objectname = $focus->column_fields['potentialname']; 1976 $mod_name = 'Potential'; 1977 $object_column_fields = array( 1978 'potentialname'=>'Potential Name', 1979 'amount'=>'Amount', 1980 'closingdate'=>'Expected Close Date', 1981 'opportunity_type'=>'Opportunity Type', 1982 'description'=>'Description', 1983 ); 1984 } 1985 1986 $description = 'Dear '.$ownername.',<br><br>'; 1987 1988 if($focus->mode == 'edit') 1989 { 1990 $subject = 'Regarding '.$mod_name.' updation - '.$objectname; 1991 $description .= 'The '.$mod_name.' has been updated.'; 1992 } 1993 else 1994 { 1995 $subject = 'Regarding '.$mod_name.' assignment - '.$objectname; 1996 $description .= 'The '.$mod_name.' has been assigned to you.'; 1997 } 1998 $description .= '<br>The '.$mod_name.' details are:<br><br>'; 1999 $description .= $mod_name.' Id : '.$focus->id.'<br>'; 2000 2001 foreach($object_column_fields as $fieldname => $fieldlabel) 2002 { 2003 //Get the translated string 2004 $temp_label = isset($app_strings[$fieldlabel])?$app_strings[$fieldlabel]:(isset($mod_strings[$fieldlabel])?$mod_strings[$fieldlabel]:$fieldlabel); 2005 2006 $description .= $temp_label.' : <b>'.$focus->column_fields[$fieldname].'</b><br>'; 2007 } 2008 2009 $description .= '<br><br>Thank You <br>'; 2010 $status = send_mail($module,$ownermailid,$current_user->user_name,'',$subject,$description); 2011 2012 $log->debug("Exiting sendNotificationToOwner method ..."); 2013 return $status; 2014 } 2015 function getUserslist() 2016 { 2017 global $log; 2018 $log->debug("Entering getUserslist() method ..."); 2019 global $adb; 2020 $result=$adb->query("select * from vtiger_users"); 2021 for($i=0;$i<$adb->num_rows($result);$i++) 2022 { 2023 $useridlist[$i]=$adb->query_result($result,$i,'id'); 2024 $usernamelist[$useridlist[$i]]=$adb->query_result($result,$i,'user_name'); 2025 } 2026 $change_owner = get_select_options_with_id($usernamelist,'admin'); 2027 $log->debug("Exiting getUserslist method ..."); 2028 return $change_owner; 2029 } 2030 2031 2032 function getGroupslist() 2033 { 2034 global $log; 2035 $log->debug("Entering getGroupslist() method ..."); 2036 global $adb; 2037 $result=$adb->query("select * from vtiger_groups"); 2038 2039 for($i=0;$i<$adb->num_rows($result);$i++) 2040 { 2041 $groupidlist[$i]=$adb->query_result($result,$i,'groupid'); 2042 $groupnamelist[$groupidlist[$i]]=$adb->query_result($result,$i,'groupname'); 2043 2044 } 2045 $change_groups_owner = get_select_options_with_id($groupnamelist,''); 2046 $log->debug("Exiting getGroupslist method ..."); 2047 2048 return $change_groups_owner; 2049 } 2050 2051 2052 /** 2053 * Function to Check for Security whether the Buttons are permitted in List/Edit/Detail View of all Modules 2054 * @param string $module -- module name 2055 * Returns an array with permission as Yes or No 2056 **/ 2057 function Button_Check($module) 2058 { 2059 global $log; 2060 $log->debug("Entering Button_Check(".$module.") method ..."); 2061 $permit_arr = array ('EditView' => '', 2062 'index' => '', 2063 'Import' => '', 2064 'Export' => '' ); 2065 2066 foreach($permit_arr as $action => $perr) 2067 { 2068 $tempPer=isPermitted($module,$action,''); 2069 $permit_arr[$action] = $tempPer; 2070 } 2071 $permit_arr["Calendar"] = isPermitted("Calendar","index",''); 2072 2073 $log->debug("Exiting Button_Check method ..."); 2074 return $permit_arr; 2075 2076 } 2077 2078 /** 2079 * Function to Check whether the User is allowed to delete a particular record from listview of each module using 2080 * mass delete button. 2081 * @param string $module -- module name 2082 * @param array $ids_list -- Record id 2083 * Returns the Record Names of each module that is not permitted to delete 2084 **/ 2085 function getEntityName($module, $ids_list) 2086 { 2087 $list = implode(",",$ids_list); 2088 global $adb; 2089 global $log; 2090 $log->debug("Entering getEntityName(".$module.") method ..."); 2091 2092 if($module != '') 2093 { 2094 $query = "select fieldname,tablename,entityidfield from vtiger_entityname where modulename = '$module'"; 2095 $result = $adb->query($query); 2096 $fieldsname = $adb->query_result($result,0,'fieldname'); 2097 $tablename = $adb->query_result($result,0,'tablename'); 2098 $entityidfield = $adb->query_result($result,0,'entityidfield'); 2099 if(!(strpos($fieldsname,',') === false)) 2100 { 2101 $fieldlists = explode(',',$fieldsname); 2102 $fieldsname = "concat("; 2103 $fieldsname = $fieldsname.implode(",' ',",$fieldlists); 2104 $fieldsname = $fieldsname.")"; 2105 } 2106 $query1 = "select $fieldsname as entityname from $tablename where $entityidfield in (".$list.")"; 2107 $result = $adb->query($query1); 2108 $numrows = $adb->num_rows($result); 2109 $account_name = array(); 2110 for ($i = 0; $i < $numrows; $i++) 2111 { 2112 $entity_id = $ids_list[$i]; 2113 $entity_info[$entity_id] = $adb->query_result($result,$i,'entityname'); 2114 } 2115 return $entity_info; 2116 } 2117 $log->debug("Exiting getEntityName method ..."); 2118 } 2119 2120 /**Function to get all permitted modules for a user with their parent 2121 */ 2122 2123 function getAllParenttabmoduleslist() 2124 { 2125 global $adb; 2126 global $current_user; 2127 $resultant_array = Array(); 2128 $query = 'select name,tablabel,parenttab_label,vtiger_tab.tabid from vtiger_parenttabrel inner join vtiger_tab on vtiger_parenttabrel.tabid = vtiger_tab.tabid inner join vtiger_parenttab on vtiger_parenttabrel.parenttabid = vtiger_parenttab.parenttabid order by vtiger_parenttab.sequence, vtiger_parenttabrel.sequence'; 2129 $result = $adb->query($query); 2130 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 2131 for($i=0;$i<$adb->num_rows($result);$i++) 2132 { 2133 $parenttabname = $adb->query_result($result,$i,'parenttab_label'); 2134 $modulename = $adb->query_result($result,$i,'name'); 2135 $tablabel = $adb->query_result($result,$i,'tablabel'); 2136 $tabid = $adb->query_result($result,$i,'tabid'); 2137 if($is_admin) 2138 { 2139 $resultant_array[$parenttabname][] = Array($modulename,$tablabel); 2140 } 2141 elseif($profileGlobalPermission[2]==0 || $profileGlobalPermission[1]==0 || $profileTabsPermission[$tabid]==0) { 2142 $resultant_array[$parenttabname][] = Array($modulename,$tablabel); 2143 } 2144 } 2145 2146 if($is_admin) 2147 { 2148 $resultant_array['Settings'][] = Array('Settings','Settings'); 2149 } 2150 2151 return $resultant_array; 2152 } 2153 2154 /** 2155 * This function is used to decide the File Storage Path in where we will upload the file in the server. 2156 * return string $filepath - filepath inwhere the file should be stored in the server will be return 2157 */ 2158 function decideFilePath() 2159 { 2160 global $log, $adb; 2161 $log->debug("Entering into decideFilePath() method ..."); 2162 2163 $filepath = 'storage/'; 2164 2165 $year = date('Y'); 2166 $month = date('F'); 2167 $day = date('j'); 2168 $week = ''; 2169 2170 if(!is_dir($filepath.$year)) 2171 { 2172 //create new folder 2173 mkdir($filepath.$year); 2174 } 2175 2176 if(!is_dir($filepath.$year."/".$month)) 2177 { 2178 //create new folder 2179 mkdir($filepath."$year/$month"); 2180 } 2181 2182 if($day > 0 && $day <= 7) 2183 $week = 'week1'; 2184 elseif($day > 7 && $day <= 14) 2185 $week = 'week2'; 2186 elseif($day > 14 && $day <= 21) 2187 $week = 'week3'; 2188 elseif($day > 21 && $day <= 28 ) 2189 $week = 'week4'; 2190 else 2191 $week = 'week5'; 2192 2193 if(!is_dir($filepath.$year."/".$month."/".$week)) 2194 { 2195 //create new folder 2196 mkdir($filepath."$year/$month/$week"); 2197 } 2198 2199 $filepath = $filepath.$year."/".$month."/".$week."/"; 2200 2201 $log->debug("Year=$year & Month=$month & week=$week && filepath=\"$filepath\""); 2202 $log->debug("Exiting from decideFilePath() method ..."); 2203 2204 return $filepath; 2205 } 2206 2207 /** 2208 * This function is used to get the Path in where we store the vtiger_files based on the module. 2209 * @param string $module - module name 2210 * return string $storage_path - path inwhere the file will be uploaded (also where it was stored) will be return based on the module 2211 */ 2212 function getModuleFileStoragePath($module) 2213 { 2214 global $log; 2215 $log->debug("Entering into getModuleFileStoragePath($module) method ..."); 2216 2217 $storage_path = "test/"; 2218 2219 if($module == 'Products') 2220 { 2221 $storage_path .= 'product/'; 2222 } 2223 if($module == 'Contacts') 2224 { 2225 $storage_path .= 'contact/'; 2226 } 2227 2228 $log->debug("Exiting from getModuleFileStoragePath($module) method. return storage_path = \"$storage_path\""); 2229 return $storage_path; 2230 } 2231 2232 /** 2233 * This function is used to check whether the attached file is a image file or not 2234 * @param string $file_details - vtiger_files array which contains all the uploaded file details 2235 * return string $save_image - true or false. if the image can be uploaded then true will return otherwise false. 2236 */ 2237 function validateImageFile($file_details) 2238 { 2239 global $adb, $log; 2240 $log->debug("Entering into validateImageFile($file_details) method."); 2241 2242 $savefile = 'true'; 2243 $file_type_details = explode("/",$file_details['type']); 2244 $filetype = $file_type_details['1']; 2245 2246 if (($filetype == "jpeg" ) || ($filetype == "png") || ($filetype == "jpg" ) || ($filetype == "pjpeg" ) || ($filetype == "x-png") || ($filetype == "gif") ) 2247 { 2248 $saveimage = 'true'; 2249 } 2250 else 2251 { 2252 $saveimage = 'false'; 2253 $_SESSION['image_type_error'] .= "<br> <b>$file_details[name]</b> is not uploaded. Allowed file types - jpeg, png, jpg, pjpeg, x-png or gif."; 2254 $log->debug("Invalid Image type == $filetype"); 2255 } 2256 2257 $log->debug("Exiting from validateImageFile($file_details) method. return saveimage=$saveimage"); 2258 return $saveimage; 2259 } 2260 2261 /** 2262 * This function is used to get the Email Template Details like subject and content for particular template. 2263 * @param integer $templateid - Template Id for an Email Template 2264 * return array $returndata - Returns Subject, Body of Template of the the particular email template. 2265 */ 2266 2267 function getTemplateDetails($templateid) 2268 { 2269 global $adb,$log; 2270 $log->debug("Entering into getTemplateDetails($templateid) method ..."); 2271 $returndata = Array(); 2272 $result = $adb->query("select * from vtiger_emailtemplates where templateid=$templateid"); 2273 $returndata[] = $templateid; 2274 $returndata[] = $adb->query_result($result,0,'body'); 2275 $returndata[] = $adb->query_result($result,0,'subject'); 2276 $log->debug("Exiting from getTemplateDetails($templateid) method ..."); 2277 return $returndata; 2278 } 2279 /** 2280 * This function is used to merge the Template Details with the email description 2281 * @param string $description -body of the mail(ie template) 2282 * @param integer $tid - Id of the entity 2283 * @param string $parent_type - module of the entity 2284 * return string $description - Returns description, merged with the input template. 2285 */ 2286 2287 function getMergedDescription($description,$id,$parent_type) 2288 { 2289 global $adb,$log; 2290 $log->debug("Entering getMergedDescription ..."); 2291 $token_data_pair = explode('$',$description); 2292 $fields = Array(); 2293 for($i=1;$i < count($token_data_pair);$i+=2) 2294 { 2295 2296 $module = explode('-',$token_data_pair[$i]); 2297 $fields[$module[0]][] = $module[1]; 2298 2299 } 2300 //replace the tokens with the values for the selected parent 2301 switch($parent_type) 2302 { 2303 case 'Accounts': 2304 if(is_array($fields["accounts"])) 2305 { 2306 $columnfields = implode(',',$fields["accounts"]); 2307 $query = 'select '.$columnfields.' from vtiger_account where accountid ='.$id; 2308 $result = $adb->query($query); 2309 foreach($fields["accounts"] as $columnname) 2310 { 2311 $token_data = '$accounts-'.$columnname.'$'; 2312 $description = str_replace($token_data,$adb->query_result($result,0,$columnname),$description); 2313 } 2314 } 2315 break; 2316 case 'Contacts': 2317 if(is_array($fields["contacts"])) 2318 { 2319 //Checking for salutation type and checking the table column to be queried 2320 $key = array_search('salutationtype',$fields["contacts"]); 2321 if(isset($key) && $key !='') 2322 { 2323 $fields["contacts"][$key]='salutation'; 2324 } 2325 2326 $columnfields = implode(',',$fields["contacts"]); 2327 $query = 'select '.$columnfields.' from vtiger_contactdetails where contactid='.$id; 2328 $result = $adb->query($query); 2329 foreach($fields["contacts"] as $columnname) 2330 { 2331 $token_data = '$contacts-'.$columnname.'$'; 2332 $description = str_replace($token_data,$adb->query_result($result,0,$columnname),$description); 2333 } 2334 } 2335 break; 2336 case 'Leads': 2337 if(is_array($fields["leads"])) 2338 { 2339 //Checking for salutation type and checking the table column to be queried 2340 $key = array_search('salutationtype',$fields["contacts"]); 2341 if(isset($key) && $key !='') 2342 { 2343 $fields["contacts"][$key]='salutation'; 2344 } 2345 $columnfields = implode(',',$fields["leads"]); 2346 $query = 'select '.$columnfields.' from vtiger_leaddetails where leadid='.$id; 2347 $result = $adb->query($query); 2348 foreach($fields["leads"] as $columnname) 2349 { 2350 $token_data = '$leads-'.$columnname.'$'; 2351 $description = str_replace($token_data,$adb->query_result($result,0,$columnname),$description); 2352 } 2353 } 2354 break; 2355 case 'Users': 2356 if(is_array($fields["users"])) 2357 { 2358 $columnfields = implode(',',$fields["users"]); 2359 $query = 'select '.$columnfields.' from vtiger_users where id='.$id; 2360 $result = $adb->query($query); 2361 foreach($fields["users"] as $columnname) 2362 { 2363 $token_data = '$users-'.$columnname.'$'; 2364 $description = str_replace($token_data,$adb->query_result($result,0,$columnname),$description); 2365 } 2366 } 2367 break; 2368 } 2369 //replace the unwanted tokens by null 2370 $token_data_pair = explode('$',$description); 2371 for($i=1;$i < count($token_data_pair);$i+=2) 2372 { 2373 $token_data = '$'.$token_data_pair[$i].'$'; 2374 $description = str_replace($token_data,'',$description); 2375 } 2376 $log->debug("Exiting from getMergedDescription ..."); 2377 return $description; 2378 } 2379 2380 /** Function used to retrieve a single field value from database 2381 * @param string $tablename - tablename from which we will retrieve the field value 2382 * @param string $fieldname - fieldname to which we want to get the value from database 2383 * @param string $idname - idname which is the name of the entity id in the table like, inoviceid, quoteid, etc., 2384 * @param int $id - entity id 2385 * return string $fieldval - field value of the needed fieldname from database will be returned 2386 */ 2387 function getSingleFieldValue($tablename, $fieldname, $idname, $id) 2388 { 2389 global $log, $adb; 2390 $log->debug("Entering into function getSingleFieldValue($tablename, $fieldname, $idname, $id)"); 2391 2392 $fieldval = $adb->query_result($adb->query("select $fieldname from $tablename where $idname = $id"),0,$fieldname); 2393 2394 $log->debug("Exit from function getSingleFieldValue. return value ==> \"$fieldval\""); 2395 2396 return $fieldval; 2397 } 2398 2399 /** Function used to retrieve the announcements from database 2400 * The function accepts no argument and returns the announcements 2401 * return string $announcement - List of announments for the CRM users 2402 */ 2403 2404 function get_announcements() 2405 { 2406 global $adb; 2407 $sql="select * from vtiger_announcement order by time"; 2408 $result=$adb->query($sql); 2409 for($i=0;$i<$adb->num_rows($result);$i++) 2410 { 2411 $announce = getUserName($adb->query_result($result,$i,'creatorid')).' : '.$adb->query_result($result,$i,'announcement').' '; 2412 if($adb->query_result($result,$i,'announcement')!='') 2413 $announcement.=$announce; 2414 } 2415 return $announcement; 2416 } 2417 2418 /** Function used to retrieve the rate converted into dollar tobe saved into database 2419 * The function accepts the price in the current currency 2420 * return integer $conv_price - 2421 */ 2422 function getConvertedPrice($price) 2423 { 2424 global $current_user; 2425 $currencyid=fetchCurrency($current_user->id); 2426 $rate_symbol = getCurrencySymbolandCRate($currencyid); 2427 $conv_price = convertToDollar($price,$rate_symbol['rate']); 2428 return $conv_price; 2429 } 2430 2431 2432 /** Function used to get the converted amount from dollar which will be showed to the user 2433 * @param float $price - amount in dollor which we want to convert to the user configured amount 2434 * @return float $conv_price - amount in user configured currency 2435 */ 2436 function getConvertedPriceFromDollar($price) 2437 { 2438 global $current_user; 2439 $currencyid=fetchCurrency($current_user->id); 2440 $rate_symbol = getCurrencySymbolandCRate($currencyid); 2441 $conv_price = convertFromDollar($price,$rate_symbol['rate']); 2442 return $conv_price; 2443 } 2444 2445 2446 /** 2447 * Function to get recurring info depending on the recurring type 2448 * return $recurObj - Object of class RecurringType 2449 */ 2450 2451 function getrecurringObjValue() 2452 { 2453 $recurring_data = array(); 2454 if(isset($_REQUEST['recurringtype']) && $_REQUEST['recurringtype'] != null && $_REQUEST['recurringtype'] != '--None--' ) 2455 { 2456 if(isset($_REQUEST['date_start']) && $_REQUEST['date_start'] != null) 2457 { 2458 $recurring_data['startdate'] = $_REQUEST['date_start']; 2459 } 2460 if(isset($_REQUEST['due_date']) && $_REQUEST['due_date'] != null) 2461 { 2462 $recurring_data['enddate'] = $_REQUEST['due_date']; 2463 } 2464 $recurring_data['type'] = $_REQUEST['recurringtype']; 2465 if($_REQUEST['recurringtype'] == 'Weekly') 2466 { 2467 if(isset($_REQUEST['sun_flag']) && $_REQUEST['sun_flag'] != null) 2468 $recurring_data['sun_flag'] = true; 2469 if(isset($_REQUEST['mon_flag']) && $_REQUEST['mon_flag'] != null) 2470 $recurring_data['mon_flag'] = true; 2471 if(isset($_REQUEST['tue_flag']) && $_REQUEST['tue_flag'] != null) 2472 $recurring_data['tue_flag'] = true; 2473 if(isset($_REQUEST['wed_flag']) && $_REQUEST['wed_flag'] != null) 2474 $recurring_data['wed_flag'] = true; 2475 if(isset($_REQUEST['thu_flag']) && $_REQUEST['thu_flag'] != null) 2476 $recurring_data['thu_flag'] = true; 2477 if(isset($_REQUEST['fri_flag']) && $_REQUEST['fri_flag'] != null) 2478 $recurring_data['fri_flag'] = true; 2479 if(isset($_REQUEST['sat_flag']) && $_REQUEST['sat_flag'] != null) 2480 $recurring_data['sat_flag'] = true; 2481 } 2482 elseif($_REQUEST['recurringtype'] == 'Monthly') 2483 { 2484 if(isset($_REQUEST['repeatMonth']) && $_REQUEST['repeatMonth'] != null) 2485 $recurring_data['repeatmonth_type'] = $_REQUEST['repeatMonth']; 2486 if($recurring_data['repeatmonth_type'] == 'date') 2487 { 2488 if(isset($_REQUEST['repeatMonth_date']) && $_REQUEST['repeatMonth_date'] != null) 2489 $recurring_data['repeatmonth_date'] = $_REQUEST['repeatMonth_date']; 2490 else 2491 $recurring_data['repeatmonth_date'] = 1; 2492 } 2493 elseif($recurring_data['repeatmonth_type'] == 'day') 2494 { 2495 $recurring_data['repeatmonth_daytype'] = $_REQUEST['repeatMonth_daytype']; 2496 switch($_REQUEST['repeatMonth_day']) 2497 { 2498 case 0 : 2499 $recurring_data['sun_flag'] = true; 2500 break; 2501 case 1 : 2502 $recurring_data['mon_flag'] = true; 2503 break; 2504 case 2 : 2505 $recurring_data['tue_flag'] = true; 2506 break; 2507 case 3 : 2508 $recurring_data['wed_flag'] = true; 2509 break; 2510 case 4 : 2511 $recurring_data['thu_flag'] = true; 2512 break; 2513 case 5 : 2514 $recurring_data['fri_flag'] = true; 2515 break; 2516 case 6 : 2517 $recurring_data['sat_flag'] = true; 2518 break; 2519 } 2520 } 2521 } 2522 if(isset($_REQUEST['repeat_frequency']) && $_REQUEST['repeat_frequency'] != null) 2523 $recurring_data['repeat_frequency'] = $_REQUEST['repeat_frequency']; 2524 //echo '<pre>';print_r($recurring_data);echo '</pre>';die; 2525 $recurObj = new RecurringType($recurring_data); 2526 //echo '<pre>';print_r($recurObj);echo '</pre>';die; 2527 return $recurObj; 2528 } 2529 2530 } 2531 ?>
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 |