Commit ee7cadef authored by mbriand's avatar mbriand
Browse files

Archivage des objets de l'inventaire

parent a7909c84
......@@ -30,11 +30,11 @@ $asso = new asso($site->db,$site->dbrw);
$asso->load_by_id($_REQUEST["id_asso"]);
if ( $asso->id < 1 )
{
$site->error_not_found();
exit();
$site->error_not_found();
exit();
}
if ( !$site->user->is_in_group("gestion_ae") && !$asso->is_member_role($site->user->id,ROLEASSO_MEMBREBUREAU) )
$site->error_forbidden();
$site->error_forbidden();
$site->start_page("presentation",$asso->nom);
......@@ -42,36 +42,56 @@ $cts = new contents($asso->get_html_path());
$cts->add(new tabshead($asso->get_tabs($site->user),"inv"));
$show_all = false;
if (isset($_REQUEST['show_all']))
$show_all = true;
$cts->add_paragraph("<a href=\"../objet.php?id_asso=".$asso->id."\">Ajouter un objet</a>");
$cts->add_paragraph("<a href=\"../etiquette.php?id_asso=".$asso->id."\">Imprimer codes barres</a>");
$cts->add_paragraph("<a href=\"inventaire.php?id_asso=".$asso->id."&showall\">Afficher les objets archivés</a>");
$req = new requete ( $site->db, "SELECT `inv_objet`.`id_objet`," .
"CONCAT(`inv_objet`.`nom_objet`,' ',`inv_objet`.`cbar_objet`) AS `nom_objet`, " .
"`asso_gest`.`id_asso` AS `id_asso_gest`, " .
"`asso_gest`.`nom_asso` AS `nom_asso_gest`, " .
"`asso_prop`.`id_asso` AS `id_asso_prop`, " .
"`asso_prop`.`nom_asso` AS `nom_asso_prop`, " .
"`sl_batiment`.`id_batiment`,`sl_batiment`.`nom_bat`," .
"`sl_salle`.`id_salle`,`sl_salle`.`nom_salle`, " .
"`inv_type_objets`.`id_objtype`,`inv_type_objets`.`nom_objtype` " .
"FROM `inv_objet` " .
"INNER JOIN `asso` AS `asso_gest` ON `inv_objet`.`id_asso`=`asso_gest`.`id_asso` " .
"INNER JOIN `asso` AS `asso_prop` ON `inv_objet`.`id_asso_prop`=`asso_prop`.`id_asso` " .
"INNER JOIN `sl_salle` ON `inv_objet`.`id_salle`=`sl_salle`.`id_salle` " .
"INNER JOIN `sl_batiment` ON `sl_batiment`.`id_batiment`=`sl_salle`.`id_batiment` " .
"INNER JOIN `inv_type_objets` ON `inv_objet`.`id_objtype`=`inv_type_objets`.`id_objtype` " .
"WHERE `inv_objet`.`id_asso`='".$asso->id."'" );
"CONCAT(`inv_objet`.`nom_objet`,' ',`inv_objet`.`cbar_objet`) AS `nom_objet`, " .
"`asso_gest`.`id_asso` AS `id_asso_gest`, " .
"`asso_gest`.`nom_asso` AS `nom_asso_gest`, " .
"`asso_prop`.`id_asso` AS `id_asso_prop`, " .
"`asso_prop`.`nom_asso` AS `nom_asso_prop`, " .
"`sl_batiment`.`id_batiment`,`sl_batiment`.`nom_bat`," .
"`sl_salle`.`id_salle`,`sl_salle`.`nom_salle`, " .
"`inv_type_objets`.`id_objtype`,`inv_type_objets`.`nom_objtype` " .
($show_all ? "if(`inv_objet`.`archive_objet` = 1, 'Oui', 'Non') archive_objet" : "").
"FROM `inv_objet` " .
"INNER JOIN `asso` AS `asso_gest` ON `inv_objet`.`id_asso`=`asso_gest`.`id_asso` " .
"INNER JOIN `asso` AS `asso_prop` ON `inv_objet`.`id_asso_prop`=`asso_prop`.`id_asso` " .
"INNER JOIN `sl_salle` ON `inv_objet`.`id_salle`=`sl_salle`.`id_salle` " .
"INNER JOIN `sl_batiment` ON `sl_batiment`.`id_batiment`=`sl_salle`.`id_batiment` " .
"INNER JOIN `inv_type_objets` ON `inv_objet`.`id_objtype`=`inv_type_objets`.`id_objtype` " .
"WHERE `inv_objet`.`id_asso`='".$asso->id."'".
($show_all ? "" : "AND `archive_objet` = 0")
);
$columns = array(
"nom_objet"=>"Objet",
"nom_objtype"=>"Type",
"nom_asso_gest"=>"Gestionnaire",
"nom_asso_prop"=>"Propriétaire",
"nom_salle"=>"Salle",
"nom_bat"=>"Batiment",
);
if ($show_all)
$columns["archive_objet"] = "Archivé";
$tbl = new sqltable(
"listobjets",
"Inventaire", $req, "asso.php",
"id_objet",
array("nom_objet"=>"Objet","nom_objtype"=>"Type","nom_asso_gest"=>"Gestionnaire","nom_asso_prop"=>"Propriétaire","nom_salle"=>"Salle","nom_bat"=>"Batiment"),
array(), array(), array()
);
"listobjets",
"Inventaire", $req, "asso.php",
"id_objet",
$columns,
array(), array(), array()
);
$cts->add($tbl);
......
......@@ -33,121 +33,121 @@
*/
class objtype extends stdentity
{
var $nom;
var $prix;
var $caution;
var $prix_emprunt;
var $code;
var $empruntable;
var $notes;
/** Charge un type d'objet en fonction de son id
* $this->id est égal à -1 en cas d'erreur
* @param $id id de la fonction
*/
function load_by_id ( $id )
{
$req = new requete($this->db, "SELECT * FROM `inv_type_objets`
WHERE `id_objtype` = '" . mysql_real_escape_string($id) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function load_by_code ( $code )
{
$req = new requete($this->db, "SELECT * FROM `inv_type_objets`
WHERE `code_objtype` = '" . mysql_real_escape_string($code) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function _load ( $row )
{
$this->id = $row['id_objtype'];
$this->nom = $row['nom_objtype'];
$this->prix = $row['prix_objtype'];
$this->caution = $row['caution_objtype'];
$this->prix_emprunt = $row['prix_emprunt_objtype'];
$this->code = $row['code_objtype'];
$this->empruntable = $row['empruntable_objtype'];
$this->notes = $row['notes_objtype'];
}
function add ( $nom, $prix, $caution, $prix_emprunt, $code, $empruntable, $notes )
{
$this->nom = $nom;
$this->prix = $prix;
$this->caution = $caution;
$this->prix_emprunt = $prix_emprunt;
$this->code = $code;
$this->empruntable = $empruntable;
$this->notes = $notes;
$sql = new insert ($this->dbrw,
"inv_type_objets",
array(
"nom_objtype" => $this->nom,
"prix_objtype" => $this->prix,
"caution_objtype" => $this->caution,
"prix_emprunt_objtype" => $this->prix_emprunt,
"code_objtype" => $this->code,
"empruntable_objtype" => $this->empruntable,
"notes_objtype" => $this->notes
)
);
if ( $sql )
$this->id = $sql->get_id();
else
$this->id = null;
}
function save ( $nom, $prix, $caution, $prix_emprunt, $code, $empruntable, $notes )
{
$this->nom = $nom;
$this->prix = $prix;
$this->caution = $caution;
$this->prix_emprunt = $prix_emprunt;
$this->code = $code;
$this->empruntable = $empruntable;
$this->notes = $notes;
$sql = new update ($this->dbrw,
"inv_type_objets",
array(
"nom_objtype" => $this->nom,
"prix_objtype" => $this->prix,
"caution_objtype" => $this->caution,
"prix_emprunt_objtype" => $this->prix_emprunt,
"code_objtype" => $this->code,
"empruntable_objtype" => $this->empruntable,
"notes_objtype" => $this->notes
),
array(
"id_objtype" => $this->id
)
);
}
var $nom;
var $prix;
var $caution;
var $prix_emprunt;
var $code;
var $empruntable;
var $notes;
/** Charge un type d'objet en fonction de son id
* $this->id est égal à -1 en cas d'erreur
* @param $id id de la fonction
*/
function load_by_id ( $id )
{
$req = new requete($this->db, "SELECT * FROM `inv_type_objets`
WHERE `id_objtype` = '" . mysql_real_escape_string($id) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function load_by_code ( $code )
{
$req = new requete($this->db, "SELECT * FROM `inv_type_objets`
WHERE `code_objtype` = '" . mysql_real_escape_string($code) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function _load ( $row )
{
$this->id = $row['id_objtype'];
$this->nom = $row['nom_objtype'];
$this->prix = $row['prix_objtype'];
$this->caution = $row['caution_objtype'];
$this->prix_emprunt = $row['prix_emprunt_objtype'];
$this->code = $row['code_objtype'];
$this->empruntable = $row['empruntable_objtype'];
$this->notes = $row['notes_objtype'];
}
function add ( $nom, $prix, $caution, $prix_emprunt, $code, $empruntable, $notes )
{
$this->nom = $nom;
$this->prix = $prix;
$this->caution = $caution;
$this->prix_emprunt = $prix_emprunt;
$this->code = $code;
$this->empruntable = $empruntable;
$this->notes = $notes;
$sql = new insert ($this->dbrw,
"inv_type_objets",
array(
"nom_objtype" => $this->nom,
"prix_objtype" => $this->prix,
"caution_objtype" => $this->caution,
"prix_emprunt_objtype" => $this->prix_emprunt,
"code_objtype" => $this->code,
"empruntable_objtype" => $this->empruntable,
"notes_objtype" => $this->notes
)
);
if ( $sql )
$this->id = $sql->get_id();
else
$this->id = null;
}
function save ( $nom, $prix, $caution, $prix_emprunt, $code, $empruntable, $notes )
{
$this->nom = $nom;
$this->prix = $prix;
$this->caution = $caution;
$this->prix_emprunt = $prix_emprunt;
$this->code = $code;
$this->empruntable = $empruntable;
$this->notes = $notes;
$sql = new update ($this->dbrw,
"inv_type_objets",
array(
"nom_objtype" => $this->nom,
"prix_objtype" => $this->prix,
"caution_objtype" => $this->caution,
"prix_emprunt_objtype" => $this->prix_emprunt,
"code_objtype" => $this->code,
"empruntable_objtype" => $this->empruntable,
"notes_objtype" => $this->notes
),
array(
"id_objtype" => $this->id
)
);
}
}
......@@ -163,110 +163,110 @@ define("OEVENT_VOLE",4);
class objet extends stdentity
{
var $id_asso;
var $id_asso_prop;
var $id_salle;
var $id_objtype;
var $id_op;
var $nom;
var $num;
var $cbar;
var $num_serie;
var $date_achat;
var $prix;
var $caution;
var $prix_emprunt;
var $empruntable;
var $en_etat;
var $archive;
var $notes;
var $id_asso;
var $id_asso_prop;
var $id_salle;
var $id_objtype;
var $id_op;
var $nom;
var $num;
var $cbar;
var $num_serie;
var $date_achat;
var $prix;
var $caution;
var $prix_emprunt;
var $empruntable;
var $en_etat;
var $archive;
var $notes;
var $_is_book;
var $_is_jeu;
/** Charge un objet en fonction de son id
* $this->id est égal à -1 en cas d'erreur
* @param $id id de la fonction
*/
function load_by_id ( $id )
{
$req = new requete($this->db, "SELECT * FROM `inv_objet`
WHERE `id_objet` = '" . mysql_real_escape_string($id) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function load_by_cbar ( $cbar )
{
$req = new requete($this->db, "SELECT * FROM `inv_objet`
WHERE `cbar_objet` = '" . mysql_real_escape_string($cbar) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function load_by_num ( $id_objtype, $num )
{
$req = new requete($this->db, "SELECT * FROM `inv_objet`
WHERE `id_objtype` = '" . mysql_real_escape_string($id_objtype) . "'
AND `num_objet` = '" . mysql_real_escape_string($num) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
/** Charge un objet en fonction de son id
* $this->id est égal à -1 en cas d'erreur
* @param $id id de la fonction
*/
function load_by_id ( $id )
{
$req = new requete($this->db, "SELECT * FROM `inv_objet`
WHERE `id_objet` = '" . mysql_real_escape_string($id) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function load_by_cbar ( $cbar )
{
$req = new requete($this->db, "SELECT * FROM `inv_objet`
WHERE `cbar_objet` = '" . mysql_real_escape_string($cbar) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function load_by_num ( $id_objtype, $num )
{
$req = new requete($this->db, "SELECT * FROM `inv_objet`
WHERE `id_objtype` = '" . mysql_real_escape_string($id_objtype) . "'
AND `num_objet` = '" . mysql_real_escape_string($num) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function get_display_name()
{
if ( $this->nom )
return $this->nom." (".$this->num.")";
else
return $this->num;
if ( $this->nom )
return $this->nom." (".$this->num.")";
else
return $this->num;
}
function _load ( $row )
{
$this->id = $row['id_objet'];
$this->id_asso = $row['id_asso'];
$this->id_asso_prop = $row['id_asso_prop'];
$this->id_salle = $row['id_salle'];
$this->id_objtype = $row['id_objtype'];
$this->id_op = $row['id_op'];
$this->nom = $row['nom_objet'];
$this->num = $row['num_objet'];
$this->cbar = $row['cbar_objet'];
$this->num_serie = $row['num_serie'];
$this->prix = $row['prix_objet'];
$this->caution = $row['caution_objet'];
$this->prix_emprunt = $row['prix_emprunt_objet'];
$this->empruntable = $row['objet_empruntable'];
$this->en_etat = $row['en_etat'];
$this->archive = $row['archive_objet'];
$this->notes = $row['notes_objet'];
$this->date_achat = strtotime($row['date_achat']);
}
function _load ( $row )
{
$this->id = $row['id_objet'];
$this->id_asso = $row['id_asso'];
$this->id_asso_prop = $row['id_asso_prop'];
$this->id_salle = $row['id_salle'];
$this->id_objtype = $row['id_objtype'];
$this->id_op = $row['id_op'];
$this->nom = $row['nom_objet'];
$this->num = $row['num_objet'];
$this->cbar = $row['cbar_objet'];
$this->num_serie = $row['num_serie'];
$this->prix = $row['prix_objet'];
$this->caution = $row['caution_objet'];
$this->prix_emprunt = $row['prix_emprunt_objet'];
$this->empruntable = $row['objet_empruntable'];
$this->en_etat = $row['en_etat'];
$this->archive = $row['archive_objet'];
$this->notes = $row['notes_objet'];
$this->date_achat = strtotime($row['date_achat']);
}
function _determine_special()
{
......@@ -275,15 +275,15 @@ class objet extends stdentity
if ( !isset($this->_is_book) )
{
$req = new requete($this->db, "SELECT id_objet FROM `bk_book`
WHERE `id_objet` = '" . mysql_real_escape_string($this->id) . "'
LIMIT 1");
$req = new requete($this->db, "SELECT id_objet FROM `bk_book`
WHERE `id_objet` = '" . mysql_real_escape_string($this->id) . "'
LIMIT 1");
$this->_is_book = $req->lines == 1;
$req = new requete($this->db, "SELECT id_objet FROM `inv_jeu`
WHERE `id_objet` = '" . mysql_real_escape_string($this->id) . "'
LIMIT 1");
$req = new requete($this->db, "SELECT id_objet FROM `inv_jeu`
WHERE `id_objet` = '" . mysql_real_escape_string($this->id) . "'
LIMIT 1");
$this->_is_jeu = $req->lines == 1;
}
......@@ -310,186 +310,187 @@ class objet extends stdentity
return $this->_is_jeu;
}
function add ( $id_asso, $id_asso_prop, $id_salle, $id_objtype, $id_op, $nom,
$code_objtype, $num_serie, $prix, $caution, $prix_emprunt, $empruntable,
$en_etat, $date_achat, $notes )
{
$sql = new requete ( $this->db, "SELECT MAX(`num_objet`) FROM `inv_objet` " .
"WHERE `id_objtype`='".intval($id_objtype)."'" );
if ( $sql->lines == 1 )
list($pnum) = $sql->get_row();
else
$pnum = 0;
$this->num = $pnum + 1;
$this->id_asso = $id_asso;
$this->id_asso_prop = $id_asso_prop;
$this->id_salle = $id_salle;
$this->id_objtype = $id_objtype;
$this->id_op = $id_op;
$this->nom = $nom;
$this->cbar = sprintf("%s%04d",$code_objtype,$this->num);
$this->num_serie = $num_serie;
$this->prix = $prix;
$this->caution = $caution;
$this->prix_emprunt = $prix_emprunt;
$this->empruntable = $empruntable;
$this->en_etat = $en_etat;
$this->archive = false;
$this->notes = $notes;
$this->date_achat = $date_achat;
$sql = new insert ($this->dbrw,
"inv_objet",
array(
"id_asso" => $this->id_asso,
"id_asso_prop" => $this->id_asso_prop,
"id_salle" => $this->id_salle,
"id_objtype" => $this->id_objtype,
"id_op" => $this->id_op,
"nom_objet" => $this->nom,
"num_objet" => $this->num,
"cbar_objet" => $this->cbar,
"num_serie" => $this->num_serie,