noalyss  Version-6.7.2
Public Member Functions | Static Public Member Functions
Document_type Class Reference

class for the table document_type < dt_id pk document_type < dt_value value More...

Public Member Functions

 document_type ($p_cn, $p_id=-1)
 document_type
 get ()
 Get all the data for this dt_id.
 insert ($p_value, $p_prefix)
 set_number ($p_int)
 update ()
 Update.

Static Public Member Functions

static get_list ($p_cn)
 get a list $p_cn database connection

Detailed Description

class for the table document_type < dt_id pk document_type < dt_value value

Definition at line 30 of file class_document_type.php.


Member Function Documentation

Document_type::document_type ( p_cn,
p_id = -1 
)

document_type

constructor

Parameters:
$p_cndatabase connx

Definition at line 37 of file class_document_type.php.

References db.

        {
                $this->db = $p_cn;
                $this->dt_id = $p_id;
        }

Get all the data for this dt_id.

Definition at line 47 of file class_document_type.php.

References $r, $sql, db, and Database\fetch_array().

        {
                $sql = "select * from document_type where dt_id=$1";
                $R = $this->db->exec_sql($sql, array($this->dt_id));
                if (count($R) == 0) return 1;
                $r = Database::fetch_array($R, 0);
                $this->dt_id = $r['dt_id'];
                $this->dt_value = $r['dt_value'];
                $this->dt_prefix = $r['dt_prefix'];
                return 0;
        }
static Document_type::get_list ( p_cn) [static]

get a list $p_cn database connection

Returns:
array of data from document_type

Definition at line 64 of file class_document_type.php.

References $array, $r, $sql, $tmp, and id.

        {
                $sql = "select * from document_type order by dt_value";
                $r = $p_cn->get_array($sql);
                $array = array();
                for ($i = 0; $i < count($r); $i++)
                {
                        $tmp['dt_value'] = $r[$i]['dt_value'];
                        $tmp['dt_prefix'] = $r[$i]['dt_prefix'];

                        $bt = new IButton('X' . $r[$i]['dt_id']);
                        $bt->label = _('Modifier');
                        $bt->javascript = "cat_doc_change('" . $r[$i]['dt_id'] . "','" . Dossier::id() . "');";

                        $tmp['js_mod'] = $bt->input();
                        $tmp['dt_id'] = $r[$i]['dt_id'];

                        $bt = new IButton('X' . $r[$i]['dt_id']);
                        $bt->label = _('Effacer');
                        $bt->javascript = "if (confirm('" . _('Vous confirmez') . "')==true) {";
                        $bt->javascript.="cat_doc_remove('" . $r[$i]['dt_id'] . "','" . Dossier::id() . "');";
                        $bt->javascript.='}';

                        $tmp['js_remove'] = $bt->input();


                        $array[$i] = $tmp;
                }
                return $array;
        }
Document_type::insert ( p_value,
p_prefix 
)

Definition at line 95 of file class_document_type.php.

References $e, $sql, alert(), db, j(), and trim().

        {
                $sql = "insert into document_type(dt_value,dt_prefix) values ($1,$2)";
                try
                {
                        if ($this->db->count_sql('select * from document_type where upper(dt_value)=upper(trim($1))', array($p_value)) > 0)
                                throw new Exception('Nom en double');
                        if (strlen(trim($p_value)) > 0)
                                $this->db->exec_sql($sql, array($p_value, $p_prefix));
                }
                catch (Exception $e)
                {
                        alert(j(_("Impossible d'ajouter [$p_value] ") . $e->getMessage()));
                }
        }

Definition at line 127 of file class_document_type.php.

References $e, alert(), and db.

        {
                try
                {
                        $this->db->exec_sql("alter sequence seq_doc_type_" . $this->dt_id . " restart " . $p_int);
                }
                catch (Exception $e)
                {
                        alert("Erreur " . $e->getMessage());
                }
        }

Update.

Definition at line 114 of file class_document_type.php.

References $e, alert(), and db.

        {
                try
                {
                        $this->db->exec_sql("update document_type set dt_value=$1,dt_prefix=$2 where dt_id=$3", array($this->dt_value,
                                $this->dt_prefix, $this->dt_id));
                }
                catch (Exception $e)
                {
                        alert(" Erreur " . $e->getMessage());
                }
        }

The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations