altocompta/include/class_tool_uos.php
Dany De Bontridder 08a3e922da Merged revisions 5324,5326-5332 via svnmerge from
svn+ssh://ns352270.ovh.net/svn/phpcompta/tags/rel660

........
  r5324 | danydb | 2013-06-10 18:17:15 +0200 (Mon, 10 Jun 2013) | 1 line
  
  Probleme journaux ODS: mauvais filtre pour les fiches
........
  r5326 | danydb | 2013-06-26 21:25:42 +0200 (Wed, 26 Jun 2013) | 1 line
  
  bug : use POST instead of array
........
  r5327 | danydb | 2013-06-29 00:24:33 +0200 (Sat, 29 Jun 2013) | 1 line
  
  Bug : missing php path
........
  r5328 | danydb | 2013-06-29 00:34:51 +0200 (Sat, 29 Jun 2013) | 1 line
  
  Bug : mixed 2 variables : cannot save Analytic operation
........
  r5329 | danydb | 2013-06-29 00:56:50 +0200 (Sat, 29 Jun 2013) | 1 line
  
  Bug #0000859: FORECAST ; bug Total Categorie reel
........
  r5330 | danydb | 2013-07-03 22:08:41 +0200 (Wed, 03 Jul 2013) | 1 line
  
  Bug #0000860: creation de comptes utilisateurs sur serveur mutualisé (mono dossier)
........
  r5331 | danydb | 2013-07-10 19:12:32 +0200 (Wed, 10 Jul 2013) | 1 line
  
  Card ordered by name
........
  r5332 | danydb | 2013-07-10 19:13:44 +0200 (Wed, 10 Jul 2013) | 1 line
  
  Card ordered by name
........
2013-07-10 17:16:02 +00:00

108 lines
3.4 KiB
PHP

<?php
/*
* This file is part of PhpCompta.
*
* PhpCompta 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; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision: $Revision $ */
/**
* @file
* @brief Objec to check a double insert into the database, this duplicate occurs after
* a refresh of the web page
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
require_once 'class_database.php';
define ('CODE_EXCP_DUPLICATE',901);
/**
* @brief Objec to check a double insert into the database, this duplicate occurs after
* a refresh of the web page
* in
*/
class Tool_Uos
{
/**
* Constructor $p_name will be set to $this->name, it is also the name
* of the tag hidden in a form
* @global $cn Db connxion
* @param $p_name
*/
function __construct($p_name)
{
$this->name=$p_name;
}
/**
* @brief return a string with a tag hidden and a uniq value
* @param $hHidden is the name of the tag hidden
* @return string : tag hidden
*/
function hidden()
{
global $cn;
$this->id=$cn->get_next_seq('uos_pk_seq');
return HtmlInput::hidden($this->name,$this->id);
}
/**
* @brief Try to insert into the table tool_uos
* @global $cn Database connx
* @throws Exception if the value $p_id is not unique
*/
function save($p_array=null)
{
global $cn;
if ( $p_array == null ) $p_array=$_POST;
$this->id=$p_array[$this->name];
$sql="insert into tool_uos(uos_value) values ($1)";
try {
$cn->exec_sql($sql,array($this->id));
} catch (Exception $e)
{
throw new Exception('Duplicate value');
}
}
/**
* Count how many time we have this->id into the table tool_uos
* @global $cn Database connx
* @param $p_array is the array where to find the key name, usually it is
* $_POST. The default value is $_POST
* @return integer : 0 or 1
*/
function get_count($p_array=null)
{
global $cn;
if ( $p_array == null ) $p_array=$_POST;
$this->id=$p_array[$this->name];
$count=$cn->get_value('select count(*) from tool_uos where uos_value=$1',
array($this->id));
return $count;
}
function check ($p_array=null)
{
global $cn;
if ( $p_array == null ) $p_array=$_POST;
$this->id=$p_array[$this->name];
try
{
$count=$cn->get_value('select count(*) from tool_uos where uos_value=$1',
array($this->id));
if ($count != 0 ) throw new Exception ('DUPLICATE',CODE_EXCP_DUPLICATE);
}catch (Exception $e)
{
throw $e;
}
}
}
?>