1 |
cerini_j |
7172 |
<?php |
2 |
|
|
/** |
3 |
|
|
* Ce script permet de creer un duplicata d'un enregistrement |
4 |
|
|
* et des ses enregistrements liés |
5 |
|
|
* |
6 |
|
|
* @package openfoncier |
7 |
|
|
* @version SVN : $Id: valid_copie.php 4476 2015-04-01 13:40:14Z vpihour $ |
8 |
|
|
* |
9 |
|
|
* @todo Il faut gerer ce script d'une maniere differente : |
10 |
|
|
* il faudrait integrer la duplication d'enregistrement dans |
11 |
|
|
* om_dbform.class.php pour le gerer grace a la meme interface que |
12 |
|
|
* form.php. |
13 |
|
|
*/ |
14 |
|
|
|
15 |
|
|
// Fichier requis |
16 |
|
|
require_once "../obj/utils.class.php"; |
17 |
|
|
require_once '../obj/om_formulaire.class.php'; |
18 |
|
|
|
19 |
|
|
// Instance de la classe utils |
20 |
|
|
$f = new utils(NULL, "copie", _("Copie")); |
21 |
|
|
|
22 |
|
|
// Identifiant de l'objet metier a copier |
23 |
|
|
($f->get_submitted_get_value('idx')!=null ? $idx = $f->get_submitted_get_value('idx') : $idx = ""); |
24 |
|
|
// Nom de l'objet metier |
25 |
|
|
($f->get_submitted_get_value('obj')!=null ? $obj = $f->get_submitted_get_value('obj') : $obj = ""); |
26 |
|
|
// Nom de l'objet metier associe |
27 |
|
|
($f->get_submitted_get_value('objsf')!=null ? $objsf = $f->get_submitted_get_value('objsf') : $objsf = ""); |
28 |
|
|
// Paramètres pour le bouton retour |
29 |
|
|
($f->get_submitted_get_value('premier')!=null ? $premier = $f->get_submitted_get_value('premier') : $premier = 0); |
30 |
|
|
($f->get_submitted_get_value('tricol')!=null ? $tricol = $f->get_submitted_get_value('tricol') : $tricol = ""); |
31 |
|
|
($f->get_submitted_get_value('recherche')!=null ? $recherche = $f->get_submitted_get_value('recherche') : $recherche = ""); |
32 |
|
|
($f->get_submitted_get_value('selectioncol')!=null ? $selectioncol = $f->get_submitted_get_value('selectioncol') : $selectioncol = ""); |
33 |
|
|
($f->get_submitted_get_value('advs_id')!=null ? $advs_id = $f->get_submitted_get_value('advs_id') : $advs_id = ""); |
34 |
|
|
|
35 |
|
|
// Description de la page |
36 |
|
|
$description = _("Cette page permet de dupliquer un enregistrement et ses enregistrements associes."); |
37 |
|
|
$f->displayDescription($description); |
38 |
|
|
|
39 |
|
|
// Bouton retour |
40 |
|
|
$bouton_retour = "<a class=\"retour\" href=". |
41 |
|
|
"\"../scr/tab.php?obj=%s&premier=%s&tricol=%s". |
42 |
|
|
"&recherche=%s&selectioncol=%s&advs_id=%s\">". |
43 |
|
|
_("Retour"). |
44 |
|
|
"</a>"; |
45 |
|
|
|
46 |
|
|
// Si des données sont envoyées par le formulaire |
47 |
|
|
if ($f->get_submitted_post_value('idx')!=null |
48 |
|
|
&& $f->get_submitted_post_value('obj')) { |
49 |
|
|
|
50 |
|
|
// Identifiant de l'objet metier a copier |
51 |
|
|
($f->get_submitted_post_value('idx')!=null ? $idx = $f->get_submitted_post_value('idx') : $idx = ""); |
52 |
|
|
// Nom de l'objet metier |
53 |
|
|
($f->get_submitted_post_value('obj')!=null ? $obj = $f->get_submitted_post_value('obj') : $obj = ""); |
54 |
|
|
// Nom des objets metier associés |
55 |
|
|
($f->get_submitted_post_value('objsf')!=null ? $objsf = $f->get_submitted_post_value('objsf') : $objsf = ""); |
56 |
|
|
// Liste des objets associés |
57 |
|
|
$listObjsf = explode(",", $objsf); |
58 |
|
|
foreach ($listObjsf as $key => $value) { |
59 |
|
|
// Si l'objet n'est pas checké |
60 |
|
|
if (!array_key_exists($value, $f->get_submitted_post_value())) { |
61 |
|
|
// Supprime l'objet de la liste |
62 |
|
|
unset($listObjsf[$key]); |
63 |
|
|
} |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
// Liste des objets associés choisis |
67 |
|
|
$objsf_checked = implode(",", $listObjsf); |
68 |
|
|
|
69 |
|
|
// Utilisation de la fonction copie |
70 |
|
|
$return = $f->copier($idx, $obj, $objsf_checked); |
71 |
|
|
|
72 |
|
|
// Message affiché à l'utilisateur |
73 |
|
|
$message = $return['message']; |
74 |
|
|
// Type du message |
75 |
|
|
$message_type = $return['message_type']; |
76 |
|
|
|
77 |
|
|
// Affiche le message |
78 |
|
|
$f->displayMessage($message_type, $message); |
79 |
|
|
|
80 |
|
|
// Permet de faire une recherche sur l'identifiant du duplicata |
81 |
|
|
$recherche = (isset($return[$obj.'_'.$idx])) ? $return[$obj.'_'.$idx] : ""; |
82 |
|
|
// Permet que la recherche se fasse seulement sur l'identifiant |
83 |
|
|
$selectioncol = 0; |
84 |
|
|
|
85 |
|
|
// Affiche le bouton de retour |
86 |
|
|
printf("<div class=\"formControls\">"); |
87 |
|
|
printf($bouton_retour, $obj, $premier, $tricol, $recherche, $selectioncol, $advs_id); |
88 |
|
|
printf("</div>"); |
89 |
|
|
|
90 |
|
|
// Sinon |
91 |
|
|
} else { |
92 |
|
|
|
93 |
|
|
// Champs du formulaire = objet métier associés |
94 |
|
|
if ($objsf != '') { |
95 |
|
|
$champs = explode(",", $objsf); |
96 |
|
|
} |
97 |
|
|
$champs[] = "idx"; |
98 |
|
|
$champs[] = "obj"; |
99 |
|
|
$champs[] = "objsf"; |
100 |
|
|
|
101 |
|
|
// Création d'un nouvel objet de type formulaire |
102 |
|
|
$form = new formulaire(NULL, 0, 0, $champs); |
103 |
|
|
|
104 |
|
|
// Type des champs |
105 |
|
|
foreach ($champs as $key) { |
106 |
|
|
$form->setType($key, 'checkbox'); |
107 |
|
|
} |
108 |
|
|
$form->setType("idx", 'hidden'); |
109 |
|
|
$form->setType("obj", 'hidden'); |
110 |
|
|
$form->setType("objsf", 'hidden'); |
111 |
|
|
|
112 |
|
|
// Libellés des champs |
113 |
|
|
foreach ($champs as $key) { |
114 |
|
|
$form->setLib($key, _($key)); |
115 |
|
|
} |
116 |
|
|
|
117 |
|
|
// Valeur des champs |
118 |
|
|
foreach ($champs as $key) { |
119 |
|
|
$form->setVal($key, 'f'); |
120 |
|
|
} |
121 |
|
|
$form->setVal("idx", $idx); |
122 |
|
|
$form->setVal("obj", $obj); |
123 |
|
|
$form->setVal("objsf", $objsf); |
124 |
|
|
|
125 |
|
|
// Affichage des champs |
126 |
|
|
$i = 0; |
127 |
|
|
$lastKey = ""; |
128 |
|
|
foreach ($champs as $key) { |
129 |
|
|
if ($i == 0) { |
130 |
|
|
$form->setFieldset($key, 'D', _("Liste des objets associes"), ""); |
131 |
|
|
} |
132 |
|
|
$form->setBloc($key, 'DF', "", ""); |
133 |
|
|
$lastKey = $key; |
134 |
|
|
$i++; |
135 |
|
|
} |
136 |
|
|
$form->setFieldset($lastKey, 'F'); |
137 |
|
|
|
138 |
|
|
// Ouverture du formulaire |
139 |
|
|
printf("<form method=\"POST\" action=\"valid_copie.php?obj=".$obj."&objsf=bible,lien_dossier_instruction_type_evenement,transition&idx=".$idx."&premier=".$premier."&tricol=".$tricol."&recherche=".$recherche."&selectioncol=".$selectioncol."&advs_id=".$advs_id."\" name=\"f2\">"); |
140 |
|
|
|
141 |
|
|
// Champs du formulaire |
142 |
|
|
$form->entete(); |
143 |
|
|
$form->afficher($champs, 0, false, false); |
144 |
|
|
if ($objsf == '') { |
145 |
|
|
printf(_("Aucun objet associe existant.")); |
146 |
|
|
} |
147 |
|
|
$form->enpied(); |
148 |
|
|
|
149 |
|
|
// Bouton "Copier" et "Retour" |
150 |
|
|
printf("<div class=\"formControls\">"); |
151 |
|
|
printf('<input id="button-%1$s" type="submit" class="om-button ui-button ui-widget ui-state-default ui-corner-all" value="%1$s" role="button" aria-disabled="false">', _("Copier")); |
152 |
|
|
printf($bouton_retour, $obj, $premier, $tricol, $recherche, $selectioncol, $advs_id); |
153 |
|
|
printf("</div>"); |
154 |
|
|
|
155 |
|
|
// Fermeture du formulaire |
156 |
|
|
printf("</form>"); |
157 |
|
|
} |
158 |
|
|
|
159 |
|
|
?> |