noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_own.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 /*! \file
00021  * \brief Class to manage the company parameter (address, name...)
00022  */
00023 /*!
00024  * \brief Class to manage the company parameter (address, name...)
00025  */
00026 
00027 class Own
00028 {
00029     var $db;
00030     // constructor
00031     function Own($p_cn)
00032     {
00033         $this->db=$p_cn;
00034         $Res=$p_cn->exec_sql("select * from parameter where pr_id like 'MY_%'");
00035         for ($i = 0;$i < Database::num_row($Res);$i++)
00036         {
00037             $row=Database::fetch_array($Res,$i);
00038             $key=$row['pr_id'];
00039             $elt=$row['pr_value'];
00040             // store value here
00041             $this->{"$key"}=$elt;
00042         }
00043 
00044     }
00045     function check(&$p_value)
00046     {
00047         if ($p_value == 'MY_STRICT'
00048                 && $this->MY_STRICT != 'Y'
00049                 && $this->MY_STRICT != 'N')
00050             $p_value='N';
00051         $p_value=htmlspecialchars($p_value);
00052     }
00053     /*!
00054      **************************************************
00055      * \brief  save the parameter into the database by inserting or updating
00056      *
00057      *
00058      * \param $p_attr give the attribut name
00059      *
00060      */
00061     function save($p_attr)
00062     {
00063         $this->check($p_attr);
00064         $value=$this->$p_attr;
00065         // check if the parameter does exist
00066         if ( $this->db->get_value('select count(*) from parameter where pr_id=$1',array($p_attr)) != 0 )
00067         {
00068             $Res=$this->db->exec_sql("update parameter set pr_value=$1 where pr_id=$2",
00069                                      array($value,$p_attr));
00070         }
00071         else
00072         {
00073 
00074             $Res=$this->db->exec_sql("insert into parameter (pr_id,pr_value) values( $1,$2)",
00075                                      array($p_attr,$value));
00076 
00077         }
00078 
00079     }
00080 
00081     /*!
00082      **************************************************
00083      * \brief  save data
00084      *
00085      *
00086      */
00087     function update()
00088     {
00089 
00090         $this->save('MY_NAME');
00091         $this->save('MY_TVA');
00092         $this->save('MY_STREET');
00093         $this->save('MY_NUMBER');
00094         $this->save('MY_CP');
00095         $this->save('MY_TEL');
00096         $this->save('MY_PAYS');
00097         $this->save('MY_COMMUNE');
00098         $this->save('MY_FAX');
00099         $this->save('MY_ANALYTIC');
00100         $this->save('MY_STRICT');
00101         $this->save('MY_TVA_USE');
00102         $this->save('MY_PJ_SUGGEST');
00103         $this->save('MY_CHECK_PERIODE');
00104         $this->save('MY_DATE_SUGGEST');
00105         $this->save('MY_ALPHANUM');
00106         $this->save('MY_UPDLAB');
00107         $this->save('MY_STOCK');
00108 
00109 
00110     }
00111 
00112 }
 All Data Structures Namespaces Files Functions Variables Enumerations