TUTOS PHP Cross Reference Groupware Applications

Source: /php/rate/rate_ins.php - 120 lines - 3421 bytes - Text - Print

Description: Copyright 1999 - 2013 by Gero Kohnert and ecosoft 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 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   * this script parses all the inputs and stores the object into the database.
  10   * on completition it jumps to the detail screen of the stored object
  11   *
  12   * @modulegroup rate
  13   * @module rate_ins
  14   * @package rate
  15   */
  16  $tutos['files'][__FILE__] = '$Rev: 1193 $';
  17  
  18  $tutos['base'] = "../..";
  19  ini_set("include_path","..");
  20  require_once  'webelements.p3';
  21  require_once  'permission.p3';
  22  
  23  /* Check if user is allowed to use it */
  24  check_user();
  25  loadmodules("rate","ins");
  26  loadmodule("rate");
  27  
  28  /* Check Input */
  29  
  30  $msg     = '';
  31  $info    = '';
  32  $gotourl = 'rate/rate_new.php';
  33  $u    = new rate($dbconn);
  34  
  35  if ( isset($_POST['Xid']) ) {
  36      $u = $u->read($_POST['Xid'],$u);
  37      $gotourl= addUrlParameter($gotourl,"id=". $u->id,true);
  38  } else {
  39      $u->creator = $current_user;
  40  }
  41  // name
  42  if ( empty($_POST['name']) ) {
  43      $msg = addLine($msg,sprintf($lang['Err0009'],$lang['RateName']));
  44      $gotourl = addBadField($gotourl,'name',true);
  45  } else {
  46      $u->setName(trim($_POST['name']));
  47      $gotourl= addUrlParameter($gotourl,"name=". UrlEncode($u->name),true);
  48  }
  49  // cph
  50  if ( empty($_POST['cph']) ) {
  51      $msg = addLine($msg,sprintf($lang['Err0009'],$lang['Rate']));
  52  } else {
  53      $u->setCph($_POST['cph']);
  54      $gotourl= addUrlParameter($gotourl,"cph=". UrlEncode($u->cph),true);
  55  }
  56  // currency
  57  if ( empty($_POST['currency']) ) {
  58      $msg = addLine($msg,sprintf($lang['Err0009'],$lang['Rate']));
  59  } else {
  60      $u->setCurrency($_POST['currency']);
  61      $gotourl= addUrlParameter($gotourl,"currency=". UrlEncode($u->currency),true);
  62  }
  63  // priority
  64  if ( isset($_POST['priority']) ) {
  65      $u->setPriority($_POST['priority']);
  66      $gotourl= addUrlParameter($gotourl,"priority=". UrlEncode($u->priority),true);
  67  }
  68  // tax
  69  if ( isset($_POST['vat']) ) {
  70      $val = trim($_POST['vat']);
  71      if (checkfloat($val) ) {
  72          $u->setVat($val);
  73      }
  74      $gotourl= addUrlParameter($gotourl,"vat=". UrlEncode($_POST['vat']),true);
  75  }
  76  // state
  77  if ( isset($_POST['state']) ) {
  78      $u->setState($_POST['state']);
  79      $gotourl= addUrlParameter($gotourl,"state=". UrlEncode($u->state),true);
  80  }
  81  // role
  82  if ( isset($_POST['role_id']) ) {
  83      $u->setRole($_POST['role_id']);
  84      $gotourl= addUrlParameter($gotourl,"role_id=". UrlEncode($u->role_id),true);
  85  }
  86  // worker
  87  if ( isset($_POST['worker']) ) {
  88      $u->setWorker($_POST['worker']);
  89      $gotourl= addUrlParameter($gotourl,"worker=". UrlEncode($u->worker),true);
  90  }
  91  // reference
  92  if ( empty($_POST['link_id']) ) {
  93      $msg = addLine($msg,"No Link ID given !");
  94  } else {
  95      $u->setReference($_POST['link_id']);
  96      $gotourl= addUrlParameter($gotourl,"link_id=". $u->link_id,true);
  97      $u->read_reference();
  98  }
  99  
 100  //
 101  // Parse additional custom fields
 102  //
 103  $msg = addLine($msg,parse_custom_fields($u->gettype(),$u));
 104  // other modules
 105  $msg = addLine($msg,module_parseforms($current_user,$u,$gotourl));
 106  
 107  $msg = addLine($msg,$u->run_check_hook());
 108  if ( $msg == "" ) {
 109      $dbconn->Begin("WORK");
 110      $msg = addLine($msg,$u->save());
 111      $dbconn->Commit("WORK");
 112      $gotourl = $u->ref->getURL();
 113  }
 114  
 115  leave_insert($dbconn,'../'.$gotourl,$msg,$info);
 116  /**
 117   *  SVN Info $Id: rate_ins.php 1193 2013-12-05 08:44:55Z gokohnert $
 118   *  $Author: gokohnert $
 119   */
 120  ?>

title

Description

title

Description

title

Description

title

title

Body