[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Reports/ -> ReportSharing.php (source)

   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  require_once ("data/Tracker.php");
  13  require_once ('include/logging.php');
  14  require_once ('include/utils/utils.php');
  15  require_once ('modules/Reports/Reports.php');
  16  
  17  global $app_strings;
  18  global $app_list_strings;
  19  global $mod_strings;
  20  $current_module_strings = return_module_language($current_language, 'Reports');
  21  global $list_max_entries_per_page;
  22  global $urlPrefix;
  23  
  24  $log = LoggerManager::getLogger('report_type');
  25  global $currentModule;
  26  global $image_path;
  27  global $theme;
  28  global $current_user;
  29  
  30  $report_std_filter = new vtigerCRM_Smarty; 
  31  $report_std_filter->assign("MOD", $mod_strings);
  32  $report_std_filter->assign("APP", $app_strings);
  33  $report_std_filter->assign("IMAGE_PATH",$image_path);
  34  $report_std_filter->assign("DATEFORMAT",$current_user->date_format);
  35  $report_std_filter->assign("JS_DATEFORMAT",parse_calendardate($app_strings['NTC_DATE_FORMAT']));
  36  
  37  $roleid = $current_user->column_fields['roleid'];
  38  $user_array = getAllUserName();
  39  $userIdStr = "";
  40  $userNameStr = "";
  41  $m=0;
  42  foreach($user_array as $userid=>$username){
  43      
  44      if($userid!=$current_user->id){
  45          if($m!=0){
  46              $userIdStr .= ",";
  47              $userNameStr .= ",";
  48          }
  49          $userIdStr .="'".$userid."'"; 
  50          $userNameStr .="'".escape_single_quotes(decode_html($username))."'";
  51          $m++;
  52      }
  53  }
  54  
  55  $user_groups = getAllGroupName();
  56  $groupIdStr = "";
  57  $groupNameStr = "";
  58  $l=0;
  59  foreach($user_groups as $grpid=>$groupname){
  60      if($l!=0){
  61          $groupIdStr .= ",";
  62          $groupNameStr .= ",";
  63      }
  64      $groupIdStr .= "'".$grpid."'";
  65      $groupNameStr .= "'".escape_single_quotes(decode_html($groupname))."'";
  66      $l++;
  67  }
  68  if(isset($_REQUEST["record"]) && $_REQUEST['record']!='')
  69  {
  70      $reportid = vtlib_purify($_REQUEST["record"]);
  71      $visiblecriteria=getVisibleCriteria($recordid);
  72      $report_std_filter->assign("VISIBLECRITERIA", $visiblecriteria);
  73      $member = getShareInfo($recordid);
  74      $report_std_filter->assign("MEMBER", $member);
  75  } else {
  76      $visiblecriteria=getVisibleCriteria();
  77      $report_std_filter->assign("VISIBLECRITERIA", $visiblecriteria);
  78  }
  79  $report_std_filter->assign("GROUPNAMESTR", $groupNameStr);
  80  $report_std_filter->assign("USERNAMESTR", $userNameStr);
  81  $report_std_filter->assign("GROUPIDSTR", $groupIdStr);
  82  $report_std_filter->assign("USERIDSTR", $userIdStr);
  83  
  84  
  85  //include("modules/Reports/StandardFilter.php");
  86  //include("modules/Reports/AdvancedFilter.php");
  87  
  88  $report_std_filter->display('ReportSharing.tpl');
  89  
  90  /** Function to get visible criteria for a report
  91   *  This function accepts The reportid as an argument
  92   *  It returns a array of selected option of sharing along with other options
  93   */
  94  function getVisibleCriteria($recordid='')
  95  {
  96      global $mod_strings; 
  97      global $app_strings;
  98      global $adb,$current_user;
  99      //print_r("i am here");die;
 100      $filter = array();
 101      $selcriteria = "";
 102      if($recordid!='')
 103      {
 104          $result = $adb->pquery("select sharingtype from vtiger_report where reportid=?",array($recordid));
 105          $selcriteria=$adb->query_result($result,0,"sharingtype");
 106      }
 107      if($selcriteria == ""){
 108          $selcriteria = 'Public';
 109      }
 110      $filter_result = $adb->query("select * from vtiger_reportfilters");
 111      $numrows = $adb->num_rows($filter_result);
 112      for($j=0;$j<$numrows;$j++)
 113      {
 114          $filter_id = $adb->query_result($filter_result,$j,"filterid");
 115          $filtername = $adb->query_result($filter_result,$j,"name");
 116          $name=str_replace(' ','_',$filtername);
 117          if($filtername == 'Private') {
 118              $FilterKey='Private';
 119              $FilterValue=getTranslatedString('PRIVATE_FILTER');
 120          }elseif($filtername=='Shared')
 121          {
 122              $FilterKey='Shared';
 123              $FilterValue=getTranslatedString('SHARE_FILTER');
 124          }else{
 125              $FilterKey='Public';
 126              $FilterValue=getTranslatedString('PUBLIC_FILTER');
 127          }
 128          if($FilterKey == $selcriteria)
 129          {
 130              $shtml['value'] = $FilterKey;
 131              $shtml['text'] = $FilterValue;
 132              $shtml['selected'] = "selected";
 133          }else
 134          {
 135              $shtml['value'] = $FilterKey;
 136              $shtml['text'] = $FilterValue;
 137              $shtml['selected'] = "";
 138          }
 139          $filter[] = $shtml;
 140      }        
 141      return $filter;
 142  }
 143  
 144  function getShareInfo($recordid=''){
 145      global $adb;
 146      $member_query = $adb->pquery("SELECT vtiger_reportsharing.setype,vtiger_users.id,vtiger_users.user_name FROM vtiger_reportsharing INNER JOIN vtiger_users on vtiger_users.id = vtiger_reportsharing.shareid WHERE vtiger_reportsharing.setype='users' AND vtiger_reportsharing.reportid = ?",array($recordid));
 147      $noofrows = $adb->num_rows($member_query);
 148      if($noofrows > 0){
 149          for($i=0;$i<$noofrows;$i++){
 150              $userid = $adb->query_result($member_query,$i,'id');
 151              $username = $adb->query_result($member_query,$i,'user_name');
 152              $setype = $adb->query_result($member_query,$i,'setype');
 153              $member_data[] = Array('id'=>$setype."::".$userid,'name'=>$setype."::".$username);
 154          }
 155      }
 156      
 157      $member_query = $adb->pquery("SELECT vtiger_reportsharing.setype,vtiger_groups.groupid,vtiger_groups.groupname FROM vtiger_reportsharing INNER JOIN vtiger_groups on vtiger_groups.groupid = vtiger_reportsharing.shareid WHERE vtiger_reportsharing.setype='groups' AND vtiger_reportsharing.reportid = ?",array($recordid));
 158      $noofrows = $adb->num_rows($member_query);
 159      if($noofrows > 0){
 160          for($i=0;$i<$noofrows;$i++){
 161              $grpid = $adb->query_result($member_query,$i,'groupid');
 162              $grpname = $adb->query_result($member_query,$i,'groupname');
 163              $setype = $adb->query_result($member_query,$i,'setype');
 164              $member_data[] = Array('id'=>$setype."::".$grpid,'name'=>$setype."::".$grpname);
 165          }
 166      }
 167      return $member_data;
 168  }
 169  
 170  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1