[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Dashboard/ -> Chart_pipeline_by_sales_stage.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$
  17   * Description:  returns HTML for client-side image map.
  18   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  19   * All Rights Reserved.
  20   * Contributor(s): ______________________________________..
  21   ********************************************************************************/
  22  
  23  require_once ('include/utils/utils.php');
  24  require_once ('include/logging.php');
  25  require_once ("modules/Potentials/Charts.php");
  26  require_once ('include/ComboUtil.php');
  27  global $app_list_strings, $current_language, $tmp_dir, $currentModule, $action;
  28  $current_module_strings = return_module_language($current_language, 'Dashboard');
  29  
  30  $log = LoggerManager::getLogger('pipeline_by_sales_stage');
  31  
  32  if (isset($_REQUEST['pbss_refresh'])) { $refresh = $_REQUEST['pbss_refresh']; }
  33  else { $refresh = false; }
  34  
  35  // added for auto refresh
  36  $refresh = true;
  37  //
  38  
  39  // Get _dom Arrays from Database
  40  $comboFieldNames = Array('sales_stage'=>'sales_stage_dom');
  41  $comboFieldArray = getComboArray($comboFieldNames);
  42  
  43  //get the dates to display
  44  if (isset($_SESSION['pbss_date_start']) && $_SESSION['pbss_date_start'] != '' && !isset($_REQUEST['pbss_date_start'])) {
  45      $date_start = $_SESSION['pbss_date_start'];
  46      $log->debug("_SESSION['pbss_date_start'] is:");
  47      $log->debug($_SESSION['pbss_date_start']);
  48  }
  49  elseif (isset($_REQUEST['pbss_date_start']) && $_REQUEST['pbss_date_start'] != '') {
  50      $date_start = $_REQUEST['pbss_date_start'];
  51      $current_user->setPreference('pbss_date_start', $_REQUEST['pbss_date_start']);
  52      $log->debug("_REQUEST['pbss_date_start'] is:");
  53      $log->debug($_REQUEST['pbss_date_start']);
  54      $log->debug("_SESSION['pbss_date_start'] is:");
  55      $log->debug($_SESSION['pbss_date_start']);
  56  }
  57  else {
  58      $date_start = "2001-01-01";
  59  }
  60  
  61  if (isset($_SESSION['pbss_date_end']) && $_SESSION['pbss_date_end'] != '' && !isset($_REQUEST['pbss_date_end'])) {
  62      $date_end = $_SESSION['pbss_date_end'];
  63      $log->debug("_SESSION['pbss_date_end'] is:");
  64      $log->debug($_SESSION['pbss_date_end']);
  65  }
  66  elseif (isset($_REQUEST['pbss_date_end']) && $_REQUEST['pbss_date_end'] != '') {
  67      $date_end = $_REQUEST['pbss_date_end'];
  68      $current_user->setPreference('pbss_date_end', $_REQUEST['pbss_date_end']);
  69      $log->debug("_REQUEST['pbss_date_end'] is:");
  70      $log->debug($_REQUEST['pbss_date_end']);
  71      $log->debug("_SESSION['pbss_date_end'] is:");
  72      $log->debug($_SESSION['pbss_date_end']);
  73  }
  74  else {
  75      $date_end = '2100-01-01';
  76  }
  77  
  78  $tempx = array();
  79  $datax = array();
  80  //get list of sales stage keys to display
  81  if (isset($_SESSION['pbss_sales_stages']) && count($_SESSION['pbss_sales_stages']) > 0 && !isset($_REQUEST['pbss_sales_stages'])) {
  82      $tempx = $_SESSION['pbss_sales_stages'];
  83      $log->debug("_SESSION['pbss_sales_stages'] is:");
  84      $log->debug($_SESSION['pbss_sales_stages']);
  85  }
  86  elseif (isset($_REQUEST['pbss_sales_stages']) && count($_REQUEST['pbss_sales_stages']) > 0) {
  87      $tempx = $_REQUEST['pbss_sales_stages'];
  88      $current_user->setPreference('pbss_sales_stages', $_REQUEST['pbss_sales_stages']);
  89      $log->debug("_REQUEST['pbss_sales_stages'] is:");
  90      $log->debug($_REQUEST['pbss_sales_stages']);
  91      $log->debug("_SESSION['pbss_sales_stages'] is:");
  92      $log->debug($_SESSION['pbss_sales_stages']);
  93  }
  94  
  95  //set $datax using selected sales stage keys 
  96  if (count($tempx) > 0) {
  97      foreach ($tempx as $key) {
  98          $datax[$key] = $comboFieldArray['sales_stage_dom'][$key];
  99      }
 100  }
 101  else {
 102      $datax = $comboFieldArray['sales_stage_dom'];
 103  }
 104  $log->debug("datax is:");
 105  $log->debug($datax);
 106  
 107  $ids = array();
 108  //get list of user ids for which to display data
 109  if (isset($_SESSION['pbss_ids']) && count($_SESSION['pbss_ids']) != 0 && !isset($_REQUEST['pbss_ids'])) {
 110      $ids = $_SESSION['pbss_ids'];
 111      $log->debug("_SESSION['pbss_ids'] is:");
 112      $log->debug($_SESSION['pbss_ids']);
 113  }
 114  elseif (isset($_REQUEST['pbss_ids']) && count($_REQUEST['pbss_ids']) > 0) {
 115      $ids = $_REQUEST['pbss_ids'];
 116      $current_user->setPreference('pbss_ids', $_REQUEST['pbss_ids']);
 117      $log->debug("_REQUEST['pbss_ids'] is:");
 118      $log->debug($_REQUEST['pbss_ids']);
 119      $log->debug("_SESSION['pbss_ids'] is:");
 120      $log->debug($_SESSION['pbss_ids']);
 121  }
 122  else {
 123      $ids = get_user_array(false);
 124      $ids = array_keys($ids);
 125  }
 126  
 127  //create unique prefix based on selected users for image files
 128  $id_hash = '';
 129  if (isset($ids)) {
 130      sort($ids);
 131      $id_hash = crc32(implode('',$ids));
 132  }
 133  $log->debug("ids is:");
 134  $log->debug($ids);
 135  
 136  $cache_file_name = $id_hash."_pipeline_".$current_language."_".crc32(implode('',$datax)).$date_start.$date_end.".png";
 137  $log->debug("cache file name is: $cache_file_name");
 138  
 139  if(isPermitted('Potentials','index')=="yes")
 140  {
 141  $draw_this = new jpgraph();
 142  $width = 850;
 143  $height = 500;
 144  if(isset($_REQUEST['display_view']) && $_REQUEST['display_view'] == 'MATRIX')
 145  {
 146      $width = 350;
 147      $height = 250;
 148  }
 149  
 150  
 151  echo $draw_this->pipeline_by_sales_stage($datax, $date_start, $date_end, $ids, $tmp_dir.$cache_file_name, $refresh,$width,$height);
 152  echo "<P><font size='1'><em>".$current_module_strings['LBL_SALES_STAGE_FORM_DESC']."</em></font></P>";
 153  if (isset($_REQUEST['pbss_edit']) && $_REQUEST['pbss_edit'] == 'true') {
 154      $cal_lang = "en";
 155      $cal_dateformat = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
 156      $cal_dateformat = '%Y-%m-%d'; // fix providedd by Jlee for date bug in Dashboard
 157  
 158  ?>
 159  <link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css">
 160  <script type="text/javascript" src="jscalendar/calendar.js"></script>
 161  <script type="text/javascript" src="jscalendar/lang/calendar-<?php echo $cal_lang ?>.js"></script>
 162  <script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
 163  <form name='pipeline_by_sales_stage' action="index.php" method="post" >
 164  <input type="hidden" name="module" value="<?php echo $currentModule;?>">
 165  <input type="hidden" name="action" value="<?php echo $action;?>">
 166  <input type="hidden" name="pbss_refresh" value="true">
 167  <table cellpadding="2" border="0"><tbody>
 168  <tr>
 169  
 170  
 171  <td valign='top' nowrap><?php echo $current_module_strings['LBL_DATE_START']?> <br><em><?php echo $app_strings['NTC_DATE_FORMAT']?></em></td>
 172  
 173  <td valign='top' ><input class="text" name="pbss_date_start" size='12' maxlength='10' id='date_start' value='<?php if (isset($_SESSION['pbss_date_start'])) echo $_SESSION['pbss_date_start']?>'>  <img src="themes/<?php echo $theme ?>/images/calendar.gif" id="date_start_trigger"> </td>
 174  </tr><tr>
 175  <tr>
 176  <td valign='top' nowrap><?php echo $current_module_strings['LBL_DATE_END'];?><br><em><?php echo $app_strings['NTC_DATE_FORMAT']?></em></td>
 177  <td valign='top' ><input class="text" name="pbss_date_end" size='12' maxlength='10' id='date_end' value='<?php if (isset($_SESSION['pbss_date_end'])) echo $_SESSION['pbss_date_end']?>'>  <img src="themes/<?php echo $theme ?>/images/calendar.gif" id="date_end_trigger"> </td>
 178  </tr><tr>
 179  <td valign='top' nowrap><?php echo $current_module_strings['LBL_SALES_STAGES'];?></td>
 180  <td valign='top' ><select name="pbss_sales_stages[]" multiple size='3'><?php echo get_select_options_with_id($comboFieldArray['sales_stage_dom'],$_SESSION['pbss_sales_stages']); ?></select></td>
 181  </tr><tr>
 182  <td valign='top' nowrap><?php echo $current_module_strings['LBL_USERS'];?></td>
 183  <td valign='top' ><select name="pbss_ids[]" multiple size='3'><?php echo get_select_options_with_id(get_user_array(false),$_SESSION['pbss_ids']); ?></select></td>
 184  </tr><tr>
 185  <td align="right"><br /> <input class="button" onclick="return verify_chart_data(pipeline_by_sales_stage);" type="submit" title="<?php echo $app_strings['LBL_SELECT_BUTTON_TITLE']; ?>" accessKey="<?php echo $app_strings['LBL_SELECT_BUTTON_KEY']; ?>" value="<?php echo $app_strings['LBL_SELECT_BUTTON_LABEL']?>" /></td>
 186  </tr></table>
 187  </form>
 188  <script type="text/javascript">
 189  Calendar.setup ({
 190      inputField : "date_start", ifFormat : "<?php echo $cal_dateformat ?>", showsTime : false, button : "date_start_trigger", singleClick : true, step : 1
 191  });
 192  Calendar.setup ({
 193      inputField : "date_end", ifFormat : "<?php echo $cal_dateformat ?>", showsTime : false, button : "date_end_trigger", singleClick : true, step : 1
 194  });
 195  </script>
 196  
 197  <?php } 
 198  else {
 199      if (file_exists($tmp_dir.$cache_file_name)) {
 200          $file_date = getDisplayDate(date('Y-m-d H:i', filemtime($tmp_dir.$cache_file_name)));
 201      }
 202      else {
 203          $file_date = '';
 204      }
 205  ?>
 206  <div align=right><FONT size='1'>
 207  <em><?php  echo $current_module_strings['LBL_CREATED_ON'].' '.$file_date; ?> 
 208  </em>[<a href="javascript:;" onClick="changeView('DashboardHome','NORMAL');"><?php echo $current_module_strings['LBL_REFRESH'];?></a>]
 209  [<a href="index.php?module=<?php echo $currentModule;?>&action=index&pbss_edit=true"><?php echo $current_module_strings['LBL_EDIT'];?></a>]
 210  </FONT></div>
 211  <?php }
 212  }
 213  else
 214  {
 215      echo $mod_strings['LBL_NO_PERMISSION'];
 216  } 
 217  //echo get_validate_chart_js();
 218  ?>


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