function demandes_types($table, $col_id_name, $col_lib_name, $id_liste = 0) { global $dbh; $this->table = $table; $this->colonne_id_nom = $col_id_name; $this->colonne_lib_nom = $col_lib_name; $this->id_liste = $id_liste; if (!$this->id_liste) { $this->lib_liste = ''; $workflow = new workflow('ACTIONS'); $this->allowed_actions = $workflow->getTypeList(); } else { $req = "select {$this->colonne_lib_nom} as lib,allowed_actions from {$this->table} where {$this->colonne_id_nom} ='" . $this->id_liste . "'"; $res = pmb_mysql_query($req, $dbh); $list = pmb_mysql_fetch_object($res); $this->lib_liste = $list->lib; $this->allowed_actions = unserialize($list->allowed_actions); if (!is_array($this->allowed_actions) || !count($this->allowed_actions)) { $workflow = new workflow('ACTIONS'); $this->allowed_actions = $workflow->getTypeList(); } } $this->setParametres(); }
function fetch_data($id = 0, $lazzy_load = true) { global $base_path, $dbh; if ($this->id_demande && !$id) { $id = $this->id_demande; } elseif (!$this->id_demande && $id) { $this->id_demande = $id; } if ($this->id_demande) { $req = "select etat_demande, date_demande, deadline_demande, sujet_demande, num_demandeur, progression, num_notice,\n\t\t\tdate_prevue, theme_demande, type_demande, titre_demande, libelle_theme,libelle_type, allowed_actions, dmde_read_gestion, dmde_read_opac, num_linked_notice\n\t\t\tfrom demandes d, demandes_theme dt, demandes_type dy\n\t\t\twhere dy.id_type=d.type_demande and dt.id_theme=d.theme_demande and id_demande='" . $this->id_demande . "'"; $res = pmb_mysql_query($req, $dbh); if (pmb_mysql_num_rows($res)) { $dmde = pmb_mysql_fetch_object($res); $this->etat_demande = $dmde->etat_demande; $this->date_demande = $dmde->date_demande; $this->deadline_demande = $dmde->deadline_demande; $this->sujet_demande = $dmde->sujet_demande; $this->num_demandeur = $dmde->num_demandeur; $this->progression = $dmde->progression; $this->date_prevue = $dmde->date_prevue; $this->theme_demande = $dmde->theme_demande; $this->type_demande = $dmde->type_demande; $this->titre_demande = $dmde->titre_demande; $this->theme_libelle = $dmde->libelle_theme; $this->type_libelle = $dmde->libelle_type; $this->num_notice = $dmde->num_notice; $this->allowed_actions = unserialize($dmde->allowed_actions); $this->dmde_read_gestion = $dmde->dmde_read_gestion; $this->dmde_read_opac = $dmde->dmde_read_opac; $this->num_linked_notice = $dmde->num_linked_notice; if (!count($this->allowed_actions)) { $workflow = new workflow('ACTIONS'); $this->allowed_actions = $workflow->getTypeList(); $allowed_actions = array(); foreach ($this->allowed_actions as $allowed_action) { $allowed_action['active'] = 1; $allowed_actions[] = $allowed_action; if ($allowed_action['default']) { $this->first_action = $allowed_action['id']; } } } } else { $this->id_demande = 0; $this->etat_demande = 0; $this->date_demande = '0000-00-00'; $this->deadline_demande = '0000-00-00'; $this->sujet_demande = ''; $this->num_demandeur = 0; $this->progression = 0; $this->date_prevue = '0000-00-00'; $this->theme_demande = 0; $this->type_demande = 0; $this->titre_demande = ''; $this->num_notice = 0; $workflow = new workflow('ACTIONS'); $this->allowed_actions = $workflow->getTypeList(); $allowed_actions = array(); $this->dmde_read_gestion = 0; $this->dmde_read_opac = 0; $this->num_linked_notice = 0; foreach ($this->allowed_actions as $allowed_action) { $allowed_action['active'] = 1; $allowed_actions[] = $allowed_action; if ($allowed_action['default']) { $this->first_action = $allowed_action['id']; } } } $req = "select num_user, concat(prenom,' ',nom) as nom, username, users_statut from demandes_users, users where num_user=userid and num_demande='" . $this->id_demande . "' and users_statut=1"; $res = pmb_mysql_query($req, $dbh); $i = 0; while ($user = pmb_mysql_fetch_object($res)) { $this->users[$i]['nom'] = trim($user->nom) ? $user->nom : $user->username; $this->users[$i]['id'] = $user->num_user; $this->users[$i]['statut'] = $user->users_statut; $i++; } } else { $this->id_demande = 0; $this->etat_demande = 0; $this->date_demande = '0000-00-00'; $this->deadline_demande = '0000-00-00'; $this->sujet_demande = ''; $this->num_demandeur = 0; $this->num_user = array(); $this->progression = 0; $this->date_prevue = '0000-00-00'; $this->theme_demande = 0; $this->type_demande = 0; $this->titre_demande = ''; $this->num_notice = 0; $workflow = new workflow('ACTIONS'); $this->allowed_actions = $workflow->getTypeList(); $allowed_actions = array(); $this->dmde_read_gestion = 0; $this->dmde_read_opac = 0; $this->num_linked_notice = 0; foreach ($this->allowed_actions as $allowed_action) { $allowed_action['active'] = 1; $allowed_actions[] = $allowed_action; if ($allowed_action['default']) { $this->first_action = $allowed_action['id']; } } } if (!sizeof($this->workflow)) { $this->workflow = new workflow('DEMANDES', 'INITIAL'); $this->liste_etat = $this->workflow->getStateList(); } if ($this->id_demande) { $this->actions = array(); //On charge la liste d'id des actions $query = 'SELECT id_action FROM demandes_actions WHERE num_demande=' . $this->id_demande; $result = pmb_mysql_query($query); while ($action = pmb_mysql_fetch_array($result, MYSQL_ASSOC)) { if ($lazzy_load) { $this->actions[$action['id_action']] = new stdClass(); $this->actions[$action['id_action']]->id_action = $action['id_action']; } else { $this->actions[$action['id_action']] = new demandes_actions($action['id_action']); } } if (!$lazzy_load) { $this->last_modified = self::get_last_modified_action($this->actions); } } }