TUTOS PHP Cross Reference Groupware Applications

Source: /php/sales_forecast.php - 732 lines - 26364 bytes - Summary - Text - Print

Description: Copyright 1999 - 2013 by Gero Kohnert well, copyright? Inspired by Gero, This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

   1  <?php
   2  /**
   3   * Copyright 1999 - 2013 by Gero Kohnert
   4   * well, copyright? Inspired by Gero,
   5   *
   6   *  This program is free software; you can redistribute it and/or modify it
   7   *  under the terms of the GNU General Public License as published by the
   8   *  Free Software Foundation; version 2 of the License.
   9   *
  10   *  SVN Info  $Id: sales_forecast.php 1121 2013-08-04 12:51:03Z gokohnert $
  11   *  $Author: gokohnert $
  12   *
  13   * @modulegroup product
  14   * @module sales_forecast
  15   * @package product
  16   *
  17   * shamelessly copied and mutulated by J. Baten
  18   * This should turn out to be a salesforecast report
  19   * Multiply price * probability = balanced sales amount
  20   * if chances are estimated correctly this should give you
  21   * a good impression of future sales.
  22   * version 1.1 d.d. 01032002 J. Baten initial version. far from finished.
  23   * version 1.2 d.d. 02032002 J. Baten, fixed the totals at the bottom
  24   * still todo
  25   * -subdivide output in separate months
  26   * -make graph of report (using jpgraph)
  27   */
  28  $tutos['files'][__FILE__] = '$Rev: 1121 $';
  29  
  30  require_once  'webelements.p3';
  31  require_once  'permission.p3';
  32  
  33  // Check if user is allowed to use it
  34  check_user();
  35  
  36  require_once  'appointment.pinc';
  37  require_once  'product.pinc';
  38  require_once  'task.pinc';
  39  require_once  'graphs.pinc';
  40  
  41  loadmodules('product','forecast');
  42  loadlayout();
  43  
  44  /**
  45   * sales forecast
  46   */
  47  class Product_forecast extends layout {
  48      /**
  49       *
  50       */
  51      function footline($periodtotal,$comment = '') {
  52          global $tutos;
  53  
  54          $r = '<tr>';
  55          $cols = 0;
  56          if ($comment != '') {
  57              $comment = '&sum; '.$comment;
  58          }
  59          foreach ($tutos[prodfields] as $c) {
  60              if ($c == 'balanced') {
  61                  if ($cols > 0) {
  62                      $r .= '<td colspan="'. $cols .'">'.$comment.'&nbsp;</td>';
  63                      $comment = '';
  64                  }
  65                  $r .= '<td class="over_r"><b><i>';
  66                  foreach($periodtotal[$c] as $i => $f) {
  67                      $r .= my_number_format($f,2) .' '. htmlspecialchars($i) ."<br />\n";
  68                  }
  69                  $r .= '</i></b></td>';
  70                  $cols = 0;
  71              } else if ($c == 'ework') {
  72                  if ($cols > 0) {
  73                      $r .= '<td colspan="'. $cols .'">'.$comment.'&nbsp;</td>';
  74                      $comment = '';
  75                  }
  76                  $r .= '<td class="over_r"><b><i>';
  77                  $r .= hour_format($periodtotal[$c],2);
  78                  $r .= '</i></b></td>';
  79                  $cols = 0;
  80              } else if ($c == 'bwork') {
  81                  if ($cols > 0) {
  82                      $r .= '<td colspan="'. $cols .'">'.$comment.'&nbsp;</td>';
  83                      $comment = '';
  84                  }
  85                  $r .= '<td class="over_r"><b><i>';
  86                  $r .= hour_format($periodtotal[$c],2);
  87                  $r .= '</i></b></td>';
  88                  $cols = 0;
  89              } else if($this->pshow[$c]) {
  90                  $cols++;
  91              }
  92          }
  93          if ($cols > 0)
  94              $r .= '<td colspan="'. $cols .'">&nbsp;</td>';
  95          $r .= '</tr>';
  96          return $r;
  97      }
  98  
  99      /**
 100       * Display table with product/project info. This is the normal report.
 101       * version: 1.0 date 03022002 J. Baten Seems to be find now.
 102       */
 103      Function info() {
 104          global $lang,$tutos;
 105  
 106          $r = '';
 107          $this->result = $this->dbconn->Exec($this->q);
 108          $plist = array();
 109          $n = $this->result->numrows();
 110          if ( 0 == $n) {
 111              $r .= $this->error($lang['Err0048']);
 112              $this->result->free();
 113              return $r;
 114          }
 115          if ($this->format == "stat" ) {
 116              $r .= $this->statinfo();
 117              $this->result->free();
 118              return $r;
 119          }
 120          if ( $this->format == "image" ) {
 121              $r .= $this->image();
 122              $this->result->free();
 123              return $r;
 124          }
 125          foreach($tutos[currencies] as $c) {
 126              $sum[1][$c] = 0;
 127              $sum[2][$c] = 0;
 128          }
 129          $sum[1][''] = 0;
 130          $sum[2][''] = 0;
 131  
 132          $flds = 0;
 133  
 134          // Make a big array of all visible products
 135          $x = 0;
 136          while ( $x < $n ) {
 137              $p = new product($this->dbconn);
 138              $p->read_result($this->result,$x);
 139              $x++;
 140              if ( ! $p->see_ok() ) {
 141                  unset($p);
 142                  continue;
 143              }
 144              if (! isset ($sum[1][$p->currency])) {
 145                  $sum[1][$p->currency] = 0;
 146                  $sum[2][$p->currency] = 0;
 147              }
 148              $sum[1][$p->currency] += $p->price;
 149              $sum[2][$p->currency] += $p->getBalanced();
 150              $plist[] = &$p;
 151              unset($p);
 152          }
 153          $this->result->free();
 154          $n = count($plist);
 155          if ( 0 == $n) {
 156              $r .= $this->error($lang['Err0048']);
 157              return;
 158          }
 159  
 160          // start the header for the results
 161          $r .= $this->header;
 162          $r .= $this->OverviewTableStart();
 163          $r .= "<thead>\n";
 164          $r .= "<tr>\n";
 165  
 166          foreach ($tutos[prodfields] as $c) {
 167              if ( ($c == 'name') && $this->pshow[$c] ) {
 168                  $r .= $this->orderHeader('',$lang['ProdName'],'');
 169                  $flds++;
 170              }
 171              if ( ($c == 'version') && $this->pshow[$c] ) {
 172                  $r .= $this->orderHeader('',$lang['ProdVersion'],'');
 173                  $flds++;
 174              }
 175              if ( ($c == 'seller') && $this->pshow[$c] ) {
 176                  $r .= $this->orderHeader('',$lang['ProdRole'][4],'');
 177                  $flds++;
 178              }
 179              if ( ($c == 'manager') && $this->pshow[$c] ) {
 180                  $r .= $this->orderHeader('',$lang['ProdRole'][1],'');
 181                  $flds++;
 182              }
 183              if ( ($c == 'customer') && $this->pshow[$c] ) {
 184                  $r .= $this->orderHeader('',$lang['ProdRole'][6],'');
 185                  $flds++;
 186              }
 187              if ( ($c == 'supplier') && $this->pshow[$c] ) {
 188                  $r .= $this->orderHeader('',$lang['ProdRole'][7],'');
 189                  $flds++;
 190              }
 191              if ( ($c == 'reseller') && $this->pshow[$c] ) {
 192                  $r .= $this->orderHeader('',$lang['ProdRole'][8],'');
 193                  $flds++;
 194              }
 195              if ( ($c == 'partner') && $this->pshow[$c] ) {
 196                  $r .= $this->orderHeader('',$lang['ProdRole'][9],'');
 197                  $flds++;
 198              }
 199              if ( ($c == 'desc') && $this->pshow[$c] ) {
 200                  $r .= $this->orderHeader('',$lang['ProdDesc'],'');
 201                  $flds++;
 202              }
 203              if ( ($c == 'desc1') && $this->pshow[$c] ) {
 204                  $r .= $this->orderHeader('',$lang['ProdDesc1'],'');
 205                  $flds++;
 206              }
 207              if ( ($c == 'desc2') && $this->pshow[$c] ) {
 208                  $r .= $this->orderHeader('',$lang['ProdDesc2'],'');
 209                  $flds++;
 210              }
 211              if ( ($c == "cl1") && $this->pshow[$c] ) {
 212                  $r .= $this->orderHeader('',$lang['ProdClass1'],'');
 213                  $flds++;
 214              }
 215              if ( ($c == "cl2") && $this->pshow[$c] ) {
 216                  $r .= $this->orderHeader('',$lang['ProdClass2'],'');
 217                  $flds++;
 218              }
 219              if ( ($c == "state") && $this->pshow[$c] ) {
 220                  $r .=$this-> orderHeader('',$lang['ProdState'],'');
 221                  $flds++;
 222              }
 223              if ( ($c == 'ework') && $this->pshow[$c] ) {
 224                  $r .=$this-> orderHeader('',$lang['TaskVolumeFull'],'');
 225                  $flds++;
 226              }
 227              if ( ($c == 'bwork') && $this->pshow[$c] ) {
 228                  $r .=$this-> orderHeader('',$lang['TimetrackBooked'],'');
 229                  $flds++;
 230              }
 231              if ( ($c == "probability") && $this->pshow[$c] ) {
 232                  $r .= $this->orderHeader('',$lang['ProdProb'],'');
 233                  $flds++;
 234              }
 235              if ( ($c == "price") && $this->pshow[$c] ) {
 236                  $r .= $this->orderHeader('',$lang['ProdPrice'],'');
 237                  $flds++;
 238              }
 239              if ( ($c == "cost") && $this->pshow[$c] ) {
 240                  $r .= $this->orderHeader('',$lang['ProdCost'],'');
 241                  $flds++;
 242              }
 243              if ( ($c == "creator") && $this->pshow[$c] ) {
 244                  $r .= $this->orderHeader('',$lang['ProdCreator'],$this->link2);
 245                  $flds++;
 246              }
 247              if ( ($c == "creation") && $this->pshow[$c] ) {
 248                  $r .= $this->orderHeader("creation",$lang['ProdCreationS'],$this->link2);
 249                  $flds++;
 250              }
 251              if ( ($c == "p_start") && $this->pshow[$c] ) {
 252                  $r .= $this->orderHeader('',$lang['ProdStart'],'');
 253                  $flds++;
 254              }
 255              if ( ($c == "p_end") && $this->pshow[$c] ) {
 256                  $r .= $this->orderHeader('',$lang['ProdEnd'],'');
 257                  $flds++;
 258              }
 259              if ( ($c == "balanced") && $this->pshow[$c] ) {
 260                  $r .= $this->orderHeader('',$lang['SalesBalanced'],'');
 261                  $flds++;
 262              }
 263              if ( $this->user->feature_ok(usebugtracking,PERM_SEE) ) {
 264                  if ( ($c == "pbugs") && $this->pshow[$c] ) {
 265                      $r .= $this->orderHeader('',$lang['Bugs'],'');
 266                      $flds++;
 267                  }
 268              }
 269          }
 270          $r .= "</tr>\n";
 271          $r .= "</thead>\n";
 272  
 273          $a = 0;
 274          $end = $n;
 275          $line = 0;
 276  
 277          $sumPeriod = array();
 278          $oldperiod = '';
 279          $oldfiscalyear = '';
 280          $notthefirst=false;
 281          $fiscalswitch=false;
 282          // start the main body with the results
 283  
 284          while ( ($a < $n) && ($a < $end) ) {
 285              $p = &$plist[$a];
 286              $p->readroles();
 287  
 288              // read the task and timtrack info
 289              task_calc($p);
 290              $p->readTimetrackSum();
 291  
 292              // here we select the period to display
 293              $period=$p->p_end->month.'/'.$p->p_end->year;
 294              if ( $period == "-1/-1" ) {
 295                  $period=$lang['UndefinedEndDate'];
 296                  $fiscalyear = -1;
 297              } else {
 298                  $fiscalyear = $p->p_end->fiscalYear();
 299              }
 300              // a new fiscal year starts
 301              if ($fiscalyear != $oldfiscalyear) {
 302                  $sumPeriod[$fiscalyear] = array();
 303                  $sumPeriod[$fiscalyear]['ework'] = 0;
 304                  $sumPeriod[$fiscalyear]['bwork'] = 0;
 305                  $fiscalswitch = true;
 306              }
 307              // a new timeperiod has started. Let's make a row.
 308              // and if it is not the first header then print a subtotal
 309              if ( $oldperiod != $period ) {
 310                  if ( $notthefirst == true ) {
 311                      $r .= $this->footline($sumPeriod[$oldperiod],$oldperiod);
 312                  }
 313                  $sumPeriod[$period] = array();
 314                  $sumPeriod[$period]['ework'] = 0;
 315                  $sumPeriod[$period]['bwork'] = 0;
 316                  // Print the Headline
 317                  if ($fiscalswitch) {
 318                      // Print the Headline
 319                      if ( ($oldfiscalyear != -1) && $notthefirst)
 320                          $r .= $this->footline($sumPeriod[$oldfiscalyear],$oldfiscalyear);
 321                      if ($fiscalyear != -1)
 322                          $r .= '<tr><td colspan="'. $flds .'" align="center"><h2>'.$fiscalyear."</h2></td></tr>\n";
 323                  }
 324                  $r .= '<tr><td colspan="'. $flds .'" align="left"><h2>'.$period."</h2></td></tr>\n";
 325                  $fiscalswitch  = false;
 326                  $notthefirst   = true;
 327                  $oldperiod     = $period;
 328                  $oldfiscalyear = $fiscalyear;
 329              } // periodswitch
 330  
 331              if (!isset($sumPeriod[$period]['balanced'][$p->currency])) {
 332                  $sumPeriod[$period]['balanced'][$p->currency] = 0;
 333              }
 334              if (!isset($sumPeriod[$fiscalyear]['balanced'][$p->currency])) {
 335                  $sumPeriod[$fiscalyear]['balanced'][$p->currency] = 0;
 336              }
 337              $sumPeriod[$period]['balanced'][$p->currency] += $p->getBalanced();
 338              $sumPeriod[$fiscalyear]['balanced'][$p->currency] += $p->getBalanced();
 339  
 340              $r .= $this->OverviewRowStart($line);
 341              #            $r .= $period.' '.$sumPeriod[$period]['balanced'][$p->currency].'<br>';
 342              foreach ($tutos[prodfields] as $c) {
 343                  // projectname
 344                  if ( ($c == "name") && $this->pshow[$c] ) {
 345                      $b = $p->name;
 346                      if (! $this->pshow['version']) {
 347                          $b .= ' '.$p->version;
 348                      }
 349                      $r .= '  <td class="over_l">';
 350                      $r .= makelink($p->getUrl(),$this->mark_filter(myentities($b),'name'));
 351                      $r .= "</td>\n";
 352                  }
 353                  if ( ($c == 'version') && $this->pshow[$c] ) {
 354                      $r .= '  <td class="over_l">';
 355                      $r .= $this->mark_filter(myentities($p->version),'name');
 356                      $r .= "</td>\n";
 357                  }
 358  
 359                  // Customer
 360                  if ( ($c == "customer") && $this->pshow[$c] ) {
 361                      $r .= "  <td valign=\"top\">\n &nbsp;";
 362                      if (isset($p->role[6]) && (count($p->role[6]) > 0) ) {
 363                          $x = 0;
 364                          foreach ($p->role[6] as $r ) {
 365                              if ( $x > 0 ) {
 366                                  $r .= "<br />\n &nbsp;";
 367                              }
 368                              $r .=  $r->getLink();
 369                              $x++;
 370                          }
 371                      }
 372                      $r .= "  </td>\n";
 373                  }
 374  
 375                  // someone forget to say 'description' here :-)
 376                  if ( ($c == "desc") && $this->pshow[$c] ) {
 377                      $r .= '  <td class="over_l">';
 378                      $r .= $this->mark_filter(myentities($p->description),'name');
 379                      $r .= "</td>\n";
 380                  }
 381  
 382                  // state
 383                  if ( ($c == 'state') && $this->pshow[$c] ) {
 384                      $r .= '  <td class="over_l">'. $p->getStateColorBlock().$p->getState() ."</td>\n";
 385                  }
 386                  // expected work
 387                  if ( ($c == 'ework') && $this->pshow[$c] ) {
 388                      $r .= '  <td class="over_r">'. hour_format($p->sum['volume']) ."</td>\n";
 389                      $sumPeriod[$period][$c] += $p->sum['volume'];
 390                      $sumPeriod[$fiscalyear][$c] += $p->sum['volume'];
 391                  }
 392                  // booked work
 393                  if ( ($c == 'bwork') && $this->pshow[$c] ) {
 394                      $timesum = $p->timetracksum;
 395                      foreach ($p->tsum as $i => $f) {
 396                          $timesum += $p->tsum[$i];
 397                      }
 398                      $r .= '  <td class="over_r">'. hour_format($timesum) ."</td>\n";
 399                      $sumPeriod[$period][$c] += $timesum;
 400                      $sumPeriod[$fiscalyear][$c] += $timesum;
 401                  }
 402  
 403                  // probability (mucho importante)
 404                  if ( ($c == "probability") && $this->pshow[$c] ) {
 405                      $r .= '  <td class="over_r">'. $p->probability ."%</td>\n";
 406                  }
 407                  // price (also mucho importante)
 408                  if ( ($c == "price") && $this->pshow[$c] ) {
 409                      $r .= '  <td class="over_r">'. my_number_format($p->price,2) .' '. htmlspecialchars($p->currency) ."</td>\n";
 410                  }
 411                  // price (also mucho importante)
 412                  if ( ($c == "cost") && $this->pshow[$c] ) {
 413                      $r .= '  <td class="over_r">'. my_number_format($p->cost,2) .' '. htmlspecialchars($p->currency) ."</td>\n";
 414                  }
 415                  // balanced result
 416                  if ( ($c == "balanced") && $this->pshow[$c] ) {
 417                      $r .= '  <td class="over_r">'. my_number_format($p->getBalanced(),2) .' '. htmlspecialchars($p->currency) ."</td>\n";
 418                  }
 419                  // start date
 420                  if ( ($c == "p_start") && $this->pshow[$c] ) {
 421                      $r .= '  <td class="over_l">'. $p->p_start->getLinkDate() ."</td>\n";
 422                  }
 423                  // end date
 424                  if ( ($c == "p_end") && $this->pshow[$c] ) {
 425                      $r .= '  <td class="over_l">'. $p->p_end->getLinkDate() ."</td>\n";
 426                  }
 427              }
 428              $r .= $this->OverviewRowEnd($line++);
 429              unset($plist[$a]);
 430              unset($p);
 431              $a++;
 432          }
 433          // finalize the last running period
 434          $r .= $this->footline($sumPeriod[$period],$period);
 435          // finalize the last running fiscalyear
 436          $r .= $this->footline($sumPeriod[$fiscalyear],$fiscalyear);
 437  
 438  
 439          $r .= $this->list_navigation($this->link1,$flds,$this->start,$a,$n);
 440  
 441          // Sums of amounts
 442          if ( ($this->pshow['price'] == 1) || ($this->pshow['balanced'] == 1) ) {
 443              $r .= "<tr>\n";
 444              $fill = 0;
 445              foreach ($tutos[prodfields] as $c) {
 446                  if (  $this->pshow[$c] == 0 ) {
 447                      continue;
 448                  }
 449                  // display total sum of price
 450                  if ( $c == "price" ) {
 451                      if ( $fill > 0 ) {
 452                          $r .= ' <td colspan="'. $fill ."\">&nbsp;</td>\n";
 453                          $fill = 0;
 454                      }
 455                      $r .= " <td class=\"over_r\">\n";
 456                      $pre = "";
 457                      foreach ( $sum[1] as $i1 => $f1 ) {
 458                          if ( $f1 ) {
 459                              $r .= $pre . my_number_format($f1,2) .' '. $i1;
 460                              $pre = "<br />\n";
 461                          }
 462                      }
 463                      $r .= " </td>\n";
 464                  } else if ( $c == "balanced" ) {
 465                      // display total sum of balanced
 466                      if ( $fill > 0 ) {
 467                          $r .= ' <td colspan="'. $fill ."\">&nbsp;</td>\n";
 468                          $fill = 0;
 469                      }
 470                      $r .= " <td class=\"over_r\">\n";
 471                      $pre = "";
 472                      foreach ( $sum[2] as $i1 => $f1 ) {
 473                          if ( $f1 ) {
 474                              $r .= $pre . my_number_format($f1,2) .' '. $i1;
 475                              $pre = "<br />\n";
 476                          }
 477                      }
 478                      $r .= " </td>\n";
 479                  } else {
 480                      $fill++;
 481                  }
 482              }
 483              if ( $fill > 0 ) {
 484                  $r .= ' <td colspan="'. $fill ."\">&nbsp;</td>\n";
 485              }
 486              $r .= "</tr>\n";
 487          }
 488  
 489          $r .= $this->OverviewTableEnd();
 490          return $r;
 491      }
 492  
 493      /**
 494       * version 1.0 date 03032002 initial version
 495       * This procedure makes a graphic display of the information.
 496       * since I can't use jpgrapg to make an inline graphic, I just
 497       * call myself as an image... :-) cute no?
 498       */
 499      Function statinfo() {
 500          global $lang,$tutos;
 501  
 502          $r = '';
 503  
 504          $sbar = array();
 505          $sbar['title']  = $lang['SalesForecastRep'];
 506          $sbar['ytitle'] = $lang['Est_revenue'];
 507          $sbar['xtitle'] = $lang['Period'];
 508  
 509          $n = $this->result->numrows();
 510          $a = 0;
 511          $sum = array();
 512          while ( $a < $n ) {
 513              $p = new product($this->dbconn);
 514              $p->read_result($this->result,$a);
 515              // here we select the period to display
 516              $m=$p->p_end->month;
 517              $y=$p->p_end->year;
 518              $period= $m."/".$y;
 519              if ( $period == "-1/-1" ) {
 520                  $period=$lang['UndefinedEndDate'];
 521              }
 522              if (!isset($sum[$period])) $sum[$period] = 0.0;
 523              $sum[$period] += $p->getBalanced();
 524              $a++;
 525          }
 526          foreach ($sum as $i => $s) {
 527              $sbar['data'][] = array('val' => $s ,'cnt' => $s,'title' => $i);
 528          }
 529  
 530          $r .= bar($sbar);
 531  
 532          return $r;
 533      }
 534  
 535      /**
 536       * this function is used by the above mentioned function
 537       */
 538      Function image() {
 539          global $lang,$tutos;
 540  
 541          if (!load_jpgraph( array("jpgraph_gantt.php","jpgraph_bar.php") )) {
 542              return;
 543          }
 544          // add a temporary field
 545          // now where can I put the above extension?
 546  
 547          $n = $this->result->numrows();
 548          $a = 0;
 549          $cnt = 0;
 550          $notthefirst=false;
 551          $sumperiodtotal=0;
 552          $datax=array();
 553          $datay1=array();
 554          $datay2=array();
 555          $sumPeriod = array();
 556          $oldperiod = "";
 557          while ( $a < $n ) {
 558              $p = new product($this->dbconn);
 559              $p->read_result($this->result,$a);
 560              #$p->readroles();
 561              $cnt++;
 562              // here we select the period to display
 563              $m=$p->p_end->month;
 564              $y=$p->p_end->year;
 565              $period= $m."/".$y;
 566              if ( $period == "-1/-1" ) {
 567                  $period=$lang['UndefinedEndDate'];
 568              }
 569              // a new timeperiod has started. Let's make a row.
 570              // and if it is not the first header then print a subtotal
 571              if ( $oldperiod != $period ) {
 572                  if ( $notthefirst == true ) {
 573                      array_push($datax,$oldperiod);
 574  
 575                      $periodtotal=$sumPeriod[$oldperiod];
 576                      array_push($datay1,$periodtotal);
 577  
 578                      $sumperiodtotal+=$periodtotal;
 579                      array_push($datay2,$sumperiodtotal);
 580  
 581                      $sumPeriod[$period]=0;
 582                  }
 583                  $notthefirst=true;
 584              }
 585              $oldperiod=$period;
 586              if (isset($sumPeriod[$period])) {
 587                  $sumPeriod[$period]+=$p->getBalanced();
 588              } else {
 589                  $sumPeriod[$period]= $p->getBalanced();
 590              }
 591              #unset($p);
 592              $a++;
 593          }
 594          // let's get the last values...
 595          array_push($datax,$oldperiod);
 596  
 597          $periodtotal=$sumPeriod[$oldperiod];
 598          array_push($datay1,$periodtotal);
 599  
 600          $sumperiodtotal+=$periodtotal;
 601          array_push($datay2,$sumperiodtotal);
 602  
 603          $graph = new Graph(600,400,"auto");
 604          $graph->img->SetMargin(90,40,40,40);
 605          $graph->SetScale("textlin");
 606          #    $graph->SetShadow();
 607          $graph->title->Set($lang['SalesForecastRep']);
 608          $graph->title->SetFont(FF_FONT1,FS_BOLD);
 609  
 610          $graph->xaxis->title->Set($lang['Period']);
 611          $graph->xaxis->SetTickLabels($datax);
 612          $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
 613  
 614          $graph->yaxis->title->Set($lang['Est_revenue']);
 615          $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
 616          $graph->yaxis->SetTitleMargin(65);
 617  
 618          $p1 = new BarPlot($datay2);
 619          $p1->SetFillColor("orange");
 620          $p1->SetLegend($lang['AccumulatedRevenue']);
 621  
 622          $p2 = new BarPlot($datay1);
 623          $p2->SetFillColor("blue");
 624          $p2->SetWidth(1.0);
 625          #     $p2->SetValueFormat("%0d");
 626          #     $p2->ShowValue();
 627          $p2->SetLegend($lang['PeriodRevenue']);
 628  
 629          // Create the grouped bar plot
 630          $plot = new AccBarPlot(array($p1,$p2));
 631          $plot->SetShadow();
 632  
 633          $graph->Add($plot);
 634          $graph->Stroke();
 635      }
 636  
 637      /**
 638       * prepare
 639       */
 640      Function prepare() {
 641          global $msg,$tutos,$lang;
 642  
 643          $this->layout_id = useprojects;
 644          $this->name = $lang['SalesForecastRep'];
 645          $this->css_class = 'overviewbox';
 646  
 647  
 648          if ( ! $this->user->feature_ok(useprojects,PERM_SEE) ) {
 649              $msg .= sprintf($lang['Err0022'],"'". $this->name ."'");
 650              $this->stop = true;
 651              return;
 652          }
 653  
 654          $this->link1 = 'sales_forecast.php';
 655          $this->link3 = 'product_overview.php';
 656          if (isset($_GET['ext'])) {
 657              $this->ext = $_GET['ext'];
 658              $this->link1 = addUrlParameter($this->link1,"ext=".$this->ext);
 659              $this->link3 = addUrlParameter($this->link3,"ext=".$this->ext);
 660          } else {
 661              $this->ext = 2;
 662          }
 663  
 664  
 665  
 666          $this->pshow = array();
 667          $tutos[prodfields][] = 'balanced';
 668          $tutos[prodfields][] = 'ework';
 669          $tutos[prodfields][] = 'bwork';
 670          foreach ($tutos[prodfields] as $c) {
 671              $this->pshow[$c] = 0;
 672          }
 673          $this->pshow['name']         = 1;
 674          $this->pshow['customer']     = 1;
 675          $this->pshow['desc']         = 1;
 676          $this->pshow['cost']         = 1;
 677          $this->pshow['price']        = 1;
 678          $this->pshow['probability']  = 1;
 679          $this->pshow['state']        = 1;
 680          $this->pshow['ework']        = 1;
 681          $this->pshow['bwork']        = 1;
 682          $this->pshow['p_start']      = 1;
 683          $this->pshow['p_end']        = 1;
 684          $this->pshow['balanced']     = 1;
 685  
 686          prepare_product_overview($this);
 687  
 688          $this->q .= " ORDER by p_end ASC";
 689  
 690          $x = product::getSelectLink($this->user,$lang['Search']);
 691          $x[category][] = 'obj';
 692          $this->addMenu($x);
 693  
 694          if ( $this->user->feature_ok(useprojects,PERM_NEW) ) {
 695              $x = array( url => 'product_new.php',
 696                          text => $lang['NewEntry'],
 697                          info => $lang['ProdCreateInfo'],
 698                          category => array('product','new','obj',useprojects)
 699                  );
 700              $this->addMenu($x);
 701          }
 702  
 703          $x = array( url => addUrlParameter($this->link1,"format=paper"),
 704                      text => $lang['Printable'],
 705                      info => $lang['PrintableInfo'],
 706                      category => array('print','product','view',useprojects)
 707              );
 708          $this->addMenu($x);
 709  
 710          if ( $this->format != "stat" ) {
 711              $x = array( url => addUrlParameter($this->link1,"format=stat"),
 712                          text => $lang['Graph'],
 713                          info => $lang['GraphInfo'],
 714                          category => array('graph','product','view',useprojects)
 715                  );
 716              $this->addMenu($x);
 717          }
 718  
 719          if (class_exists('url')) {
 720              $this->addMenu(url::getAddLinkPreset($this->user,$this));
 721          }
 722      }
 723  }
 724  
 725  $l = new Product_forecast($current_user);
 726  $l->display();
 727  $dbconn->Close();
 728  ?>
 729  <!--
 730  SVN Info  $Id: sales_forecast.php 1121 2013-08-04 12:51:03Z gokohnert $
 731  $Author: gokohnert $
 732  -->

title

Description

title

Description

title

Description

title

title

Body