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