[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/Home/ -> index.php (source)

   1  <?php
   2  /*********************************************************************************
   3   * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
   4   * ("License"); You may not use this file except in compliance with the
   5   * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
   6   * Software distributed under the License is distributed on an  "AS IS"  basis,
   7   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
   8   * the specific language governing rights and limitations under the License.
   9   * The Original Code is:  SugarCRM Open Source
  10   * The Initial Developer of the Original Code is SugarCRM, Inc.
  11   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
  12   * All Rights Reserved.
  13   * Contributor(s): ______________________________________.
  14   ********************************************************************************/
  15  /*********************************************************************************
  16   * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Home/index.php,v 1.28 2005/04/20 06:57:47 samk Exp $
  17   * Description:  Main file for the Home module.
  18   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  19   * All Rights Reserved.
  20   * Contributor(s): ______________________________________..
  21   ********************************************************************************/
  22  require_once ('Smarty_setup.php');
  23  global $theme;
  24  $theme_path="themes/".$theme."/";
  25  $image_path=$theme_path."images/";
  26  require_once ($theme_path.'layout_utils.php');
  27  require_once ('include/database/PearDatabase.php');
  28  require_once ('include/utils/UserInfoUtil.php');
  29  require_once ('include/utils/CommonUtils.php');
  30  require_once ('include/freetag/freetag.class.php');
  31  global $app_strings;
  32  global $app_list_strings;
  33  global $mod_strings;
  34  $smarty = new vtigerCRM_Smarty;
  35  
  36  $_REQUEST['search_form'] = 'false';
  37  $_REQUEST['query'] = 'true';
  38  $_REQUEST['status'] = 'In Progress--Not Started';
  39  $_REQUEST['current_user_only'] = 'On';
  40  
  41  $task_title = $mod_strings['LBL_OPEN_TASKS'];
  42  
  43  // MWC Home Order Sorting functions given by mike
  44  global $adb;
  45  global $current_user;
  46  
  47  $query = "SELECT vtiger_users.homeorder FROM vtiger_users WHERE id=".$current_user->id;
  48  $result =& $adb->query($query, true,"Error getting home order");
  49  $row = $adb->fetchByAssoc($result);
  50  
  51  if($row != null)
  52  {
  53      $home_section_order = $row['homeorder'];
  54  }
  55  if( count($home_section_order) < 1 )
  56  {
  57      $home_section_order = array("ALVT","HDB","PLVT","QLTQ","CVLVT","HLT","OLV","GRT","OLTSO","ILTI","MNL","OLTPO","LTFAQ");
  58  }
  59  
  60  require('user_privileges/user_privileges_'.$current_user->id.'.php');
  61  foreach ( explode(",",$home_section_order) as $section )
  62  {
  63      switch( $section )
  64      {
  65          case 'OLV':
  66      if(isPermitted('Calendar','index') == "yes")
  67      {
  68          $activities = Array();
  69                  include ("modules/Calendar/OpenListView.php") ;
  70                  $activities[] = getPendingActivities(0);
  71                  $activities[] = getPendingActivities(1);
  72      }
  73              break;
  74          case 'ALVT':
  75  
  76  
  77      //Added to support the inclusion of the Top Accounts in the Home Page. 
  78      //Fix given by Mike Crowe
  79          if(isPermitted('Accounts','index') == "yes")
  80          {
  81                  include ("modules/Accounts/ListViewTop.php");
  82          $home_values['Accounts']=getTopAccounts();
  83          }
  84              break;
  85          case 'PLVT':
  86      if(isPermitted('Potentials','index') == "yes")
  87          {
  88           include ("modules/Potentials/ListViewTop.php");
  89           $home_values['Potentials']=getTopPotentials();
  90      }
  91              break;
  92  
  93          case 'MNL':
  94      if(isPermitted('Leads','index') == "yes")
  95          {
  96           include ("modules/Leads/ListViewTop.php");
  97           $home_values['Leads']=getNewLeads();
  98      }
  99              break;
 100  
 101      case 'GRT':
 102          $home_values['GroupAllocation']=getGroupTaskLists();       
 103             break;
 104          case 'HLT':
 105          if(isPermitted('HelpDesk','index') == "yes")
 106          {
 107          require_once ('modules/HelpDesk/ListTickets.php');
 108          $home_values['HelpDesk']=getMyTickets();
 109      }
 110              break;
 111          case 'CVLVT':
 112      include ("modules/CustomView/ListViewTop.php");
 113      $home_values['CustomView'] = getKeyMetrics();
 114              break;
 115          case 'QLTQ':
 116          if(isPermitted('Quotes','index') == "yes")
 117          {
 118          require_once ('modules/Quotes/ListTopQuotes.php');
 119          $home_values['Quotes']=getTopQuotes();
 120      }
 121              break;
 122          case 'OLTSO':
 123          if(isPermitted('SalesOrder','index') == "yes")
 124          {
 125          require_once ('modules/SalesOrder/ListTopSalesOrder.php');
 126          $home_values['SalesOrder']=getTopSalesOrder();
 127      }
 128              break;
 129          case 'ILTI':
 130          if(isPermitted('Invoice','index') == "yes")
 131          {
 132          require_once ('modules/Invoice/ListTopInvoice.php');
 133          $home_values['Invoice']=getTopInvoice();
 134      }
 135              break;
 136      case 'HDB':
 137      if(isPermitted('Dashboard','index') == "yes")
 138      {
 139          $smarty->assign('IS_HOMEDASH','true');
 140          $home_values['Dashboard']="true";
 141      }
 142          break;
 143      case 'OLTPO':
 144          if(isPermitted('PurchaseOrder','index') == "yes")
 145          {
 146          require_once ('modules/PurchaseOrder/ListTopPurchaseOrder.php');
 147          $home_values['PurchaseOrder']=getTopPurchaseOrder();
 148      }
 149          break;
 150      case 'LTFAQ':
 151          if(isPermitted('Faq','index') == "yes")
 152          {
 153          require_once ('modules/Faq/ListFaq.php');
 154          $home_values['Faq']=getMyFaq();
 155      }
 156              break;
 157  
 158      }
 159  }
 160  
 161      /** Function to get the ActivityType for the given entity id
 162       *  @param entityid : Type Integer
 163       *  return the activity type for the given id
 164       */
 165  function getActivityType($id)
 166  {
 167      global $adb;
 168      $quer = "select activitytype from vtiger_activity where activityid=".$id;
 169      $res = $adb->query($quer);
 170      $acti_type = $adb->query_result($res,0,"activitytype");
 171      return $acti_type;
 172  
 173  }
 174  
 175  global $current_language;
 176  $current_module_strings = return_module_language($current_language, 'Calendar');
 177  
 178  $t=Date("Ymd");
 179  $buttoncheck['Calendar'] = isPermitted('Calendar','index');
 180  $smarty->assign("CHECK",$buttoncheck);
 181  $smarty->assign("IMAGE_PATH",$image_path);
 182  $smarty->assign("APP",$app_strings);
 183  $smarty->assign("MOD",$mod_strings);
 184  $smarty->assign("MODULE",'Home');
 185  $smarty->assign("CATEGORY",getParenttab('Home'));
 186  $smarty->assign("HOMEDETAILS",$home_values);
 187  $smarty->assign("HOMEDEFAULTVIEW",DefHomeView());
 188  $smarty->assign("ACTIVITIES",$activities);
 189  $freetag = new freetag();
 190  $smarty->assign("ALL_TAG",$freetag->get_tag_cloud_html("",$current_user->id));
 191  $smarty->display("HomePage.tpl");
 192  
 193      /** Function to get the Tasks assigned to the group for the currentUser 
 194       *  This function accepts no arguments
 195       * @returns  $group related tasks Array in the following format
 196       * $values = Array('Title'=>Array(0=>'image name',
 197       *                 1=>'My Group Allocation',
 198       *                  2=>'home_mygrp'
 199       *                 ),
 200       *          'Header'=>Array(0=>'Entity Name',
 201       *                    1=>'Group Name',
 202       *                  2=>'Entity Type'    
 203       *                  ),
 204       *          'Entries'=>Array($id=>Array(
 205       *                          0=>$name,
 206       *                        1=>$groupname,
 207       *                        2=>$entityname
 208       *                           ),
 209       *                   $id1=>Array(
 210           *                                               0=>$name1,
 211           *                                               1=>$groupname1,
 212       *                         2=>$entityname1    
 213           *                                              ),
 214       *                    |
 215       *                    |
 216           *                   $idn=>Array(
 217           *                                               0=>$namen,
 218           *                                               1=>$groupnamen,
 219       *                         2=>$entitynamen        
 220           *                                              )    
 221       *                  )
 222       *
 223          */
 224  function getGroupTaskLists()
 225  {
 226      //get all the group relation tasks
 227      global $current_user;
 228      global $adb;
 229      global $log;
 230      global $app_strings;
 231      $userid= $current_user->id;
 232      $groupids = fetchUserGroupids($userid);
 233      if($groupids !='')
 234      {
 235          $query = '';
 236          if(isPermitted('Leads','index') == "yes")
 237              {
 238              //code modified to list the vtiger_groups associates to a user om 21-11-05
 239              //Get the leads assigned to group
 240              $query = "select vtiger_leaddetails.leadid as id,vtiger_leaddetails.lastname as name,vtiger_leadgrouprelation.groupname as groupname, 'Leads     ' as Type from vtiger_leaddetails inner join vtiger_leadgrouprelation on vtiger_leaddetails.leadid=vtiger_leadgrouprelation.leadid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_leaddetails.leadid inner join vtiger_groups on vtiger_leadgrouprelation.groupname=vtiger_groups.groupname where  vtiger_crmentity.deleted=0  and vtiger_leadgrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
 241          }
 242          if(isPermitted('Calendar','index') == "yes")
 243              {
 244              if($query !='')
 245              $query .= " union all ";
 246              //Get the activities assigned to group
 247              $query .= "select vtiger_activity.activityid id,vtiger_activity.subject as name,vtiger_activitygrouprelation.groupname,'Activities' as Type from vtiger_activity inner join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_activity.activityid inner join vtiger_groups on vtiger_activitygrouprelation.groupname=vtiger_groups.groupname where  vtiger_crmentity.deleted=0 and ((vtiger_activity.eventstatus !='held'and (vtiger_activity.status is null or vtiger_activity.status ='')) or (vtiger_activity.status !='completed' and (vtiger_activity.eventstatus is null or vtiger_activity.eventstatus=''))) and vtiger_activitygrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
 248          }
 249          if(isPermitted('HelpDesk','index') == "yes")
 250                  {
 251              if($query !='')
 252              $query .= " union all ";
 253              //Get the tickets assigned to group (status not Closed -- hardcoded value)
 254              $query .= "select vtiger_troubletickets.ticketid,vtiger_troubletickets.title as name,vtiger_ticketgrouprelation.groupname,'Tickets   ' as Type from vtiger_troubletickets inner join vtiger_ticketgrouprelation on vtiger_ticketgrouprelation.ticketid=vtiger_troubletickets.ticketid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_troubletickets.ticketid inner join vtiger_groups on vtiger_ticketgrouprelation.groupname=vtiger_groups.groupname where vtiger_crmentity.deleted=0 and vtiger_troubletickets.status != 'Closed' and vtiger_ticketgrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
 255  
 256          }
 257          $log->info("Here is the where clause for the list view: $query");
 258          $result = $adb->limitquery($query,0,5) or die("Couldn't get the group listing");
 259  
 260          $title=array();
 261          $title[]='myGroupAllocation.gif';
 262          $title[]=$app_strings['LBL_GROUP_ALLOCATION_TITLE'];
 263          $title[]='home_mygrp';
 264          $header=array();
 265          $header[]=$app_strings['LBL_ENTITY_NAME'];
 266          $header[]=$app_strings['LBL_GROUP_NAME'];
 267          $header[]=$app_strings['LBL_ENTITY_TYPE'];
 268  
 269  
 270  
 271          if($groupids !='')
 272          {
 273              $i=1;
 274              while($row = $adb->fetch_array($result))
 275              {
 276                  $value=array();    
 277                  $row["type"]=trim($row["type"]);
 278                  if($row["type"] == "Tickets")
 279                  {    
 280                      $list = '<a href=index.php?module=HelpDesk';
 281                      $list .= '&action=DetailView&record='.$row["id"].'>'.$row["name"].'</a>';
 282                  }
 283                  elseif($row["type"] == "Activities")
 284                  {
 285                      $row["type"] = 'Calendar';
 286                      $acti_type = getActivityType($row["id"]);
 287                      $list = '<a href=index.php?module='.$row["type"];
 288                      if($acti_type == 'Task')
 289                      {
 290                          $list .= '&activity_mode=Task';
 291                      }
 292                      elseif($acti_type == 'Call' || $acti_type == 'Meeting')
 293                      {
 294                          $list .= '&activity_mode=Events';
 295                      }
 296                      $list .= '&action=DetailView&record='.$row["id"].'>'.$row["name"].'</a>';
 297                  }
 298                  else
 299                  {
 300                      $list = '<a href=index.php?module='.$row["type"];
 301                      $list .= '&action=DetailView&record='.$row["id"].'>'.$row["name"].'</a>';
 302                  }
 303  
 304                  $value[]=$list;    
 305                  $value[]= $row["groupname"];
 306                  $value[]= $row["type"];
 307                  $entries[$row["id"]]=$value;    
 308                  $i++;
 309              }
 310          }
 311  
 312          $values=Array('Title'=>$title,'Header'=>$header,'Entries'=>$entries);
 313          if(count($entries)>0)    
 314              return $values;
 315          } 
 316  }
 317  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7