TUTOS PHP Cross Reference Groupware Applications

Source: /php/rate/rate.pinc - 821 lines - 24720 bytes - Summary - Text - Print

Description: Copyright 1999 - 2013 by Gero Kohnert and ecosoft

   1  <?php
   2  /**
   3   *  Copyright 1999 - 2013 by Gero Kohnert and ecosoft
   4   *
   5   *  This program is free software; you can redistribute it and/or modify it
   6   *  under the terms of the GNU General Public License as published by the
   7   *  Free Software Foundation; version 2 of the License.
   8   *
   9   *  SVN Info $Id: rate.pinc 1143 2013-08-19 05:52:12Z gokohnert $
  10   *  $Author: gokohnert $
  11   */
  12  $tutos['files'][__FILE__] = '$Rev: 1143 $';
  13  
  14  /* ---------------------------------------------------------------------------
  15   * List all rates
  16   * cols > 0  make sperate rows with cols columns for each rate
  17   */
  18  function showRates(tutos_user $user,tutos_base $obj,$rows = 0) {
  19      global $tutos,$lang;
  20  
  21      $r = '';
  22      $n = 1;
  23      $x = count($obj->list[userates]);
  24      if ( $rows == 0 ) {
  25          $rows = $tutos['maxshort'];
  26      }
  27      if ( $rows == -1 ) {
  28          $rows = $x;
  29      }
  30      foreach ($obj->list[userates] as $f) {
  31          if ( ($n >= $rows) && ( $x != $rows ) ) {
  32              $r .=  '  '. $user->layout->theme->getImage(folder,'list') .' '. makelink('rate/rate_overview.php?link_id='. $obj->id,sprintf($lang['AllEntries'], $x));
  33              break;
  34          }
  35          $r .= '  '. $user->layout->theme->getImage(rate::getHtmlIcon(),'list') .' '. $f->getLink() .' '. my_number_format($f->cph,2) .' '. $f->currency .' ('. (is_object($f->worker) ? $f->worker->getLink():$lang['HistoryDeleted']) .")<br />\n";
  36          $n++;
  37      }
  38      return $r;
  39  }
  40  
  41  /**
  42   * a rate , attachable nearly everywhere in TUTOS
  43   *
  44   * @package rate
  45   */
  46  class Rate extends tutos_module {
  47      /**
  48       * URL to use for modify this object
  49       */
  50      protected $modurl  = 'rate/rate_new.php';
  51      /**
  52       * URL to use for display this object
  53       */
  54      protected $showurl = 'rate/rate_show.php';
  55      /**
  56       * revision of file
  57       */
  58      static public $revision = '$Rev: 1143 $';
  59  
  60      /**
  61       * constructor
  62       */
  63      function rate(tutos_db $dbconn) {
  64          global $tutos,$current_user,$table;
  65  
  66          $this->init($dbconn);
  67  
  68          $this->link_id   = $current_user->id;
  69          $this->worker    = $current_user->id;
  70          $this->name      = '';
  71          $this->priority  = 0;
  72          $this->cph       = 0.0;
  73          $this->currency  = $tutos[currencies][0];
  74          $this->vat       = 0.0;
  75          $this->role_id   = 1;
  76          $this->state     = -1;
  77          $this->tablename = $this->dbconn->prefix .$table['rate'][name];
  78  
  79          $this->acl_raise($current_user->id,$tutos[modok]);
  80          $this->run_postinit_hook();
  81      }
  82  
  83      /**
  84       * fill the object data with a given resultset
  85       *
  86       * @param Object $r    a result set object
  87       * @param int    $pos  a index in the resultset
  88       */
  89      function read_result (result $r, $pos ) {
  90          $this->link_id     = $r->get($pos, "link_id");
  91  
  92          $s =  $r->get($pos, "worker");
  93          $this->worker = getObject($this->dbconn,$s);
  94          // Check for unfilled worker
  95          if ( !is_object($this->worker) ) {
  96              // set default
  97              $this->worker = $this->creator;
  98          }
  99          if ( is_object($this->worker) && ($this->worker->gettype() == "team") ) {
 100              $this->worker->read_member();
 101          }
 102  
 103          $this->name        = $r->get($pos, "name");
 104          $this->priority    = $r->get($pos, "priority");
 105          $this->cph         = $r->get($pos, "cph");
 106          $this->currency    = $r->get($pos, "currency");
 107          $this->vat         = $r->get($pos, "vat");
 108          $this->role_id     = $r->get($pos, "role_id");
 109          $this->state       = $r->get($pos, "state");
 110  
 111          $this->creator     = getObject($this->dbconn,$r->get($pos, "creator"));
 112  
 113          parent::read_result($r,$pos);
 114          return;
 115      }
 116  
 117      /**
 118       * get a list of possible new parents
 119       */
 120      function read_relations ( ) {
 121          global $lang;
 122  
 123          $this->plist = array();
 124          if (is_object($this->ref)) {
 125              // Read possible new parents
 126              $this->plist = $this->ref->getNeighbours();
 127          }
 128      }
 129  
 130      /**
 131       * read the linked object
 132       */
 133      function read_reference () {
 134          if ( $this->link_id == -1 ) return;
 135          if ( empty($this->link_id) ) return;
 136  
 137          $this->ref = getObject($this->dbconn,$this->link_id);
 138          if ( !is_object($this->ref) ) {
 139              $this->ref = $this->creator;
 140          }
 141          return;
 142      }
 143  
 144      /**
 145       * Return a link to the reference
 146       */
 147      function getRefLink($text = "") {
 148          if ( isset($this->ref) ) {
 149              return $this->ref->getLink();
 150          }
 151          return "no link";
 152      }
 153  
 154      /**
 155       * added by J. Baten
 156       */
 157      function formatted (layout $ly) {
 158          return '<tr><td colspan="3" class="rate">'. $this->getLink() ."</td></tr>\n";
 159      }
 160  
 161      /**
 162       * Popup for rates
 163       */
 164      function getPopInfo() {
 165          global $lang;
 166  
 167          $this->read_reference();
 168  
 169          $n =str_replace("\n","<br />",myentities(my_number_format($this->cph,2).' '. $this->currency));
 170          $n =str_replace("\r","",$n);
 171          $n =str_replace("\\","\\\\",$n);
 172  
 173          $t =myentities($this->name);
 174          $t =str_replace("\\","\\\\",$t);
 175  
 176          $h = $this->ref->getFullName();
 177          $h = preg_replace('#\r\n#',' ',$h);
 178  
 179          $info = '';
 180          $info .= '<table class="popupinfo">';
 181          $info .= '<tr><th>'. $lang[$this->ref->getType()] .' '. $h .'  &#8594; '. $t  .'</th></tr>';
 182          $info .= '<tr><td><pre>';
 183          $info .= $n;
 184          $info .= '</pre></td></tr>';
 185          $info .= $this->custom_popup_content();
 186          $info .= '</table>';
 187          return $info;
 188      }
 189  
 190      /**
 191       * the url where we go after deleting this object
 192       */
 193      function get_after_del_url () {
 194          $this->read_reference();
 195          return $this->ref->getUrl();
 196      }
 197  
 198      /**
 199       * the url where we when deleting fails
 200       */
 201      function get_failed_del_Url () {
 202          if ($this->see_ok()) {
 203              return $this->getUrl();
 204          }
 205          $this->read_reference();
 206          return $this->ref->getUrl();
 207      }
 208  
 209      /**
 210       *  Return a fullname
 211       */
 212      function getFullname() {
 213          global $lang;
 214  
 215          return $this->name;
 216      }
 217  
 218      /**
 219       * Return a link to this rate
 220       */
 221      function getLink($text = '') {
 222          global $lang;
 223  
 224          if ( empty($text) ) {
 225              $text = myentities($this->getFullName());
 226          }
 227  
 228          if (is_object($this->creator)) {
 229              $newcreator = $this->creator->getFullName();
 230          } else {
 231              $newcreator = $lang['HistoryDeleted'];
 232          }
 233  
 234          if ( $this->see_ok() ) {
 235              return makelink($this->getURL() ,$text,sprintf($lang['RateLinkInfo'], $newcreator),$this->getPopInfo(),'',$this->id);
 236          } else {
 237              return $text;
 238          }
 239      }
 240  
 241      /**
 242       * get current state of this rate (default) as HTML
 243       */
 244      function getState ($s = "") {
 245          global $lang;
 246  
 247          if ( ! empty($s) ) {
 248              return $lang['TTStates'][$s];
 249          }
 250          return $lang['TTStates'][$this->state];
 251      }
 252  
 253      /**
 254       * get role of this rate's worker
 255       */
 256      function getRole ($s = "") {
 257          global $lang;
 258  
 259          if ( ! empty($s) ) {
 260              return ''. $lang['ProdRole'][$s] .'';
 261          }
 262          return ''. $lang['ProdRole'][$this->role_id] .'';
 263      }
 264  
 265      /**
 266       * set the rate name
 267       */
 268      function setName($value) {
 269          return $this->setStrField('name',$value,'RateName');
 270      }
 271  
 272      /**
 273       * set the worker
 274       */
 275      function setWorker($name) {
 276          if ( $this->worker != $name ) {
 277              $this->modified[] = array ( 'field' => 'RateWorkerReference', 'old' => $this->worker , 'new' => $name );
 278              $this->worker = $name;
 279          }
 280          return;
 281      }
 282  
 283      /**
 284       * set the reference
 285       */
 286      function setReference($name) {
 287          if ( $this->link_id != $name ) {
 288              $this->modified[] = array ( 'field' => 'RateReference', 'old' => $this->link_id , 'new' => $name );
 289              $this->link_id = $name;
 290          }
 291          return;
 292      }
 293  
 294      /**
 295       * set the costs per hour
 296       */
 297      function setCph($value) {
 298          $this->setFloatField('cph',$value,'Rate');
 299          return;
 300      }
 301  
 302      /**
 303       * set the currency
 304       */
 305      function setCurrency($value) {
 306          $this->setStrField('currency',$value,'currency');
 307          return;
 308      }
 309  
 310      /**
 311       * set the priority
 312       */
 313      function setPriority($value) {
 314          $this->setIntField('priority',$value,'RatePriority');
 315          return;
 316      }
 317  
 318      /**
 319       * set the value added tax
 320       */
 321      function setVat($value) {
 322          $this->setFloatField('vat',$value,'RateVat');
 323          return;
 324      }
 325  
 326      /**
 327       * set the state
 328       */
 329      function setState($value) {
 330          $this->setIntField('state',$value,'TTState');
 331          return;
 332      }
 333  
 334      /**
 335       * set the role
 336       */
 337      function setRole($value) {
 338          $this->setIntField('role_id',$value,'RateRole');
 339          return;
 340      }
 341  
 342      /**
 343       * Save RATE to DB
 344       */
 345      function save() {
 346          global $current_user, $tutos,$table;
 347  
 348          $msg = $this->run_presave_hook();
 349  
 350          if ( $this->link_id == -1 ) {
 351              $this->ref = $this->creator;
 352              $this->link_id = $this->creator->id;
 353          }
 354          $q = new query($this->dbconn);
 355          $q->setTable($this->tablename);
 356          $q->addFV('link_id',$this->link_id,'INT');
 357          $q->addFV('worker',$this->worker,'INT');
 358          $q->addFV('name',$this->name,'STRING');
 359          $q->addFV('priority',$this->priority,'INT');
 360          $q->addFV('cph',$this->cph,'FLOAT');
 361          $q->addFV('currency',$this->currency,'STRING',4);
 362          $q->addFV('vat',$this->vat,'FLOAT');
 363          $q->addFV('role_id',$this->role_id,'INT');
 364          $q->addFV('state',$this->state,'INT');
 365          $this->save_custom_fields($q);
 366  
 367          if ( $this->id < 0 ) {
 368              $this->modified = array();
 369              if ( isset($this->newid) ) {
 370                  $this->id = $this->newid;
 371                  $q->addFV("id",$this->id,"");
 372              } else {
 373                  $this->id = $q->addFV("id",-1,"NEXTID");
 374                  // adopt the permissions from the referenced object
 375                  $this->copy_acl($this->ref,true);
 376                  $this->acl_default();
 377  
 378                  // Prepare the history
 379                  $this->modified[] = array ( 'field' => 'RateCreate',
 380                                              'old' => '-1' ,
 381                                              'new' => $this->id,
 382                                              'obj_id' => $this->link_id
 383                      );
 384                  $this->modified[] = array ( 'field' => 'created',
 385                                              'old' => $this->getType() ,
 386                                              'new' => $this->id,
 387                                              'obj_id' => $this->id
 388                      );
 389              }
 390              $q->addFV('creator',$this->creator,'OBJ');
 391              $q->addFV('creation',$this->creation,'DATETIME');
 392              $query = $q->getInsert();
 393          } else {
 394              $q->addWC('id',$this->id,'');
 395              $query = $q->getUpdate();
 396          }
 397  
 398          $r = $this->dbconn->Exec($query);
 399          $r->free();
 400  
 401          $msg = addLine($msg,parent::save());
 402          return $msg;
 403      }
 404  
 405      /**
 406       * Transfer reference ids according to given table
 407       */
 408      function transfer_ids (&$trans) {
 409          parent::transfer_ids ($trans);
 410          if (isset($trans[$this->link_id])) {
 411              $this->link_id = $trans[$this->link_id];
 412          }
 413          if (isset($trans[$this->creator->id])) {
 414              $this->creator->id = $trans[$this->creator->id];
 415          }
 416          return;
 417      }
 418  
 419      /**
 420       * Export as XML
 421       */
 422      function exportXML () {
 423          $r = $this->exportXML_head() ;
 424          $r .=  $this->exportXML_start();
 425          $r .= " <name>". $this->name ."</name>\n";
 426          $r .=  $this->exportXML_end();
 427          return $r;
 428      }
 429  
 430      /**
 431       * get the type of object
 432       */
 433      static function gettype () {
 434          return 'rate';
 435      }
 436  
 437      /**
 438       * get the type id of object
 439       */
 440      static function gettypeid () {
 441          return userates;
 442      }
 443  
 444      /**
 445       * get name of icons
 446       */
 447      static function getHtmlIcon () {
 448          return 'rates';
 449      }
 450  
 451      /**
 452       * resolve a history Tag (to be called from history_show)
 453       */
 454      function resolveHistoryTag ($f) {
 455          global $lang;
 456  
 457          $x = null;
 458          switch ($f['field']) {
 459          case 'RateWorkerReference':
 460              $x = resolve_history_obj($f,$this->dbconn);
 461              break;
 462          case 'RateRole':
 463              $x = resolve_history_lgarr ($f,'ProdRole');
 464              break;
 465  
 466          }
 467          return $x;
 468      }
 469  
 470      /**
 471       * a obj form is submitted
 472       * parse the values
 473       */
 474      function parseform (tutos_user $user,tutos_base $obj,&$gotourl) {
 475          global $lang;
 476  
 477          if ( $obj->gettype() != "timetrack") {
 478              return;
 479          }
 480          if ( ! $user->feature_ok(userates,PERM_SEE) ) {
 481              return;
 482          }
 483          $msg = "";
 484          if ( isset($_POST['rate']) ) {
 485              $rate = $_POST['rate'];
 486          } else if ( isset($_GET['rate']) )  {
 487              $rate = $_GET['rate'];
 488          } else {
 489              return $msg;
 490          }
 491  
 492          foreach($rate as $i => $f) {
 493              $gotourl= addUrlParameter($gotourl,"rate[]=".$f,true);
 494              $x = new Rate($obj->dbconn);
 495              $x = $x->read($f,$x);
 496              if ( $x->id == $f ) {
 497                  // set the rate in the given object
 498                  if ($obj->gettype() == "timetrack") {
 499                      $obj->setCph($x->cph);
 500                      $obj->setCurrency($x->currency);
 501                      $obj->setState($x->state);
 502                  }
 503              }
 504              unset($x);
 505          }
 506  
 507          return $msg;
 508      }
 509      /**
 510       * a form for obj is displayed
 511       * create a selectionlist of possible rates for the given reference and given user/team
 512       */
 513      function addform (tutos_user $user,tutos_base $obj,$cols) {
 514          global $lang;
 515  
 516          $r = '';
 517          if ( $obj->gettype() != "timetrack") {
 518              return $r;
 519          }
 520          if ( ! $user->feature_ok(userates,PERM_SEE) ) {
 521              return $r;
 522          }
 523          rate::obj_read($obj);
 524          if ( count($obj->list[userates]) < 1 ) {
 525              return $r;
 526          }
 527          $r .= "<tr>\n";
 528          $r .= $user->layout->showfield($lang['Rate'],0,"rate[]");
 529  
 530          $r .= '<td valign="top" colspan="'.($cols-1)."\">\n";
 531          $r .= "<select id=\"rate[]\" name=\"rate[]\" size=\"1\">\n";
 532          #$r .= "<option value=\"keep\">". $obj->cph ." ". $obj->currency ."</option>";
 533          foreach($obj->list[userates] as $i => $f) {
 534              if ($f->use_ok()) {
 535                  $r .= '<option value="'. $f->id .'"';
 536                  if ( $f->cph == $obj->cph && $f->currency == $obj->currency && $f->state == $obj->state) {
 537                      $r .= " selected";
 538                  }
 539                  $r .= '>'. $f->getFullName() .' ('. my_number_format($f->cph,2,$lang['DecPoint'],$lang['ThousandPoint']) ." ". $f->currency .")</option>\n";
 540              }
 541          }
 542          $r .= '<option value="keep">'. $obj->cph .' '. $obj->currency .'</option>';
 543          $r .= "</select>\n";
 544          $r .= "</td>\n";
 545          $r .= "</tr>\n";
 546          return $r;
 547      }
 548      /* ---------------------------------------------------------------------------
 549       * The following methods are abstract factory functions for groups
 550       * which handle the membership list of an object
 551       * --------------------------------------------------------------------------- */
 552      /**
 553       * create a list of rates for the given object and given user
 554       */
 555      static function infolist (tutos_user $user,tutos_base $obj,$cols,$format = "html") {
 556          global $lang;
 557  
 558          $r = '';
 559          if (! is_object($obj) ) return $r;
 560  
 561          if ( ! $user->feature_ok(userates,PERM_SEE) ) return $r;
 562          if ( ! $obj->obj_feature_ok($user,userates,PERM_SEE) ) return $r;
 563  
 564          rate::obj_read($obj);
 565          if ( count($obj->list[userates]) == 0 ) {
 566              return $r;
 567          }
 568          $r .= $user->layout->ContentRowStart();
 569          $r .= $user->layout->showfield($lang['Rates']);
 570          if ( $format == "paper" ) {
 571              $d = showRates($user,$obj,-1);
 572          } else {
 573              $d = showRates($user,$obj);
 574          }
 575          $r .= $user->layout->showdata($d,$cols-1);
 576          $r .= $user->layout->ContentRowEnd();
 577          return $r;
 578      }
 579  
 580      /**
 581       * create a smalllist of rates attached to the given object
 582       */
 583      static function small_infolist (tutos_user $user,tutos_base $obj) {
 584          global $lang;
 585  
 586          $r = '';
 587          if (! is_object($obj) ) return $r;
 588  
 589          if ( ! $user->feature_ok(userates,PERM_SEE) ) {
 590              return $r;
 591          }
 592          rate::obj_read($obj);
 593          if ( count($obj->list[userates]) > 0 ) {
 594              foreach ($obj->list[userates] as $i => $f) {
 595                  $r .= '<br />-' . $f->getLink();
 596              }
 597              unset($f);
 598          }
 599          return $r;
 600      }
 601  
 602      /**
 603       * create a link where a rate to for the given object could be added
 604       */
 605      static function getaddlink (tutos_user $user,tutos_base $obj,$text = "") {
 606          global $lang;
 607  
 608          if (! is_object($obj) ) return '';
 609          if (! $user->feature_ok(userates,PERM_NEW) ) return '';
 610          if (! $obj->obj_feature_ok($user,userates,PERM_NEW) ) return '';
 611          if (! $obj->use_ok() ) return '';
 612  
 613          $x = array( url => 'rate/rate_new.php?link_id='. $obj->id,
 614                      confirm => false,
 615                      text => ($text == "" ? $lang['RateCreate']:$text),
 616                      info => sprintf($lang['RateCreateInfo'], $obj->getFullName()),
 617                      category => array('rate','new','module',userates)
 618              );
 619          return $x;
 620      }
 621  
 622      /**
 623       * Return Info about connected rates to a object
 624       */
 625      static function obj_read(tutos_base $obj) {
 626          global $current_user;
 627  
 628          if (! is_object($obj) ) return;
 629          if ( isset($obj->list[userates]) ) {
 630              return;
 631          }
 632          $obj->list[userates] = array();
 633  
 634          $q = "SELECT * from ". $obj->dbconn->prefix ."rates where link_id in (";
 635  
 636          $pre = "";
 637          if ($obj->gettype() == "timetrack") {
 638              // for timetrack we wil get a list of rates connected to the parent plus some other stuff
 639              if (! is_object($obj->ref)) return;
 640              //link_id = current_user and current_user's teams
 641              $q .= $current_user->id;
 642              $pre = ",";
 643              foreach ( $current_user->teams as $idx => $val ) {
 644                  $q .= $pre . $idx ;
 645                  $pre = ",";
 646              }
 647              $q .= ") ";
 648              //link_id = reference and reference's reference?!?
 649              $q .= "or (link_id in (". $obj->ref->id;
 650              #$q .= ",". $obj->ref->parent->id;
 651              if  ($obj->ref->gettype() == "installation") {
 652                  $pre = ",";
 653                  $q .= $pre . $obj->ref->product->id;
 654              } else if  ($obj->ref->gettype() == "product") {
 655              } else if  ($obj->ref->gettype() == "scrumlog") {
 656                  $pre = ",";
 657                  if (-1 != $obj->ref->p_id)
 658                      $q .= $pre.$obj->ref->p_id;
 659                  if (-1 != $obj->ref->sprint_id)
 660                      $q .= $pre.$obj->ref->sprint_id;
 661                  if (-1 != $obj->ref->ref_id)
 662                      $q .= $pre.$obj->ref->ref_id;
 663              } else if  ($obj->ref->gettype() == "user") {
 664              } else if  ($obj->ref->gettype() == "address") {
 665                  // called for time recording the reference is the workers adress
 666              } else {
 667                  if ( is_object($obj->ref->parent) && ($obj->ref->parent->gettype() != "address") ) {
 668                      $x = $obj->ref->parent;
 669                      $pre = ",";
 670                      while ( isset ( $x ) ) {
 671                          $q .= $pre . $x->id;
 672                          if (isset($x->parent)) {
 673                              $x = $x->parent;
 674                          } else {
 675                              // for the project-id above an installation
 676                              if ( $x->gettype() == "installation" ) {
 677                                  $q .= $pre . $x->product->id;
 678                              }
 679  
 680                              unset($x);
 681                          }
 682                      }
 683                  }
 684              }
 685              //worker = current_user and current_user's teams
 686              $q .= ") and worker in (". $current_user->id;
 687              foreach ( $current_user->teams as $idx => $val ) {
 688                  $q .= $pre . $idx ;
 689                  $pre = ",";
 690              }
 691              $q .= ")";
 692              $q .= ") order by priority desc";
 693          } else {
 694              // this is a list for display only
 695              $q .= $pre . $obj->id ;
 696              $pre = ",";
 697              $q .= ") order by creation desc";
 698          }
 699          $r = $obj->dbconn->Exec($q);
 700          $n = $r->numrows();
 701          $a = 0;
 702          while ($a < $n) {
 703              $rate = new Rate($obj->dbconn);
 704              $rate->read_result($r,$a);
 705              if ( $rate->see_ok() ) {
 706                  $obj->list[userates][$rate->id] = &$rate;
 707              }
 708              $a++;
 709              unset($rate);
 710          }
 711          $r->free();
 712          return;
 713      }
 714  
 715      /**
 716       * delete rate entries for a object
 717       */
 718      static Function obj_delete(tutos_user $user,tutos_base $obj) {
 719          $msg = "";
 720          if ($obj->gettype() == "timetrack") {
 721              return $msg;
 722          }
 723          rate::obj_read($obj);
 724  
 725          if ( count($obj->list[userates]) > 0 ) {
 726              foreach ($obj->list[userates] as $f) {
 727                  $msg = addLine($msg,$f->delete());
 728              }
 729          }
 730          return $msg;
 731      }
 732  
 733      /**
 734       * create a link to a overview page
 735       */
 736      static function getSelectLink (tutos_user $user,$text = "") {
 737          global $lang,$tutos;
 738          if ( ! $user->feature_ok(userates,PERM_SEL) ) {
 739              return;
 740          }
 741          return array( url => 'rate/rate_select.php',
 742                        image => $user->layout->theme->getImage(rate::getHtmlIcon(),'menu'),
 743                        text => ($text == "" ?  $lang['RateSearch']: $text),
 744                        info => $lang['SearchForRate'],
 745                        category => array('search','rate','module',userates)
 746              );
 747      }
 748  
 749      /**
 750       * show the mytutos info about rates
 751       */
 752      static function mytutos (tutos_user $user) {
 753          global $tutos,$lang,$current_user;
 754  
 755          if ( ! $current_user->feature_ok(userates,PERM_SEE) ) {
 756              return '';
 757          }
 758          if ( ! $current_user->feature_ok(userates,PERM_MYTUTOS) ) {
 759              return '';
 760          }
 761  
 762          $q = 'SELECT * from '. $user->dbconn->prefix .'rates where creator = '. $user->id .' or link_id = '. $user->id .' order by creation DESC';
 763          $res = $user->dbconn->Exec($q);
 764          $n = $res->numrows();
 765          if ($n == 0) {
 766              $res->free();
 767              return '';
 768          }
 769  
 770          $r = info_table_start();
 771          $r .= " <tr>\n";
 772          $m = rate::getSelectLink($current_user,$lang['Rates']);
 773          if ($m) {
 774              $ml = menulink($m[url],$m[text],$m[info]);
 775          } else {
 776              $ml = $lang['Rates'];
 777          }
 778  
 779          $r .= ' <th colspan="4">'. $current_user->layout->theme->getImage(rate::getHtmlIcon(),'list').' '.$ml."</th>\n";
 780          $r .= " </tr>\n";
 781          $r .= " <tr>\n";
 782          $r .= '  <th>'. $lang['RateName'] ."</th>\n";
 783          $r .= '  <th>'. $lang['RateReference'] ."</th>\n";
 784          $r .= '  <th>'. $lang['RateWorkerReference'] ."</th>\n";
 785          $r .= '  <th>'. $lang['Rate'] ."</th>\n";
 786          $r .= " </tr>\n";
 787  
 788          $a = 0;
 789          while ( ($a < $n) and ($a < 2* $tutos['maxshort']) ) {
 790              $f = new Rate($user->dbconn);
 791              $f->read_result($res,$a);
 792              if ( $f->see_ok() ) {
 793                  $f->read_reference();
 794                  $r .= " <tr>\n";
 795                  $r .= '  <td>' . $f->getLink() ."</td>\n";
 796                  $r .= '  <td>' . $f->ref->getLink() ."</td>\n";
 797                  $r .= '  <td>' . (is_Object($f->worker) ? $f->worker->getLink():"-") ."</td>\n";
 798                  $r .= '  <td align="right">' . my_number_format($f->cph,2) .' '. $f->currency ."</td>\n";
 799                  $r .= " </tr>\n";
 800              }
 801              $a++;
 802              unset($f);
 803          }
 804          $r .= info_table_end();
 805          $res->free();
 806          return $r;
 807      }
 808  
 809      /**
 810       * get the help index
 811       */
 812      static function getHelpIndex () {
 813          global $lang;
 814  
 815          $r = '';
 816          $r .= '<h3>'. makelink('help.php?p=glossary#rate',$lang['Rates'],$lang['Rates']) ."</h3><ul>\n";
 817          $r .= "</ul>\n";
 818          return $r;
 819      }
 820  }
 821  ?>

title

Description

title

Description

title

Description

title

title

Body