[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 ********************************************************************************/ 11 12 13 require_once ('include/utils/UserInfoUtil.php'); 14 require_once ("include/utils/utils.php"); 15 require_once ("include/ListView/ListViewSession.php"); 16 17 /** Function to get related list entries in detailed array format 18 * @param $module -- modulename:: Type string 19 * @param $relatedmodule -- relatedmodule:: Type string 20 * @param $focus -- focus:: Type object 21 * @param $query -- query:: Type string 22 * @param $button -- buttons:: Type string 23 * @param $returnset -- returnset:: Type string 24 * @param $id -- id:: Type string 25 * @param $edit_val -- edit value:: Type string 26 * @param $del_val -- delete value:: Type string 27 * @returns $related_entries -- related entires:: Type string array 28 * 29 */ 30 31 function GetRelatedList($module,$relatedmodule,$focus,$query,$button,$returnset,$id='',$edit_val='',$del_val='') 32 { 33 $log = LoggerManager::getLogger('account_list'); 34 $log->debug("Entering GetRelatedList(".$module.",".$relatedmodule.",".$focus.",".$query.",".$button.",".$returnset.",".$edit_val.",".$del_val.") method ..."); 35 36 require_once ('Smarty_setup.php'); 37 require_once ("data/Tracker.php"); 38 require_once ('include/database/PearDatabase.php'); 39 40 global $adb; 41 global $app_strings; 42 global $current_language; 43 44 $current_module_strings = return_module_language($current_language, $module); 45 46 global $list_max_entries_per_page; 47 global $urlPrefix; 48 49 50 global $currentModule; 51 global $theme; 52 global $theme_path; 53 global $theme_path; 54 global $mod_strings; 55 // focus_list is the means of passing data to a ListView. 56 global $focus_list; 57 $smarty = new vtigerCRM_Smarty; 58 if (!isset($where)) $where = ""; 59 60 61 $button = '<table cellspacing=0 cellpadding=2><tr><td>'.$button.'</td></tr></table>'; 62 63 // Added to have Purchase Order as form Title 64 if($relatedmodule == 'Orders') 65 { 66 $smarty->assign('ADDBUTTON',get_form_header($app_strings['PurchaseOrder'],$button, false)); 67 } 68 else 69 { 70 $smarty->assign('ADDBUTTON',get_form_header($app_strings[$relatedmodule],$button, false)); 71 } 72 73 require_once('themes/'.$theme.'/layout_utils.php'); 74 $theme_path="themes/".$theme."/"; 75 $image_path=$theme_path."images/"; 76 $smarty->assign("MOD", $mod_strings); 77 $smarty->assign("APP", $app_strings); 78 $smarty->assign("IMAGE_PATH",$image_path); 79 $smarty->assign("MODULE",$relatedmodule); 80 81 82 //Retreive the list from Database 83 //$query = getListQuery("Accounts"); 84 85 //echo '<BR>*****************'.$relatedmodule.' ***************'; 86 //Appending the security parameter 87 if($relatedmodule != 'Notes' && $relatedmodule != 'Products' && $relatedmodule != 'Faq' && $relatedmodule != 'PriceBook' && $relatedmodule != 'Vendors') //Security fix by Don 88 { 89 global $current_user; 90 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 91 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 92 $tab_id=getTabid($relatedmodule); 93 if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) 94 { 95 $sec_parameter=getListViewSecurityParameter($relatedmodule); 96 $query .= ' '.$sec_parameter; 97 98 } 99 } 100 101 102 if(isset($where) && $where != '') 103 { 104 $query .= ' and '.$where; 105 } 106 107 if(!$_SESSION['rlvs'][$module][$relatedmodule]) 108 { 109 $modObj = new ListViewSession(); 110 $modObj->sortby = $focus->default_order_by; 111 $modObj->sorder = $focus->default_sort_order; 112 $_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj); 113 } 114 if(isset($_REQUEST['relmodule']) && ($_REQUEST['relmodule'] == $relatedmodule)) 115 { 116 if(method_exists($focus,getSortOrder)) 117 $sorder = $focus->getSortOrder(); 118 if(method_exists($focus,getOrderBy)) 119 $order_by = $focus->getOrderBy(); 120 121 if(isset($order_by) && $order_by != '') 122 { 123 $_SESSION['rlvs'][$module][$relatedmodule]['sorder'] = $sorder; 124 $_SESSION['rlvs'][$module][$relatedmodule]['sortby'] = $order_by; 125 } 126 127 } 128 elseif($_SESSION['rlvs'][$module][$relatedmodule]) 129 { 130 $sorder = $_SESSION['rlvs'][$module][$relatedmodule]['sorder']; 131 $order_by = $_SESSION['rlvs'][$module][$relatedmodule]['sortby']; 132 } 133 else 134 { 135 $order_by = $focus->default_order_by; 136 $sorder = $focus->default_sort_order; 137 } 138 139 $query .= ' ORDER BY '.$order_by.' '.$sorder; 140 $url_qry .="&order_by=".$order_by; 141 //Added for PHP version less than 5 142 if (!function_exists("stripos")) 143 { 144 function stripos($query,$needle) 145 { 146 return strpos(strtolower($query),strtolower($needle)); 147 } 148 } 149 150 //Retreiving the no of rows 151 $count_query = "select count(*) as count ".substr($query, stripos($query,'from'),strlen($query)); 152 $count_result = $adb->query(substr($count_query, stripos($count_query,'select'),stripos($count_query,'ORDER BY'))); 153 $noofrows = $adb->query_result($count_result,0,"count"); 154 155 //Setting Listview session object while sorting/pagination 156 if(isset($_REQUEST['relmodule']) && $_REQUEST['relmodule']!='' && $_REQUEST['relmodule'] == $relatedmodule) 157 { 158 $relmodule = $_REQUEST['relmodule']; 159 if($_SESSION['rlvs'][$module][$relmodule]) 160 { 161 setSessionVar($_SESSION['rlvs'][$module][$relmodule],$noofrows,$list_max_entries_per_page,$module,$relmodule); 162 } 163 } 164 $start = $_SESSION['rlvs'][$module][$relatedmodule]['start']; 165 166 $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page); 167 168 $start_rec = $navigation_array['start']; 169 $end_rec = $navigation_array['end_val']; 170 171 //limiting the query 172 if ($start_rec ==0) 173 $limit_start_rec = 0; 174 else 175 $limit_start_rec = $start_rec -1; 176 177 if( $adb->dbType == "pgsql") 178 $list_result = $adb->query($query. " OFFSET ".$limit_start_rec." LIMIT ".$list_max_entries_per_page); 179 else 180 $list_result = $adb->query($query. " LIMIT ".$limit_start_rec.",".$list_max_entries_per_page); 181 182 //Retreive the List View Table Header 183 if($noofrows == 0) 184 { 185 $smarty->assign('NOENTRIES',$app_strings['LBL_NONE_SCHEDULED']); 186 } 187 else 188 { 189 $id = $_REQUEST['record']; 190 $listview_header = getListViewHeader($focus,$relatedmodule,'',$sorder,$order_by,$id,'',$module);//"Accounts"); 191 if ($noofrows > 15) 192 { 193 $smarty->assign('SCROLLSTART','<div style="overflow:auto;height:315px;width:100%;">'); 194 $smarty->assign('SCROLLSTOP','</div>'); 195 } 196 $smarty->assign("LISTHEADER", $listview_header); 197 198 if($module == 'PriceBook' && $relatedmodule == 'Products') 199 { 200 $listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,$edit_val,$del_val); 201 } 202 if($module == 'Products' && $relatedmodule == 'PriceBook') 203 { 204 $listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,'EditListPrice','DeletePriceBookProductRel'); 205 } 206 elseif($relatedmodule == 'SalesOrder') 207 { 208 $listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,'SalesOrderEditView','DeleteSalesOrder'); 209 }else 210 { 211 $listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset); 212 } 213 214 $navigationOutput = Array(); 215 $navigationOutput[] = $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows; 216 $module_rel = $module.'&relmodule='.$relatedmodule.'&record='.$id; 217 $navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, $url_qry,$module_rel); 218 $related_entries = array('header'=>$listview_header,'entries'=>$listview_entries,'navigation'=>$navigationOutput); 219 $log->debug("Exiting GetRelatedList method ..."); 220 return $related_entries; 221 } 222 } 223 224 /** Function to get related list entries in detailed array format 225 * @param $parentmodule -- parentmodulename:: Type string 226 * @param $query -- query:: Type string 227 * @param $id -- id:: Type string 228 * @returns $entries_list -- entries list:: Type string array 229 * 230 */ 231 232 function getAttachmentsAndNotes($parentmodule,$query,$id,$sid='') 233 { 234 global $log; 235 $log->debug("Entering getAttachmentsAndNotes(".$parentmodule.",".$query.",".$id.",".$sid.") method ..."); 236 global $theme; 237 238 $list = '<script> 239 function confirmdelete(url) 240 { 241 if(confirm("Are you sure?")) 242 { 243 document.location.href=url; 244 } 245 } 246 </script>'; 247 echo $list; 248 249 $theme_path="themes/".$theme."/"; 250 $image_path=$theme_path."images/"; 251 require_once ($theme_path."layout_utils.php"); 252 253 global $adb; 254 global $mod_strings; 255 global $app_strings; 256 257 $result=$adb->query($query); 258 $noofrows = $adb->num_rows($result); 259 260 $header[] = $app_strings['LBL_CREATED']; 261 $header[] = $app_strings['LBL_SUBJECT']; 262 $header[] = $app_strings['LBL_DESCRIPTION']; 263 $header[] = $app_strings['LBL_ATTACHMENTS']; 264 $header[] = $app_strings['LBL_TYPE']; 265 $header[] = $app_strings['LBL_ACTION']; 266 267 while($row = $adb->fetch_array($result)) 268 { 269 $entries = Array(); 270 if(trim($row['activitytype']) == 'Notes') 271 { 272 $module = 'Notes'; 273 $editaction = 'EditView'; 274 $deleteaction = 'Delete'; 275 } 276 elseif($row['activitytype'] == 'Attachments') 277 { 278 $module = 'uploads'; 279 $editaction = 'upload'; 280 $deleteaction = 'deleteattachments'; 281 } 282 if($row['createdtime'] != '0000-00-00 00:00:00') 283 { 284 $created_arr = explode(" ",getDisplayDate($row['createdtime'])); 285 $created_date = $created_arr[0]; 286 $created_time = substr($created_arr[1],0,5); 287 } 288 else 289 { 290 $created_date = ''; 291 $created_time = ''; 292 } 293 294 $entries[] = $created_date; 295 if($module == 'Notes') 296 { 297 $entries[] = '<a href="index.php?module='.$module.'&action=DetailView&return_module='.$parentmodule.'&return_action='.$return_action.'&record='.$row["crmid"].'&filename='.$row['filename'].'&fileid='.$row['attachmentsid'].'&return_id='.$_REQUEST["record"].'">'.$row['title'].'</a>'; 298 } 299 elseif($module == 'uploads') 300 { 301 $entries[] = ""; 302 } 303 304 if(strlen($row['description']) > 40) 305 { 306 $row['description'] = substr($row['description'],0,40).'...'; 307 } 308 $entries[] = nl2br($row['description']); 309 $attachmentname = ltrim($row['filename'],$row['attachmentsid'].'_');//explode('_',$row['filename'],2); 310 311 $entries[] = '<a href="index.php?module=uploads&action=downloadfile&entityid='.$id.'&fileid='.$row['attachmentsid'].'">'.$attachmentname.'</a>'; 312 313 $entries[] = $row['activitytype']; 314 315 $del_param = 'index.php?module='.$module.'&action='.$deleteaction.'&return_module='.$parentmodule.'&return_action='.$_REQUEST['action'].'&record='.$row["crmid"].'&return_id='.$_REQUEST["record"]; 316 317 if($module == 'Notes') 318 { 319 $edit_param = 'index.php?module='.$module.'&action='.$editaction.'&return_module='.$parentmodule.'&return_action='.$_REQUEST['action'].'&record='.$row["crmid"].'&filename='.$row['filename'].'&fileid='.$row['attachmentsid'].'&return_id='.$_REQUEST["record"]; 320 321 $entries[] .= '<a href="'.$edit_param.'">'.$app_strings['LNK_EDIT'].'</a> | <a href=\'javascript:confirmdelete("'.$del_param.'")\'>'.$app_strings['LNK_DELETE'].'</a>'; 322 } 323 else 324 { 325 $entries[] = '<a href=\'javascript:confirmdelete("'.$del_param.'")\'>'.$app_strings['LNK_DELETE'].'</a>'; 326 } 327 $entries_list[] = $entries; 328 } 329 330 if($entries_list !='') 331 $return_data = array('header'=>$header,'entries'=>$entries_list); 332 $log->debug("Exiting getAttachmentsAndNotes method ..."); 333 return $return_data; 334 335 } 336 337 /** Function to get related list entries in detailed array format 338 * @param $parentmodule -- parentmodulename:: Type string 339 * @param $query -- query:: Type string 340 * @param $id -- id:: Type string 341 * @returns $return_data -- return data:: Type string array 342 * 343 */ 344 345 function getHistory($parentmodule,$query,$id) 346 { 347 global $log; 348 $log->debug("Entering getHistory(".$parentmodule.",".$query.",".$id.") method ..."); 349 $parentaction = $_REQUEST['action']; 350 global $theme; 351 $theme_path="themes/".$theme."/"; 352 $image_path=$theme_path."images/"; 353 require_once ($theme_path."layout_utils.php"); 354 355 global $adb; 356 global $mod_strings; 357 global $app_strings; 358 359 //Appending the security parameter 360 global $current_user; 361 $rel_tab_id = getTabid("Calendar"); 362 363 global $current_user; 364 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 365 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 366 $tab_id=getTabid('Calendar'); 367 if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) 368 { 369 $sec_parameter=getListViewSecurityParameter('Calendar'); 370 $query .= ' '.$sec_parameter; 371 372 } 373 $result=$adb->query($query); 374 $noofrows = $adb->num_rows($result); 375 376 if($noofrows == 0) 377 { 378 //There is no entries for history 379 } 380 else 381 { 382 //Form the header columns 383 $header[] = $app_strings['LBL_TYPE']; 384 $header[] = $app_strings['LBL_SUBJECT']; 385 $header[] = $app_strings['LBL_RELATED_TO']; 386 $header[] = $app_strings['LBL_START_DATE']; 387 $header[] = $app_strings['LBL_END_DATE']; 388 //$header[] = $app_strings['LBL_DESCRIPTION']; 389 $header[] = $app_strings['LBL_ACTION']; 390 $header[] = $app_strings['LBL_ASSIGNED_TO']; 391 392 $i=1; 393 while($row = $adb->fetch_array($result)) 394 { 395 $entries = Array(); 396 if($row['activitytype'] == 'Task') 397 { 398 $activitymode = 'Task'; 399 $icon = 'Tasks.gif'; 400 $status = $row['status']; 401 } 402 elseif($row['activitytype'] == 'Call' || $row['activitytype'] == 'Meeting') 403 { 404 $activitymode = 'Events'; 405 $icon = 'Activities.gif'; 406 $status = $row['eventstatus']; 407 } 408 409 $entries[] = $row['activitytype']; 410 411 $activity = '<a href="index.php?module=Calendar&action=DetailView&return_module='.$parentmodule.'&return_action=DetailView&record='.$row["activityid"] .'&activity_mode='.$activitymode.'&return_id='.$_REQUEST['record'].'" title="'.$row['description'].'">'.$row['subject'].'</a></td>'; 412 $entries[] = $activity; 413 414 $parentname = getRelatedTo('Calendar',$result,$i-1); 415 $entries[] = $parentname; 416 417 $entries[] = $row['date_start']; 418 $entries[] = $row['due_date']; 419 420 //$entries[] = nl2br($row['description']); 421 422 if(isPermitted("Calendar",1,$row["activityid"]) == 'yes') 423 { 424 $list .= '<a href="index.php?module=Calendar&action=EditView&return_module='.$parentmodule.'&return_action='.$parentaction.'&activity_mode='.$activitymode.'&record='.$row["activityid"].'&return_id='.$_REQUEST["record"].'">'.$app_strings['LNK_EDIT'].'</a>'; 425 426 } 427 428 $entries[] = $status; 429 430 if($row['user_name']==NULL && $row['groupname']!=NULL) 431 { 432 $entries[] = $row['groupname']; 433 } 434 else 435 { 436 $entries[] = $row['user_name']; 437 438 } 439 440 if(isPermitted("Calendar",2,$row["activityid"]) == 'yes') 441 { 442 $list .= '<a href="index.php?module=Calendar&action=Delete&return_module='.$parentmodule.'&return_action='.$parentaction.'&record='.$row["activityid"].'&return_id='.$_REQUEST["record"].'">'.$app_strings['LNK_DELETE'].'</a>'; 443 } 444 445 $i++; 446 $entries_list[] = $entries; 447 } 448 449 $return_data = array('header'=>$header,'entries'=>$entries_list); 450 $log->debug("Exiting getHistory method ..."); 451 return $return_data; 452 } 453 } 454 455 /** Function to display the Products which are related to the PriceBook 456 * @param string $query - query to get the list of products which are related to the current PriceBook 457 * @param object $focus - PriceBook object which contains all the information of the current PriceBook 458 * @param string $returnset - return_module, return_action and return_id which are sequenced with & to pass to the URL which is optional 459 * return array $return_data which will be formed like array('header'=>$header,'entries'=>$entries_list) where as $header contains all the header columns and $entries_list will contain all the Product entries 460 */ 461 function getPriceBookRelatedProducts($query,$focus,$returnset='') 462 { 463 global $log; 464 $log->debug("Entering getPriceBookRelatedProducts(".$query.",".$focus.",".$returnset.") method ..."); 465 466 global $adb; 467 global $app_strings; 468 global $mod_strings; 469 global $current_language; 470 $current_module_strings = return_module_language($current_language, 'PriceBook'); 471 472 global $list_max_entries_per_page; 473 global $urlPrefix; 474 475 global $theme; 476 $pricebook_id = $_REQUEST['record']; 477 $theme_path="themes/".$theme."/"; 478 $image_path=$theme_path."images/"; 479 require_once ($theme_path.'layout_utils.php'); 480 481 //Retreive the list from Database 482 $list_result = $adb->query($query); 483 $num_rows = $adb->num_rows($list_result); 484 485 $header=array(); 486 $header[]=$mod_strings['LBL_LIST_PRODUCT_NAME']; 487 $header[]=$mod_strings['LBL_PRODUCT_CODE']; 488 $header[]=$mod_strings['LBL_PRODUCT_UNIT_PRICE']; 489 $header[]=$mod_strings['LBL_PB_LIST_PRICE']; 490 $header[]=$mod_strings['LBL_ACTION']; 491 492 for($i=0; $i<$num_rows; $i++) 493 { 494 $entity_id = $adb->query_result($list_result,$i,"crmid"); 495 496 $unit_price = $adb->query_result($list_result,$i,"unit_price"); 497 $listprice = $adb->query_result($list_result,$i,"listprice"); 498 $field_name=$entity_id."_listprice"; 499 500 $entries = Array(); 501 $entries[] = $adb->query_result($list_result,$i,"productname"); 502 $entries[] = $adb->query_result($list_result,$i,"productcode"); 503 $entries[] = $unit_price; 504 $entries[] = $listprice; 505 $entries[] = '<img style="cursor:pointer;" src="'.$image_path.'editfield.gif" border="0" onClick="fnvshobj(this,\'editlistprice\'),editProductListPrice(\''.$entity_id.'\',\''.$pricebook_id.'\',\''.$listprice.'\')" alt="'.$app_strings["LBL_EDIT_BUTTON"].'" title="'.$app_strings["LBL_EDIT_BUTTON"].'"/><!--a href="index.php?module=Products&action=EditListPrice&record='.$entity_id.'&pricebook_id='.$pricebook_id.'&listprice='.$listprice.'">edit</a--> | <img src="'.$image_path.'delete.gif" onclick="if(confirm(\'Are you sure?\')) deletePriceBookProductRel('.$entity_id.','.$pricebook_id.');" alt="'.$app_strings["LBL_DELETE"].'" title="'.$app_strings["LBL_DELETE"].'" style="cursor:pointer;" border="0">'; 506 507 $entries_list[] = $entries; 508 } 509 if($num_rows>0) 510 { 511 $return_data = array('header'=>$header,'entries'=>$entries_list); 512 513 $log->debug("Exiting getPriceBookRelatedProducts method ..."); 514 return $return_data; 515 } 516 } 517 518 ?>
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 |