Nouveau fichier
This commit is contained in:
parent
7fd2464eed
commit
74e6e1d34b
39
htdocs/telephonie/sql/llx_telephonie_service.sql
Normal file
39
htdocs/telephonie/sql/llx_telephonie_service.sql
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
-- ========================================================================
|
||||||
|
-- Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
--
|
||||||
|
-- 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; either version 2 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program 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 this program; if not, write to the Free Software
|
||||||
|
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
--
|
||||||
|
-- $Id$
|
||||||
|
-- $Source$
|
||||||
|
--
|
||||||
|
-- ========================================================================
|
||||||
|
--
|
||||||
|
--
|
||||||
|
create table llx_telephonie_service (
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
ref varchar(25) NOT NULL,
|
||||||
|
|
||||||
|
libelle varchar(255),
|
||||||
|
libelle_facture varchar(255),
|
||||||
|
montant real NOT NULL,
|
||||||
|
statut smallint DEFAULT 0 NOT NULL,
|
||||||
|
|
||||||
|
fk_user_creat integer NOT NULL,
|
||||||
|
date_creat datetime NOT NULL,
|
||||||
|
fk_user_modif integer,
|
||||||
|
date_modif datetime
|
||||||
|
)type=innodb;
|
||||||
|
|
||||||
|
|
||||||
141
htdocs/telephonie/telephonie.service.class.php
Normal file
141
htdocs/telephonie/telephonie.service.class.php
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<?PHP
|
||||||
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
*
|
||||||
|
* 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; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* $Source$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TelephonieService {
|
||||||
|
var $db;
|
||||||
|
|
||||||
|
var $id;
|
||||||
|
var $ligne;
|
||||||
|
|
||||||
|
function TelephonieService($DB)
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$this->db = $DB;
|
||||||
|
$this->error_message = '';
|
||||||
|
$this->statuts[0] = "Inactif";
|
||||||
|
$this->statuts[1] = "Actif";
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function update($user)
|
||||||
|
{
|
||||||
|
$this->montant = ereg_replace(",",".",$this->montant);
|
||||||
|
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_service";
|
||||||
|
$sql .= " SET ";
|
||||||
|
$sql .= " libelle = '$this->libelle' ";
|
||||||
|
$sql .= ", libelle_facture = '$this->libelle' ";
|
||||||
|
$sql .= ", montant = '$this->montant' ";
|
||||||
|
$sql .= ", fk_user_modif = $user->id ";
|
||||||
|
$sql .= ", date_modif = now() ";
|
||||||
|
|
||||||
|
$sql .= " WHERE rowid = $this->id";
|
||||||
|
|
||||||
|
if ( $this->db->query($sql) )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error();
|
||||||
|
print $sql ;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function create($user)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->montant = ereg_replace(",",".",$this->montant);
|
||||||
|
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_service";
|
||||||
|
$sql .= " (ref, libelle, libelle_facture, montant, fk_user_creat, date_creat)";
|
||||||
|
$sql .= " VALUES (";
|
||||||
|
$sql .= " '$this->ref','$this->libelle','$this->libelle_facture','$this->montant',$user->id, now())";
|
||||||
|
|
||||||
|
if ( $this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$this->id = $this->db->last_insert_id();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->error_message = "Echec de la création du service !";
|
||||||
|
dolibarr_syslog("TelephonieService::Create Error -1");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function fetch($id)
|
||||||
|
{
|
||||||
|
$sql = "SELECT s.rowid, s.libelle, s.libelle_facture, s.montant, s.statut";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_service as s";
|
||||||
|
$sql .= " WHERE s.rowid = ".$id;
|
||||||
|
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
if ($this->db->num_rows())
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object(0);
|
||||||
|
|
||||||
|
$this->id = $obj->rowid;
|
||||||
|
$this->libelle = stripslashes($obj->libelle);
|
||||||
|
$this->libelle_facture = stripslashes($obj->libelle_facture);
|
||||||
|
$this->montant = $obj->montant;
|
||||||
|
$this->statut = $obj->statut;
|
||||||
|
|
||||||
|
$result = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result = -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->free();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Erreur select SQL */
|
||||||
|
print $this->db->error();
|
||||||
|
$result = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user