398 |
} |
} |
399 |
|
|
400 |
/** |
/** |
|
* Surcharge de la méthode formulaire afin d'y ajouter |
|
|
* la méthode de verification d'accès à l'élément |
|
|
* |
|
|
*/ |
|
|
function formulaire($enteteTab, $validation, $maj, &$db, $postVar, $aff, |
|
|
$DEBUG = false, $idx, $premier = 0, $recherche = "", |
|
|
$tricol = "", $idz = "", $selectioncol = "", |
|
|
$advs_id = "", $valide = "", $retour = "", $actions = array(), |
|
|
$extra_parameters = array()) { |
|
|
|
|
|
// Mode debug desactive |
|
|
$DEBUG = false; |
|
|
// Affectation des parametres dans un tableau associatif pour le |
|
|
// stocker en attribut de l'objet |
|
|
$parameters = array( |
|
|
"aff" => $aff, |
|
|
"validation" => $validation, |
|
|
"maj" => $maj, |
|
|
"idx" => $idx, |
|
|
"premier" => $premier, |
|
|
"recherche" => $recherche, |
|
|
"tricol" => $tricol, |
|
|
"idz" => $idz, |
|
|
"selectioncol" => $selectioncol, |
|
|
"advs_id" => $advs_id, |
|
|
"valide" => $valide, |
|
|
"retour" => $retour, |
|
|
); |
|
|
// Affectation du tableau precedant dans l'attribut 'parameters' |
|
|
$this->setParameters($parameters); |
|
|
// Affectation du tableau passe en parametre dans l'attribut 'parameters' |
|
|
$this->setParameters($extra_parameters); |
|
|
// Ouverture de la balise form si pas en consultation |
|
|
if($maj!=3) { |
|
|
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
|
|
echo "<form"; |
|
|
echo " method=\"post\""; |
|
|
echo " name=\"f1\""; |
|
|
echo " action=\""; |
|
|
echo $this->getDataSubmit(); |
|
|
echo "\""; |
|
|
echo ">\n"; |
|
|
} |
|
|
// Compatibilite anterieure - On decremente la variable validation |
|
|
$this->setParameter("validation", $this->getParameter("validation") - 1); |
|
|
// Instanciation de l'objet formulaire |
|
|
$this->form = new $this->om_formulaire($enteteTab, $this->getParameter("validation"), $maj, $this->champs, $this->val, $this->longueurMax); |
|
|
// Valorisation des variables formulaires |
|
|
$this->setVal($this->form, $maj, $this->getParameter("validation"), $this->db, $DEBUG); |
|
|
$this->setType($this->form, $maj); |
|
|
$this->setLib($this->form, $maj); |
|
|
$this->setTaille($this->form, $maj); |
|
|
$this->setMax($this->form, $maj); |
|
|
$this->setSelect($this->form, $maj, $this->db, $DEBUG); |
|
|
$this->setOnchange($this->form, $maj); |
|
|
$this->setOnkeyup($this->form, $maj); |
|
|
$this->setOnclick($this->form, $maj); |
|
|
$this->setGroupe($this->form, $maj); |
|
|
$this->setRegroupe($this->form, $maj); |
|
|
$this->setLayout($this->form, $maj); |
|
|
$this->setRequired($this->form, $maj); |
|
|
// |
|
|
$this->form->recupererPostvar($this->champs, $this->getParameter("validation"), $postVar, $DEBUG); |
|
|
// Si le formulaire a ete valide |
|
|
if ($this->getParameter("validation") > 0) { |
|
|
// Appel des methodes en fonction du mode pour inserer, modifier ou |
|
|
// supprimer l'objet de/dans la base de donnees. |
|
|
if ($maj == 2) { |
|
|
// (MODE 'delete') |
|
|
$db->autoCommit(false); |
|
|
$this->supprimer($this->form->val, $this->db, $DEBUG); |
|
|
$db->commit(); |
|
|
} else { |
|
|
if ($maj == 1) { |
|
|
// (MODE 'update') |
|
|
$db->autoCommit(false); |
|
|
$this->modifier($this->form->val, $this->db, $DEBUG); |
|
|
$db->commit(); |
|
|
} else { |
|
|
// (MODE 'insert') |
|
|
$db->autoCommit(false); |
|
|
$this->ajouter($this->form->val, $this->db, $DEBUG) ; |
|
|
$db->commit(); |
|
|
} |
|
|
} |
|
|
} |
|
|
// Desactivation du verrou |
|
|
$this->deverrouille($this->getParameter("validation")); |
|
|
// Si le formulaire a ete valide |
|
|
if ($this->getParameter("validation") > 0) { |
|
|
// Affichage du message avant d'afficher le formulaire |
|
|
$this->message(); |
|
|
// Si le formulaire est valide |
|
|
if ($this->correct) { |
|
|
// Affichage du bouton retour |
|
|
$this->retour($premier, $recherche, $tricol); |
|
|
} |
|
|
} |
|
|
//Test les droits d'accès à l'élément. |
|
|
if(!$this->canAccess() AND $maj != 0) { |
|
|
// |
|
|
$message_class = "error"; |
|
|
$message = _("Droits insuffisants. Vous n'avez pas suffisament de ". |
|
|
"droits pour acceder a cette page."); |
|
|
$this->f->addToMessage($message_class, $message); |
|
|
|
|
|
// |
|
|
$this->f->setFlag(NULL); |
|
|
$this->f->display(); |
|
|
|
|
|
// Arrêt du script |
|
|
die(); |
|
|
} |
|
|
// Affichage du contenu du formulaire |
|
|
$this->form->entete(); |
|
|
|
|
|
// Portlet d'actions contextuelles |
|
|
if ($maj == 3 and !empty($actions)) { |
|
|
|
|
|
// On surcharge les actions |
|
|
if (!empty($this->actions_sup)) { |
|
|
$actions = array_merge($actions, $this->actions_sup); |
|
|
} |
|
|
|
|
|
// On retient seulement les actions de l'utilisateur |
|
|
$user_actions = array(); |
|
|
foreach($actions as $action => $conf) { |
|
|
|
|
|
// Verification des droits |
|
|
if (!isset($conf['rights']) |
|
|
or $this->f->isAccredited($conf['rights']['list'], |
|
|
$conf['rights']['operator'])) { |
|
|
|
|
|
// Preparation du tri |
|
|
if (!isset($conf['ordre']) or empty($conf['ordre'])) { |
|
|
|
|
|
$this->actions_order[] = array($action); |
|
|
} else if (!key_exists($conf['ordre'], |
|
|
$this->actions_order)) { |
|
|
|
|
|
$this->actions_order[$conf['ordre']] = array($action); |
|
|
} else { |
|
|
|
|
|
$this->actions_order[$conf['ordre']][] = $action; |
|
|
asort($this->actions_order[$conf['ordre']]); |
|
|
} |
|
|
|
|
|
// Verification de l'action (vide ou non) |
|
|
if (!empty($conf['lien']) and $conf['lien'] != '#') { |
|
|
$user_actions[$action] = $conf; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
ksort($this->actions_order); |
|
|
|
|
|
// Affichage du portlet d'actions s'il existe des actions |
|
|
if (!empty($user_actions)) { |
|
|
$this->form->afficher_portlet($idx, $user_actions, |
|
|
$this->actions_order); |
|
|
} |
|
|
} |
|
|
|
|
|
$this->form->afficher($this->champs, $this->getParameter("validation"), $DEBUG, $this->correct); |
|
|
$this->form->enpied(); |
|
|
|
|
|
// Affichage du bouton et du bouton retour |
|
|
echo "\n<!-- ########## START FORMCONTROLS ########## -->\n"; |
|
|
echo "<div class=\"formControls\">\n"; |
|
|
if($maj!=3) { |
|
|
$this->bouton($maj); |
|
|
} |
|
|
$this->retour($premier, $recherche, $tricol); |
|
|
echo "</div>\n"; |
|
|
echo "<!-- ########## END FORMCONTROLS ########## -->\n"; |
|
|
// Fermeture de la balise form |
|
|
if($maj!=3) { |
|
|
echo "</form>\n"; |
|
|
echo "<!-- ########## END DBFORM ########## -->\n"; |
|
|
} |
|
|
// Sous formulaire interne et zone supplementaire |
|
|
if ($maj == 1) { |
|
|
$this->sousformulaireinterne(get_class($this), $idx, $this->db); |
|
|
} else { |
|
|
if ($maj == 0 and isset($this->valF[$this->clePrimaire]) and $this->valF[$this->clePrimaire] != "") { |
|
|
$this->sousformulaireinterne(get_class($this), $this->valF[$this->clePrimaire], $this->db); |
|
|
} |
|
|
} |
|
|
} |
|
|
/** |
|
|
* Surcharge de la méthode sousformulaire afin d'y ajouter |
|
|
* la méthode de verification d'accès à l'élément |
|
|
* |
|
|
*/ |
|
|
function sousformulaire($enteteTab, $validation, $maj, &$db, $postVar, |
|
|
$premiersf, $DEBUG, $idx, $idxformulaire, |
|
|
$retourformulaire, $typeformulaire, $objsf, |
|
|
$tricolsf, $retour= "", $actions = array()) { |
|
|
|
|
|
/* |
|
|
$enteteTab: libelle d entete du formulaire |
|
|
$styleform: style des controles du formulaires |
|
|
$maj : 0 ajouter / 1 mise a jour / 2 suppression |
|
|
$db : connexion base de donnees |
|
|
$aff : appel formulaire |
|
|
$DEBUG : 0= normal / 1= debugage |
|
|
$idx : valeur de l'id de la table mouvement (pour relancer la requete |
|
|
$idxformulaire : idx du formulaire |
|
|
$retourformulaire : nom du formulaire de retour |
|
|
*/ |
|
|
//passage tricolonne soustableau par $tricolsf |
|
|
$DEBUG=0; |
|
|
|
|
|
// Affectation des parametres dans un tableau associatif pour le |
|
|
// stocker en attribut de l'objet |
|
|
$parameters = array( |
|
|
"validation" => $validation, |
|
|
"maj" => $maj, |
|
|
"idx" => $idx, |
|
|
"idxformulaire" => $idxformulaire, |
|
|
"premiersf" => $premiersf, |
|
|
"tricolsf" => $tricolsf, |
|
|
"retour" => $retour, |
|
|
"retourformulaire" => $retourformulaire, |
|
|
"typeformulaire" => $typeformulaire, |
|
|
"objsf" => $objsf, |
|
|
); |
|
|
// Affectation du tableau precedant dans l'attribut 'parameters' |
|
|
$this->setParameters($parameters); |
|
|
|
|
|
//sousformulaire genere par ajax [sub form with ajax] |
|
|
$datasubmit=""; |
|
|
|
|
|
// sans idx [without idx] |
|
|
if ($idx=="]") { |
|
|
|
|
|
// ajouter [add] |
|
|
if($maj==0) { |
|
|
$datasubmit="../scr/sousform.php?obj=$objsf&premiersf=$premiersf&retourformulaire=$retourformulaire&idxformulaire=$idxformulaire&trisf=$tricolsf". |
|
|
"&validation=$validation&retour=$retour"; |
|
|
} |
|
|
|
|
|
// avec idx [with idx] |
|
|
} else { |
|
|
|
|
|
// modifier [modify] |
|
|
if($maj==1) { |
|
|
$datasubmit="../scr/sousform.php?obj=$objsf&premiersf=$premiersf&retourformulaire=$retourformulaire&idxformulaire=$idxformulaire&trisf=$tricolsf". |
|
|
"&validation=$validation&idx=$idx&retour=$retour"; |
|
|
|
|
|
// supprimer [delete] |
|
|
} else { |
|
|
$datasubmit="../scr/sousform.php?obj=$objsf&premiersf=$premiersf&retourformulaire=$retourformulaire&idxformulaire=$idxformulaire&trisf=$tricolsf". |
|
|
"&validation=$validation&ids=1&idx=$idx&retour=tab"; |
|
|
} |
|
|
} |
|
|
if($maj!=3) { |
|
|
echo "<form name=\"f2\" action=\"\" methode=\"post\" "; |
|
|
echo "onsubmit=\"affichersform('".$objsf."', '$datasubmit', this);return false;\" >"; |
|
|
} |
|
|
$validation--; // compatibilite anterieure |
|
|
$form = new $this->om_formulaire($enteteTab, $validation, $maj, $this->champs,$this->val,$this->longueurMax); |
|
|
$this->form = $form; |
|
|
//-------------------------------------------------------------------------- |
|
|
// valorisation des variables formulaires [form variables values] |
|
|
//-------------------------------------------------------------------------- |
|
|
$this->setValsousformulaire($form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,$db,$DEBUG); |
|
|
$this->setType($form,$maj) ; |
|
|
$this->setLib($form,$maj) ; |
|
|
$this->setTaille($form,$maj) ; |
|
|
$this->setMax($form,$maj) ; |
|
|
$this->setSelect($form,$maj,$db,$DEBUG) ; |
|
|
$this->setOnchange($form,$maj) ; |
|
|
$this->setOnkeyup($form,$maj) ; |
|
|
$this->setOnclick($form,$maj) ; |
|
|
$this->setGroupe($form,$maj) ; |
|
|
$this->setRegroupe($form,$maj) ; |
|
|
$this->setLayout($form, $maj); |
|
|
$this->setRequired($form, $maj); |
|
|
//-------------------------------------------------------------------------- |
|
|
// affichage du formulaire |
|
|
// ------------------------------------------------------------------------- |
|
|
|
|
|
$form->recupererPostvarsousform($this->champs,$validation,$postVar,$DEBUG); |
|
|
|
|
|
// validation ============================================================== |
|
|
if ($validation>0) { |
|
|
if ($maj==2){ |
|
|
$db->autoCommit(false); |
|
|
$this->supprimer($form->val,$db,$DEBUG); |
|
|
$db->commit() ; |
|
|
} else { |
|
|
if ($maj==1) { |
|
|
$db->autoCommit(false); |
|
|
$this->modifier($form->val,$db,$DEBUG); |
|
|
$db->commit() ; |
|
|
} else { |
|
|
$db->autoCommit(false); |
|
|
$this->ajouter($form->val,$db,$DEBUG,$idx) ; |
|
|
$db->commit() ; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
$this->deverrouille($validation); |
|
|
if ($validation > 0) { |
|
|
$this->message(); |
|
|
if ($this->correct) { |
|
|
$this->retoursousformulaire($idxformulaire,$retourformulaire,$form->val,$objsf,$premiersf,$tricolsf, $validation, $idx,$maj, $retour); |
|
|
} |
|
|
} |
|
|
//Test les droits d'accès à l'élément. |
|
|
if(!$this->canAccess() AND $maj != 0) { |
|
|
// |
|
|
$message_class = "error"; |
|
|
$message = _("Droits insuffisants. Vous n'avez pas suffisament de ". |
|
|
"droits pour acceder a cette page."); |
|
|
$this->f->addToMessage($message_class, $message); |
|
|
|
|
|
// |
|
|
$this->f->setFlag(NULL); |
|
|
$this->f->display(); |
|
|
|
|
|
// Arrêt du script |
|
|
die(); |
|
|
} |
|
|
$form->entete(); |
|
|
|
|
|
// Portlet d'actions contextuelles |
|
|
if ($maj == 3 and !empty($actions)) { |
|
|
|
|
|
// On surcharge les actions |
|
|
if (!empty($this->actions_sup)) { |
|
|
$actions = array_merge($actions, $this->actions_sup); |
|
|
} |
|
|
|
|
|
// On retient seulement les actions de l'utilisateur |
|
|
$user_actions = array(); |
|
|
foreach($actions as $action => $conf) { |
|
|
|
|
|
// Verification des droits |
|
|
if (!isset($conf['rights']) |
|
|
or $this->f->isAccredited($conf['rights']['list'], |
|
|
$conf['rights']['operator'])) { |
|
|
|
|
|
// Preparation du tri |
|
|
if (!isset($conf['ordre']) or empty($conf['ordre'])) { |
|
|
|
|
|
$this->actions_order[] = array($action); |
|
|
} else if (!key_exists($conf['ordre'], |
|
|
$this->actions_order)) { |
|
|
|
|
|
$this->actions_order[$conf['ordre']] = array($action); |
|
|
} else { |
|
|
|
|
|
$this->actions_order[$conf['ordre']][] = $action; |
|
|
asort($this->actions_order[$conf['ordre']]); |
|
|
} |
|
|
|
|
|
// Verification de l'action (vide ou non) |
|
|
if (!empty($conf['lien']) and $conf['lien'] != '#') { |
|
|
$user_actions[$action] = $conf; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
ksort($this->actions_order); |
|
|
|
|
|
// Affichage du portlet d'actions s'il existe des actions |
|
|
if (!empty($user_actions)) { |
|
|
$this->form->afficher_portlet($idx, $user_actions, |
|
|
$this->actions_order, $objsf); |
|
|
} |
|
|
} |
|
|
|
|
|
$form->afficher($this->champs,$validation,$DEBUG,$this->correct); |
|
|
$form->enpied(); |
|
|
|
|
|
echo "<div class=\"formControls\">"; |
|
|
if($maj!=3) { |
|
|
$this->boutonsousformulaire($datasubmit,$maj,$form->val); |
|
|
} |
|
|
$this->retoursousformulaire($idxformulaire,$retourformulaire,$form->val,$objsf,$premiersf,$tricolsf, $validation, $idx,$maj, $retour); |
|
|
echo "</div>\n"; |
|
|
if($maj!=3) { |
|
|
echo "</form>"; |
|
|
} |
|
|
// --------------------- |
|
|
// sousformulaireinterne |
|
|
// --------------------- |
|
|
//if($maj==1) { |
|
|
// $this->sousformulaireinterne(get_class($this),$idx,$db); |
|
|
//} |
|
|
if($maj==1) { // moyen_com |
|
|
$this->sousformulaireinterne(get_class($this),$idx,$db); |
|
|
}else{ |
|
|
if ($maj == 0 and isset($this->valF[$this->clePrimaire]) |
|
|
and $this->valF[$this->clePrimaire] != "") { |
|
|
$this->sousformulaireinterne(get_class($this),$this->valF[$this->clePrimaire],$db); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
401 |
* Methode de verification de l'unicite d'une valeur pour chaque elements du tableau unique_key, |
* Methode de verification de l'unicite d'une valeur pour chaque elements du tableau unique_key, |
402 |
* ainsi que l'unicite de la cle multiple unique_multiple_key. |
* ainsi que l'unicite de la cle multiple unique_multiple_key. |
403 |
* |
* |
642 |
$this->errors[$key] = ''; |
$this->errors[$key] = ''; |
643 |
} |
} |
644 |
} |
} |
|
|
|
|
/** |
|
|
* Cette methode est à surcharger elle permet de tester dans chaque classe |
|
|
* des droits des droits spécifiques en fonction des données |
|
|
*/ |
|
|
function canAccess() { |
|
|
return true; |
|
|
} |
|
|
|
|
645 |
} |
} |
646 |
|
|
647 |
?> |
?> |