demande-avenant2.php 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. <!DOCTYPE html>
  2. <html lang="fr">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Demande d'Avenant - SIPA Automobiles</title>
  7. <script src="https://cdn.tailwindcss.com"></script>
  8. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
  9. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/preline/dist/preline.css" />
  10. <style>
  11. .readonly-field { background-color: rgb(243, 244, 246); color: rgb(107, 114, 128); cursor: not-allowed; }
  12. @media (prefers-color-scheme: dark) {
  13. .readonly-field { background-color: rgb(38, 38, 38); color: rgb(163, 163, 163); }
  14. }
  15. .panel-pre-avenant { background-color: rgb(254 242 242); border-color: rgb(254 202 202); }
  16. .panel-post-avenant { background-color: rgb(240 253 244); border-color: rgb(187 247 208); }
  17. @media (prefers-color-scheme: dark) {
  18. .panel-pre-avenant { background-color: rgb(69 10 10 / 0.35); border-color: rgb(127 29 29); }
  19. .panel-post-avenant { background-color: rgb(6 78 59 / 0.35); border-color: rgb(20 83 45); }
  20. }
  21. /* Encarts blancs à l’intérieur des panneaux pré/post (fond rouge/vert visible autour) */
  22. .avenant-panel-section {
  23. border-radius: 0.5rem;
  24. border: 1px solid rgb(229 231 235);
  25. background-color: rgb(255 255 255);
  26. padding: 1rem;
  27. box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  28. }
  29. @media (prefers-color-scheme: dark) {
  30. .avenant-panel-section {
  31. border-color: rgb(82 82 82);
  32. background-color: rgb(10 10 10);
  33. }
  34. }
  35. .conditional-field { display: none; }
  36. .conditional-field.is-active { display: block; }
  37. .conditional-field.is-active.grid { display: grid; }
  38. .conditional-field.is-active.flex { display: flex; }
  39. @keyframes fadeInUp {
  40. from { opacity: 0; transform: translateY(12px); }
  41. to { opacity: 1; transform: translateY(0); }
  42. }
  43. .animate-fade-in-up { animation: fadeInUp 0.4s ease-out; }
  44. input[type="radio"], input[type="checkbox"] { accent-color: #21B6BA; }
  45. .person-badge {
  46. display: inline-flex; align-items: center; gap: 0.5rem;
  47. padding: 0.375rem 0.75rem; background-color: #21B6BA; color: white;
  48. border-radius: 0.5rem; font-size: 0.875rem;
  49. }
  50. .person-badge button { background: transparent; border: none; color: white; cursor: pointer; padding: 0; }
  51. </style>
  52. </head>
  53. <body class="bg-gray-50 dark:bg-neutral-900">
  54. <?php $skip_default_content = true; include 'menu.php'; ?>
  55. <div class="pt-12 lg:pt-16 lg:ps-64">
  56. <div class="min-h-screen p-4 md:p-8">
  57. <div class="mb-6">
  58. <h1 class="text-2xl font-semibold text-[#21B6BA]">Demande d'Avenant</h1>
  59. <p class="mt-1 text-sm text-gray-600 dark:text-neutral-400">
  60. Saisie pré-avenant (fond rouge clair) et post-avenant (fond vert clair). Vous pouvez ne renseigner qu’une partie du formulaire (ex. rémunération uniquement) ; en revanche, pour chaque champ, si la valeur pré ou post est renseignée, la valeur correspondante de l’autre côté doit l’être aussi.
  61. </p>
  62. </div>
  63. <form id="form-avenant" class="space-y-6">
  64. <input type="hidden" name="demande_id" id="demande_id" value="">
  65. <!-- 1. Informations de suivi -->
  66. <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700">
  67. <div class="p-6">
  68. <h2 class="text-lg font-semibold text-gray-800 dark:text-white mb-4">Informations de suivi</h2>
  69. <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
  70. <div>
  71. <label class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Créé par</label>
  72. <input type="text" readonly class="readonly-field py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:border-neutral-700" value="Sophie Bernard (RH)">
  73. </div>
  74. <div>
  75. <label class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Date de création</label>
  76. <input type="text" readonly class="readonly-field py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:border-neutral-700" value="07 mai 2026 10:00">
  77. </div>
  78. <div>
  79. <label for="statut_global" class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Statut de la demande</label>
  80. <select id="statut_global" name="statut_global" disabled class="py-3 px-4 w-full border border-gray-200 rounded-lg text-sm bg-gray-50 dark:bg-neutral-900 dark:border-neutral-700 opacity-70">
  81. <option value="nouveau" selected>Nouveau</option>
  82. <option value="en_cours">En cours</option>
  83. <option value="valide">Validé</option>
  84. </select>
  85. </div>
  86. <div class="md:col-span-3">
  87. <label class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Site</label>
  88. <input type="text" readonly class="readonly-field py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:border-neutral-700" value="Auto 33" aria-readonly="true">
  89. <input type="hidden" name="site_selectionne" id="site_selectionne" value="auto33">
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. <!-- 2. Informations personnelles -->
  95. <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700 animate-fade-in-up">
  96. <div class="p-6">
  97. <h2 class="text-lg font-semibold text-gray-800 dark:text-white mb-4">Informations personnelles</h2>
  98. <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
  99. <div>
  100. <label class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Prénom</label>
  101. <input type="text" id="prenom_collab" name="prenom_collab" readonly class="readonly-field py-3 px-4 w-full border rounded-lg text-sm dark:border-neutral-700" value="Jean">
  102. </div>
  103. <div>
  104. <label class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Nom</label>
  105. <input type="text" id="nom_collab" name="nom_collab" readonly class="readonly-field py-3 px-4 w-full border rounded-lg text-sm dark:border-neutral-700" value="DUPONT">
  106. </div>
  107. <div>
  108. <label for="date_effet_avenant" class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Date d’effet de l’avenant <span class="text-red-500">*</span></label>
  109. <input type="text" id="date_effet_avenant" name="date_effet_avenant" required placeholder="jj/mm/aaaa"
  110. class="py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  111. </div>
  112. <div>
  113. <label for="email_pro_collab" class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Email professionnel</label>
  114. <input type="email" id="email_pro_collab" name="email_pro_collab" readonly class="readonly-field py-3 px-4 w-full border rounded-lg text-sm dark:border-neutral-700" value="jean.dupont@sipa-automobiles.fr">
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. <!-- 3. Type de contrat -->
  120. <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700">
  121. <div class="p-6">
  122. <h2 class="text-lg font-semibold text-gray-800 dark:text-white mb-4">Informations sur le collaborateur concerné</h2>
  123. <p class="text-sm text-gray-600 dark:text-neutral-400 mb-4">Type de contrat pris en compte pour l’avenant</p>
  124. <div class="flex flex-wrap gap-6">
  125. <div class="flex items-center gap-2">
  126. <input type="radio" name="type_contrat_avenant" id="type_cdi" value="CDI" class="shrink-0 border-gray-200 rounded-full" checked>
  127. <label for="type_cdi" class="text-sm text-gray-700 dark:text-neutral-300">CDI</label>
  128. </div>
  129. <div class="flex items-center gap-2">
  130. <input type="radio" name="type_contrat_avenant" id="type_cdd" value="CDD" class="shrink-0 border-gray-200 rounded-full">
  131. <label for="type_cdd" class="text-sm text-gray-700 dark:text-neutral-300">CDD</label>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. <!-- 4a. Section CDI pré/post -->
  137. <div id="bloc-section-cdi" class="space-y-4">
  138. <h2 class="text-lg font-semibold text-gray-800 dark:text-white px-1">Section CDI</h2>
  139. <div class="grid grid-cols-1 xl:grid-cols-2 gap-4">
  140. <?php
  141. foreach ([['pre','Pré-avenant','panel-pre-avenant'],['post','Post-avenant','panel-post-avenant']] as $t) {
  142. $s = $t[0]; $label = $t[1]; $panel = $t[2];
  143. ?>
  144. <div class="rounded-xl border-2 p-4 md:p-6 space-y-6 <?php echo $panel; ?>">
  145. <p class="text-sm font-bold text-gray-800 dark:text-white border-b border-gray-300/50 dark:border-neutral-600 pb-2"><?php echo htmlspecialchars($label); ?></p>
  146. <div class="avenant-panel-section">
  147. <h3 class="text-sm font-semibold text-gray-700 dark:text-neutral-300 mb-3">Planning</h3>
  148. <label class="inline-flex items-center gap-2">
  149. <input type="checkbox" name="samedi_cdi_<?php echo $s; ?>" id="samedi_cdi_<?php echo $s; ?>" value="1" class="rounded border-gray-200">
  150. <span class="text-sm text-gray-700 dark:text-neutral-300">Samedi travaillé ?</span>
  151. </label>
  152. </div>
  153. <div class="avenant-panel-section">
  154. <h3 class="text-sm font-semibold text-gray-700 dark:text-neutral-300 mb-3">Manager</h3>
  155. <div class="space-y-3">
  156. <div>
  157. <label class="block text-xs font-medium mb-1 text-gray-600 dark:text-neutral-400">Qui sera son manager ?</label>
  158. <input type="text" name="manager_recherche_<?php echo $s; ?>" placeholder="Prénom ou nom du manager"
  159. class="py-2.5 px-3 w-full border border-gray-200 rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  160. </div>
  161. <div>
  162. <span class="block text-xs font-medium mb-2 text-gray-600 dark:text-neutral-400">Sera-t-il lui-même manager ?</span>
  163. <div class="flex gap-4">
  164. <label class="inline-flex items-center gap-2"><input type="radio" name="est_manager_cdi_<?php echo $s; ?>" value="oui" class="est-manager-cdi" data-side="<?php echo $s; ?>"> <span class="text-sm">Oui</span></label>
  165. <label class="inline-flex items-center gap-2"><input type="radio" name="est_manager_cdi_<?php echo $s; ?>" value="non" checked class="est-manager-cdi" data-side="<?php echo $s; ?>"> <span class="text-sm">Non</span></label>
  166. </div>
  167. </div>
  168. <div id="wrap-supervisees-cdi-<?php echo $s; ?>" class="conditional-field">
  169. <label class="block text-xs font-medium mb-1">Ajouter les personnes supervisées</label>
  170. <div class="flex gap-2">
  171. <input type="text" id="input-supervisee-cdi-<?php echo $s; ?>" placeholder="Prénom NOM" class="flex-1 py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  172. <button type="button" class="btn-add-supervisee px-3 py-2 bg-[#21B6BA] text-white rounded-lg text-sm" data-target="cdi-<?php echo $s; ?>">Ajouter</button>
  173. </div>
  174. <div id="badges-cdi-<?php echo $s; ?>" class="flex flex-wrap gap-2 mt-2 min-h-[36px]"></div>
  175. <input type="hidden" name="personnes_supervisees_cdi_<?php echo $s; ?>" id="hidden-supervisees-cdi-<?php echo $s; ?>" value="">
  176. </div>
  177. </div>
  178. </div>
  179. <div class="avenant-panel-section">
  180. <h3 class="text-sm font-semibold text-gray-700 dark:text-neutral-300 mb-3">Contrat</h3>
  181. <div class="grid grid-cols-1 gap-3">
  182. <div>
  183. <label class="block text-xs mb-1">Service</label>
  184. <select name="service_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm bg-white dark:bg-neutral-900 dark:border-neutral-700">
  185. <option value="">Sélectionner</option>
  186. <option value="vente_pra">Vente P.R.A.</option>
  187. <option value="apres_vente">Après-Vente</option>
  188. <option value="administration">Administration</option>
  189. </select>
  190. </div>
  191. <div>
  192. <label class="block text-xs mb-1">Intitulé de poste</label>
  193. <select name="intitule_poste_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  194. <option value="">Sélectionner</option>
  195. <option value="conseiller">Conseiller commercial</option>
  196. <option value="chef">Chef des ventes</option>
  197. </select>
  198. </div>
  199. <div>
  200. <label class="block text-xs mb-1">Statut</label>
  201. <select name="statut_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  202. <option value="">Sélectionner</option>
  203. <option value="ouvrier">Ouvrier</option>
  204. <option value="employe">Employé</option>
  205. <option value="am">Agent de maîtrise</option>
  206. <option value="cadre">Cadre</option>
  207. </select>
  208. </div>
  209. <div>
  210. <label class="block text-xs mb-1">Échelon</label>
  211. <select name="echelon_<?php echo $s; ?>" class="echelon-select py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>" data-context="cdi">
  212. <option value="">Sélectionner</option>
  213. <option value="III_A">III A</option>
  214. <option value="III_B">III B</option>
  215. <option value="III_C">III C</option>
  216. </select>
  217. </div>
  218. <div class="table-minima-wrap rounded-lg border border-gray-200 dark:border-neutral-600 overflow-hidden text-xs" id="minima-cdi-<?php echo $s; ?>">
  219. <table class="w-full">
  220. <thead class="bg-gray-100 dark:bg-neutral-800"><tr>
  221. <th class="text-left p-2">Échelon</th><th class="p-2">35h</th><th class="p-2">37h</th><th class="p-2">39h</th>
  222. </tr></thead>
  223. <tbody class="bg-white dark:bg-neutral-900"><tr>
  224. <td class="p-2 font-medium">—</td><td class="p-2">—</td><td class="p-2">—</td><td class="p-2">—</td>
  225. </tr></tbody>
  226. </table>
  227. </div>
  228. </div>
  229. </div>
  230. <div class="avenant-panel-section">
  231. <h3 class="text-sm font-semibold text-gray-700 dark:text-neutral-300 mb-3">Rémunération</h3>
  232. <div class="space-y-3">
  233. <div>
  234. <span class="block text-xs mb-2">Temps partiel ?</span>
  235. <div class="flex gap-4">
  236. <label class="inline-flex items-center gap-2"><input type="radio" name="temps_partiel_cdi_<?php echo $s; ?>" value="non" checked class="tp-cdi" data-side="<?php echo $s; ?>"> Non</label>
  237. <label class="inline-flex items-center gap-2"><input type="radio" name="temps_partiel_cdi_<?php echo $s; ?>" value="oui" class="tp-cdi" data-side="<?php echo $s; ?>"> Oui</label>
  238. </div>
  239. </div>
  240. <div id="tp-oui-cdi-<?php echo $s; ?>" class="conditional-field space-y-2">
  241. <label class="block text-xs">Salaire temps partiel brut mensuel (€)</label>
  242. <input type="text" name="salaire_tp_cdi_<?php echo $s; ?>" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="0.00">
  243. <label class="block text-xs">Base horaire (h / semaine)</label>
  244. <input type="text" name="base_horaire_tp_cdi_<?php echo $s; ?>" placeholder="ex. 27" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  245. </div>
  246. <div id="tp-non-cdi-<?php echo $s; ?>" class="space-y-2">
  247. <label class="block text-xs">Base horaire</label>
  248. <select name="base_horaire_cdi_<?php echo $s; ?>" class="base-horaire-cdi py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>">
  249. <option value="">Sélectionner</option>
  250. <option value="35">35h</option>
  251. <option value="37">37h</option>
  252. <option value="39">39h (forfait)</option>
  253. </select>
  254. <label class="block text-xs">Salaire mensuel brut</label>
  255. <input type="text" name="salaire_cdi_<?php echo $s; ?>" class="salaire-cdi py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>" placeholder="0.00">
  256. <label class="block text-xs">Équivalent 35h (calculé)</label>
  257. <input type="text" readonly name="salaire_35h_cdi_<?php echo $s; ?>" class="readonly-field salaire-35h-cdi py-2 px-3 w-full border rounded-lg text-sm dark:border-neutral-700" data-side="<?php echo $s; ?>">
  258. </div>
  259. <div>
  260. <span class="block text-xs mb-2">Rémunération variable ?</span>
  261. <div class="flex gap-4">
  262. <label class="inline-flex items-center gap-2"><input type="radio" name="rem_var_cdi_<?php echo $s; ?>" value="non" checked class="rem-var-cdi" data-side="<?php echo $s; ?>"> Non</label>
  263. <label class="inline-flex items-center gap-2"><input type="radio" name="rem_var_cdi_<?php echo $s; ?>" value="oui" class="rem-var-cdi" data-side="<?php echo $s; ?>"> Oui</label>
  264. </div>
  265. </div>
  266. <div>
  267. <span class="block text-xs mb-2">Garantie de salaire ?</span>
  268. <div class="flex gap-4">
  269. <label class="inline-flex items-center gap-2"><input type="radio" name="garantie_cdi_<?php echo $s; ?>" value="non" checked class="gar-cdi" data-side="<?php echo $s; ?>"> Non</label>
  270. <label class="inline-flex items-center gap-2"><input type="radio" name="garantie_cdi_<?php echo $s; ?>" value="oui" class="gar-cdi" data-side="<?php echo $s; ?>"> Oui</label>
  271. </div>
  272. </div>
  273. <div id="gar-detail-cdi-<?php echo $s; ?>" class="conditional-field grid grid-cols-1 gap-2">
  274. <label class="text-xs">Montant brut (€ / mois)</label>
  275. <input type="text" name="garantie_montant_cdi_<?php echo $s; ?>" class="py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  276. <label class="text-xs">Durée de la garantie</label>
  277. <select name="garantie_duree_cdi_<?php echo $s; ?>" class="py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  278. <option value="">Sélectionner</option>
  279. <option value="3m">3 mois</option>
  280. <option value="6m">6 mois</option>
  281. <option value="12m">12 mois</option>
  282. </select>
  283. </div>
  284. <div>
  285. <span class="block text-xs mb-2">Véhicule de fonction ?</span>
  286. <div class="flex gap-4">
  287. <label class="inline-flex items-center gap-2"><input type="radio" name="vehicule_cdi_<?php echo $s; ?>" value="non" checked class="veh-cdi" data-side="<?php echo $s; ?>"> Non</label>
  288. <label class="inline-flex items-center gap-2"><input type="radio" name="vehicule_cdi_<?php echo $s; ?>" value="oui" class="veh-cdi" data-side="<?php echo $s; ?>"> Oui</label>
  289. </div>
  290. </div>
  291. <div id="veh-detail-cdi-<?php echo $s; ?>" class="conditional-field">
  292. <label class="text-xs">Avantages en nature (€ / mois)</label>
  293. <input type="text" name="avantages_nature_cdi_<?php echo $s; ?>" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="0.00">
  294. </div>
  295. </div>
  296. </div>
  297. </div>
  298. <?php } ?>
  299. </div>
  300. </div>
  301. <!-- 4b. Section CDD pré/post -->
  302. <div id="bloc-section-cdd" class="space-y-4 hidden">
  303. <h2 class="text-lg font-semibold text-gray-800 dark:text-white px-1">Section CDD</h2>
  304. <div class="grid grid-cols-1 xl:grid-cols-2 gap-4">
  305. <?php
  306. foreach ([['pre','Pré-avenant','panel-pre-avenant'],['post','Post-avenant','panel-post-avenant']] as $t) {
  307. $s = $t[0]; $label = $t[1]; $panel = $t[2];
  308. ?>
  309. <div class="rounded-xl border-2 p-4 md:p-6 space-y-6 <?php echo $panel; ?>">
  310. <p class="text-sm font-bold text-gray-800 dark:text-white border-b border-gray-300/50 dark:border-neutral-600 pb-2"><?php echo htmlspecialchars($label); ?></p>
  311. <div class="avenant-panel-section">
  312. <h3 class="text-sm font-semibold mb-3 text-gray-700 dark:text-neutral-300">Planning</h3>
  313. <label class="inline-flex items-center gap-2">
  314. <input type="checkbox" name="samedi_cdd_<?php echo $s; ?>" value="1" class="rounded border-gray-200">
  315. <span class="text-sm text-gray-700 dark:text-neutral-300">Samedi travaillé ?</span>
  316. </label>
  317. </div>
  318. <div class="avenant-panel-section">
  319. <h3 class="text-sm font-semibold mb-3 text-gray-700 dark:text-neutral-300">Dates du contrat</h3>
  320. <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
  321. <div>
  322. <label class="block text-xs">Date début contrat</label>
  323. <input type="text" name="date_debut_cdd_<?php echo $s; ?>" class="fp-date py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="jj/mm/aaaa">
  324. </div>
  325. <div>
  326. <label class="block text-xs">Date de sortie</label>
  327. <input type="text" name="date_sortie_cdd_<?php echo $s; ?>" class="fp-date py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="jj/mm/aaaa">
  328. </div>
  329. </div>
  330. </div>
  331. <div class="avenant-panel-section">
  332. <h3 class="text-sm font-semibold mb-3 text-gray-700 dark:text-neutral-300">Manager</h3>
  333. <div class="space-y-3">
  334. <input type="text" name="manager_cdd_<?php echo $s; ?>" placeholder="Manager" class="py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  335. <div>
  336. <span class="block text-xs mb-2">Sera-t-il lui-même manager ?</span>
  337. <div class="flex gap-4">
  338. <label class="inline-flex items-center gap-2"><input type="radio" name="est_manager_cdd_<?php echo $s; ?>" value="oui" class="est-cdd" data-side="<?php echo $s; ?>"> Oui</label>
  339. <label class="inline-flex items-center gap-2"><input type="radio" name="est_manager_cdd_<?php echo $s; ?>" value="non" checked class="est-cdd" data-side="<?php echo $s; ?>"> Non</label>
  340. </div>
  341. </div>
  342. <div id="wrap-supervisees-cdd-<?php echo $s; ?>" class="conditional-field">
  343. <div class="flex gap-2">
  344. <input type="text" id="input-supervisee-cdd-<?php echo $s; ?>" placeholder="Prénom NOM" class="flex-1 py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  345. <button type="button" class="btn-add-supervisee px-3 py-2 bg-[#21B6BA] text-white rounded-lg text-sm" data-target="cdd-<?php echo $s; ?>">Ajouter</button>
  346. </div>
  347. <div id="badges-cdd-<?php echo $s; ?>" class="flex flex-wrap gap-2 mt-2 min-h-[36px]"></div>
  348. <input type="hidden" name="personnes_supervisees_cdd_<?php echo $s; ?>" id="hidden-supervisees-cdd-<?php echo $s; ?>" value="">
  349. </div>
  350. </div>
  351. </div>
  352. <div class="avenant-panel-section">
  353. <h3 class="text-sm font-semibold mb-3 text-gray-700 dark:text-neutral-300">Contrat</h3>
  354. <div class="grid grid-cols-1 gap-3">
  355. <select name="service_cdd_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm bg-white dark:bg-neutral-900 dark:border-neutral-700">
  356. <option value="">Service</option>
  357. <option value="vente_pra">Vente P.R.A.</option>
  358. <option value="pieces">Pièces</option>
  359. </select>
  360. <select name="intitule_cdd_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  361. <option value="">Intitulé de poste</option>
  362. <option value="conseiller">Conseiller commercial</option>
  363. </select>
  364. <select name="statut_cdd_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  365. <option value="">Statut</option>
  366. <option value="employe">Employé</option>
  367. <option value="cadre">Cadre</option>
  368. </select>
  369. <select name="echelon_cdd_<?php echo $s; ?>" class="echelon-select py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>" data-context="cdd">
  370. <option value="">Échelon</option>
  371. <option value="III_A">III A</option>
  372. <option value="III_B">III B</option>
  373. </select>
  374. <div class="rounded-lg border overflow-hidden text-xs" id="minima-cdd-<?php echo $s; ?>">
  375. <table class="w-full"><thead class="bg-gray-100 dark:bg-neutral-800"><tr>
  376. <th class="p-2 text-left">Échelon</th><th class="p-2">35h</th><th class="p-2">37h</th><th class="p-2">39h</th>
  377. </tr></thead><tbody class="dark:bg-neutral-900"><tr><td class="p-2">—</td><td class="p-2">—</td><td class="p-2">—</td><td class="p-2">—</td></tr></tbody></table>
  378. </div>
  379. </div>
  380. </div>
  381. <div class="avenant-panel-section">
  382. <h3 class="text-sm font-semibold mb-3 text-gray-700 dark:text-neutral-300">Rémunération</h3>
  383. <div class="space-y-3">
  384. <div class="flex gap-4 text-sm">
  385. <label class="inline-flex items-center gap-2"><input type="radio" name="temps_partiel_cdd_<?php echo $s; ?>" value="non" checked class="tp-cdd" data-side="<?php echo $s; ?>"> Temps plein</label>
  386. <label class="inline-flex items-center gap-2"><input type="radio" name="temps_partiel_cdd_<?php echo $s; ?>" value="oui" class="tp-cdd" data-side="<?php echo $s; ?>"> Temps partiel</label>
  387. </div>
  388. <div id="tp-oui-cdd-<?php echo $s; ?>" class="conditional-field space-y-2">
  389. <label class="block text-xs">Salaire temps partiel brut mensuel (€)</label>
  390. <input type="text" name="salaire_tp_cdd_<?php echo $s; ?>" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="0.00">
  391. <label class="block text-xs">Base horaire (h / semaine)</label>
  392. <input type="text" name="base_tp_cdd_<?php echo $s; ?>" placeholder="ex. 27" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  393. </div>
  394. <div id="tp-non-cdd-<?php echo $s; ?>" class="space-y-2">
  395. <label class="block text-xs">Base horaire</label>
  396. <select name="base_horaire_cdd_<?php echo $s; ?>" class="base-horaire-cdd py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>">
  397. <option value="">Sélectionner</option>
  398. <option value="35">35h</option>
  399. <option value="37">37h</option>
  400. <option value="39">39h (forfait)</option>
  401. </select>
  402. <label class="block text-xs">Salaire mensuel brut</label>
  403. <input type="text" name="salaire_cdd_val_<?php echo $s; ?>" class="salaire-cdd py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>" placeholder="0.00">
  404. <label class="block text-xs">Équivalent 35h (calculé)</label>
  405. <input type="text" readonly class="readonly-field salaire-35h-cdd py-2 px-3 w-full border rounded-lg text-sm dark:border-neutral-700" name="salaire_35h_cdd_<?php echo $s; ?>" data-side="<?php echo $s; ?>">
  406. </div>
  407. <div class="flex gap-4 text-sm">
  408. <label class="inline-flex items-center gap-2"><input type="radio" name="rem_var_cdd_<?php echo $s; ?>" value="non" checked class="rem-cdd" data-side="<?php echo $s; ?>"> Rém. variable Non</label>
  409. <label class="inline-flex items-center gap-2"><input type="radio" name="rem_var_cdd_<?php echo $s; ?>" value="oui" class="rem-cdd" data-side="<?php echo $s; ?>"> Oui</label>
  410. </div>
  411. <div class="flex gap-4 text-sm">
  412. <label class="inline-flex items-center gap-2"><input type="radio" name="garantie_cdd_<?php echo $s; ?>" value="non" checked class="gar-cdd" data-side="<?php echo $s; ?>"> Garantie Non</label>
  413. <label class="inline-flex items-center gap-2"><input type="radio" name="garantie_cdd_<?php echo $s; ?>" value="oui" class="gar-cdd" data-side="<?php echo $s; ?>"> Oui</label>
  414. </div>
  415. <div id="gar-detail-cdd-<?php echo $s; ?>" class="conditional-field grid gap-2">
  416. <input type="text" name="garantie_montant_cdd_<?php echo $s; ?>" placeholder="Montant €/mois" class="py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  417. <select name="garantie_duree_cdd_<?php echo $s; ?>" class="py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  418. <option value="">Durée garantie</option>
  419. <option value="3m">3 mois</option>
  420. <option value="6m">6 mois</option>
  421. </select>
  422. </div>
  423. <div class="flex gap-4 text-sm">
  424. <label class="inline-flex items-center gap-2"><input type="radio" name="vehicule_cdd_<?php echo $s; ?>" value="non" checked class="veh-cdd" data-side="<?php echo $s; ?>"> Véhicule Non</label>
  425. <label class="inline-flex items-center gap-2"><input type="radio" name="vehicule_cdd_<?php echo $s; ?>" value="oui" class="veh-cdd" data-side="<?php echo $s; ?>"> Oui</label>
  426. </div>
  427. <div id="veh-detail-cdd-<?php echo $s; ?>" class="conditional-field">
  428. <input type="text" name="avantages_nature_cdd_<?php echo $s; ?>" placeholder="Avantages en nature €/mois" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  429. </div>
  430. </div>
  431. </div>
  432. </div>
  433. <?php } ?>
  434. </div>
  435. </div>
  436. <!-- Justification RH -->
  437. <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700">
  438. <div class="p-6">
  439. <h2 class="text-lg font-semibold text-[#21B6BA] mb-3">Justification à destination des RH</h2>
  440. <textarea name="commentaires_rh" id="justification_rh" rows="4" class="py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="Contexte et motifs de la demande pour les ressources humaines"></textarea>
  441. </div>
  442. </div>
  443. <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700">
  444. <div class="p-6 space-y-8">
  445. <h2 class="text-lg font-semibold text-gray-800 dark:text-white">Informatique</h2>
  446. <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
  447. <div>
  448. <label class="block text-xs mb-1">Compte Windows</label>
  449. <div class="flex gap-2">
  450. <input type="text" id="compte_windows" readonly class="readonly-field flex-1 py-2 px-3 border rounded-lg text-sm dark:border-neutral-700" value="jean.dupont">
  451. <button type="button" onclick="copier('compte_windows', event)" class="px-3 py-2 bg-[#21B6BA] text-white rounded-lg text-sm shrink-0">Copier</button>
  452. </div>
  453. </div>
  454. <div>
  455. <label class="block text-xs mb-1">Office 365</label>
  456. <div class="flex gap-2">
  457. <input type="text" id="compte_o365" readonly class="readonly-field flex-1 py-2 px-3 border rounded-lg text-sm dark:border-neutral-700" value="jean.dupont@sipa-automobiles.fr">
  458. <button type="button" onclick="copier('compte_o365', event)" class="px-3 py-2 bg-[#21B6BA] text-white rounded-lg text-sm shrink-0">Copier</button>
  459. </div>
  460. </div>
  461. <div>
  462. <label class="block text-xs mb-1">Mot de passe temporaire</label>
  463. <div class="flex gap-2">
  464. <input type="text" id="mdp_temp" readonly class="readonly-field flex-1 py-2 px-3 border rounded-lg text-sm dark:border-neutral-700" value="(renseigné par l’IT)">
  465. <button type="button" onclick="copier('mdp_temp', event)" class="px-3 py-2 bg-[#21B6BA] text-white rounded-lg text-sm shrink-0">Copier</button>
  466. </div>
  467. </div>
  468. </div>
  469. <?php
  470. if (!function_exists('it_toggle_block')) {
  471. function it_toggle_block($id, $title) {
  472. echo '<div class="border-t border-gray-200 dark:border-neutral-700 pt-6">';
  473. echo '<div class="flex items-center gap-3 mb-3"><h3 class="text-base font-semibold text-gray-800 dark:text-white">' . htmlspecialchars($title) . '</h3>';
  474. echo '<label class="relative inline-flex items-center cursor-pointer"><input type="checkbox" class="sr-only peer it-toggle" data-target="' . htmlspecialchars($id) . '">';
  475. echo '<div class="relative w-11 h-6 bg-gray-200 rounded-full peer dark:bg-neutral-600 peer-checked:after:translate-x-full peer-checked:bg-[#21B6BA] peer-focus:ring-4 peer-focus:ring-[#21B6BA]/30 after:content-[\'\'] after:absolute after:top-[2px] after:start-[2px] after:h-5 after:w-5 after:bg-white after:border after:rounded-full after:transition-all"></div></label></div>';
  476. echo '<div id="' . htmlspecialchars($id) . '" class="it-panel space-y-4 border border-dashed border-gray-200 dark:border-neutral-600 rounded-lg p-4 hidden">';
  477. }
  478. }
  479. it_toggle_block('panel-mobile', 'Téléphone mobile');
  480. ?>
  481. <div>
  482. <span class="text-sm block mb-2">Récupère-t-il le mobile d’un collaborateur ?</span>
  483. <div class="flex gap-4 mb-2">
  484. <label class="inline-flex items-center gap-2"><input type="radio" name="recup_mobile" value="oui"> Oui</label>
  485. <label class="inline-flex items-center gap-2"><input type="radio" name="recup_mobile" value="non" checked> Non</label>
  486. </div>
  487. <input type="text" name="ancien_collab_mobile" placeholder="Nom de l’ancien collaborateur" class="py-2 px-3 w-full max-w-md border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  488. <p class="text-xs text-gray-500 mt-2">Si Non :</p>
  489. <div class="flex gap-4 mt-1">
  490. <label class="inline-flex items-center gap-2"><input type="radio" name="type_mobile" value="iphone"> iPhone</label>
  491. <label class="inline-flex items-center gap-2"><input type="radio" name="type_mobile" value="android"> Android</label>
  492. </div>
  493. </div>
  494. </div>
  495. </div>
  496. <?php it_toggle_block('panel-fixe', 'Téléphone fixe'); ?>
  497. <div>
  498. <div class="flex gap-4 mb-2">
  499. <label class="inline-flex items-center gap-2"><input type="radio" name="recup_fixe" value="oui"> Récupère le fixe d’un collab.</label>
  500. <label class="inline-flex items-center gap-2"><input type="radio" name="recup_fixe" value="non" checked> Non</label>
  501. </div>
  502. <input type="text" name="ancien_collab_fixe" placeholder="Recherche AD" class="py-2 px-3 w-full max-w-md border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700 mb-2">
  503. <div class="flex gap-4">
  504. <label class="inline-flex items-center gap-2"><input type="radio" name="type_fixe" value="classique"> Poste classique</label>
  505. <label class="inline-flex items-center gap-2"><input type="radio" name="type_fixe" value="sansfil"> Poste sans fil</label>
  506. </div>
  507. </div>
  508. </div>
  509. </div>
  510. <?php it_toggle_block('panel-pc', 'Ordinateur'); ?>
  511. <div class="space-y-3">
  512. <div class="flex gap-4">
  513. <label class="inline-flex items-center gap-2"><input type="radio" name="recup_pc" value="oui"> Récupère le PC d’un collab.</label>
  514. <label class="inline-flex items-center gap-2"><input type="radio" name="recup_pc" value="non" checked> Non</label>
  515. </div>
  516. <input type="text" name="ancien_collab_pc" placeholder="Nom ancien collaborateur (AD)" class="py-2 px-3 w-full max-w-md border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
  517. <div class="flex gap-4">
  518. <label class="inline-flex items-center gap-2"><input type="radio" name="type_pc" value="fixe"> PC fixe</label>
  519. <label class="inline-flex items-center gap-2"><input type="radio" name="type_pc" value="portable"> PC portable</label>
  520. </div>
  521. <div>
  522. <span class="text-sm">Écran supplémentaire ?</span>
  523. <div class="flex gap-4 mt-1">
  524. <label class="inline-flex items-center gap-2"><input type="radio" name="ecran_supp" value="oui"> Oui</label>
  525. <label class="inline-flex items-center gap-2"><input type="radio" name="ecran_supp" value="non" checked> Non</label>
  526. </div>
  527. </div>
  528. </div>
  529. </div>
  530. </div>
  531. <div>
  532. <h3 class="text-sm font-semibold mb-3">Accès logiciels (par catégorie)</h3>
  533. <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 text-sm">
  534. <?php foreach (['dms'=>'DMS','commerce'=>'Commerce','compta'=>'Comptabilité','atelier'=>'Atelier','dsi'=>'DSI','crc'=>'CRC'] as $k=>$lab): ?>
  535. <div>
  536. <label class="block text-xs mb-1"><?php echo htmlspecialchars($lab); ?></label>
  537. <select name="logiciel_<?php echo $k; ?>" class="py-2 px-2 w-full border rounded-lg dark:bg-neutral-900 dark:border-neutral-700">
  538. <option value="">Niveau d’accès</option>
  539. <option value="aucun">Aucun</option>
  540. <option value="lecture">Lecture</option>
  541. <option value="ecriture">Écriture</option>
  542. <option value="admin">Admin</option>
  543. </select>
  544. </div>
  545. <?php endforeach; ?>
  546. </div>
  547. </div>
  548. <?php it_toggle_block('panel-messagerie', 'Messagerie'); ?>
  549. <div class="space-y-3">
  550. <div>
  551. <label class="block text-xs mb-1">Liste de diffusion groupe SIPA</label>
  552. <select name="ld_sipa" class="py-2 px-3 w-full max-w-lg border rounded-lg dark:bg-neutral-900 dark:border-neutral-700">
  553. <option value="">(optionnel)</option>
  554. <option value="ld_mds">LD_MDS</option>
  555. <option value="ld_directeurs">LD_DIRECTEURS</option>
  556. </select>
  557. </div>
  558. <div>
  559. <label class="block text-xs mb-1">Liste de diffusion du site</label>
  560. <select name="ld_site" class="py-2 px-3 w-full max-w-lg border rounded-lg dark:bg-neutral-900 dark:border-neutral-700">
  561. <option value="">(optionnel)</option>
  562. <option value="ld_magasin">LD_MAGASIN_AUTO_33</option>
  563. <option value="ld_sav">LD_SAV_AUTO_33</option>
  564. </select>
  565. </div>
  566. <div>
  567. <span class="text-sm">Redirection boîte mail d’un autre collaborateur ?</span>
  568. <div class="flex gap-4 mt-1">
  569. <label class="inline-flex items-center gap-2"><input type="radio" name="redirect_mail" value="oui"> Oui</label>
  570. <label class="inline-flex items-center gap-2"><input type="radio" name="redirect_mail" value="non" checked> Non</label>
  571. </div>
  572. </div>
  573. <div>
  574. <label class="block text-xs mb-1">Intitulé pour la signature</label>
  575. <input type="text" name="intitule_signature_it" class="py-2 px-3 w-full max-w-lg border rounded-lg dark:bg-neutral-900 dark:border-neutral-700" placeholder="Ex. Responsable commercial">
  576. </div>
  577. </div>
  578. </div>
  579. </div>
  580. </div>
  581. </div>
  582. <!-- Commentaires IT -->
  583. <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700">
  584. <div class="p-6">
  585. <h2 class="text-lg font-semibold text-gray-800 dark:text-white mb-3">Commentaires IT</h2>
  586. <textarea name="commentaires_it" rows="3" class="py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="Réservé à l’IT"></textarea>
  587. </div>
  588. </div>
  589. <div class="flex flex-wrap justify-end gap-3 pb-12">
  590. <button type="button" class="py-3 px-4 text-sm font-medium rounded-lg border border-gray-200 bg-white dark:bg-neutral-800 dark:border-neutral-700">Annuler</button>
  591. <button type="submit" class="py-3 px-4 text-sm font-medium rounded-lg bg-[#21B6BA] text-white hover:bg-[#1AA5A9]">Soumettre la demande</button>
  592. </div>
  593. </form>
  594. </div>
  595. </div>
  596. <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
  597. <script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/fr.js"></script>
  598. <script src="https://cdn.jsdelivr.net/npm/preline/dist/preline.js"></script>
  599. <script>
  600. (function() {
  601. const MINIMA = {
  602. III_A: ['3804', '4075,61', '4347,21'],
  603. III_B: ['4093', '4385,24', '4677,48'],
  604. III_C: ['4383', '4695,95', '5008,89']
  605. };
  606. function majTableauMinima(sel) {
  607. const side = sel.dataset.side;
  608. const ctx = sel.dataset.context;
  609. const id = ctx === 'cdi' ? 'minima-cdi-' + side : 'minima-cdd-' + side;
  610. const wrap = document.getElementById(id);
  611. if (!wrap) return;
  612. const v = sel.value;
  613. const row = MINIMA[v];
  614. const tb = wrap.querySelector('tbody');
  615. if (row && tb) {
  616. tb.innerHTML = '<tr><td class="p-2 font-medium">' + v.replace('_',' ') + '</td><td class="p-2">' + row[0] + '</td><td class="p-2">' + row[1] + '</td><td class="p-2">' + row[2] + '</td></tr>';
  617. } else if (tb) {
  618. tb.innerHTML = '<tr><td class="p-2">—</td><td class="p-2">—</td><td class="p-2">—</td><td class="p-2">—</td></tr>';
  619. }
  620. }
  621. function calc35(salaireEl, baseEl, outEl) {
  622. const salaire = parseFloat(String(salaireEl.value).replace(',', '.'));
  623. const opt = baseEl.options[baseEl.selectedIndex];
  624. if (!salaire || !opt || !opt.value) { outEl.value = ''; return; }
  625. let h = parseFloat(opt.value);
  626. if (opt.value === '39') h = 37.5;
  627. if (h === 35) outEl.value = salaire.toFixed(2);
  628. else outEl.value = (salaire / h * 35).toFixed(2);
  629. }
  630. function bindGestionnaireCDI() {
  631. document.querySelectorAll('.est-manager-cdi').forEach(r => {
  632. r.addEventListener('change', () => {
  633. const side = r.dataset.side;
  634. const wrap = document.getElementById('wrap-supervisees-cdi-' + side);
  635. const oui = document.querySelector('input[name="est_manager_cdi_' + side + '"]:checked')?.value === 'oui';
  636. if (oui) { wrap.classList.add('is-active'); wrap.style.display = 'block'; }
  637. else { wrap.classList.remove('is-active'); wrap.style.display = 'none'; }
  638. });
  639. });
  640. document.querySelectorAll('.tp-cdi').forEach(r => {
  641. r.addEventListener('change', () => {
  642. const side = r.dataset.side;
  643. const oui = document.querySelector('input[name="temps_partiel_cdi_' + side + '"]:checked')?.value === 'oui';
  644. document.getElementById('tp-oui-cdi-' + side).classList.toggle('is-active', oui);
  645. document.getElementById('tp-oui-cdi-' + side).style.display = oui ? 'block' : 'none';
  646. document.getElementById('tp-non-cdi-' + side).style.display = oui ? 'none' : 'block';
  647. });
  648. });
  649. ['rem-var-cdi','gar-cdi','veh-cdi'].forEach(cls => {
  650. document.querySelectorAll('.' + cls).forEach(r => {
  651. r.addEventListener('change', () => {
  652. const side = r.dataset.side;
  653. if (cls === 'rem-var-cdi') { /* optionnel champs */ }
  654. if (cls === 'gar-cdi') {
  655. const on = document.querySelector('input[name="garantie_cdi_' + side + '"]:checked')?.value === 'oui';
  656. const el = document.getElementById('gar-detail-cdi-' + side);
  657. el.classList.toggle('is-active', on); el.style.display = on ? 'grid' : 'none';
  658. }
  659. if (cls === 'veh-cdi') {
  660. const on = document.querySelector('input[name="vehicule_cdi_' + side + '"]:checked')?.value === 'oui';
  661. const el = document.getElementById('veh-detail-cdi-' + side);
  662. el.classList.toggle('is-active', on); el.style.display = on ? 'block' : 'none';
  663. }
  664. });
  665. });
  666. });
  667. document.querySelectorAll('.base-horaire-cdi').forEach(b => {
  668. b.addEventListener('change', () => {
  669. const side = b.dataset.side;
  670. calc35(document.querySelector('.salaire-cdi[data-side="' + side + '"]'), b, document.querySelector('.salaire-35h-cdi[data-side="' + side + '"]'));
  671. });
  672. });
  673. document.querySelectorAll('.salaire-cdi').forEach(s => {
  674. s.addEventListener('input', () => {
  675. const side = s.dataset.side;
  676. calc35(s, document.querySelector('.base-horaire-cdi[data-side="' + side + '"]'), document.querySelector('.salaire-35h-cdi[data-side="' + side + '"]'));
  677. });
  678. });
  679. }
  680. function bindCDD() {
  681. document.querySelectorAll('.est-cdd').forEach(r => {
  682. r.addEventListener('change', () => {
  683. const side = r.dataset.side;
  684. const on = document.querySelector('input[name="est_manager_cdd_' + side + '"]:checked')?.value === 'oui';
  685. const w = document.getElementById('wrap-supervisees-cdd-' + side);
  686. w.classList.toggle('is-active', on); w.style.display = on ? 'block' : 'none';
  687. });
  688. });
  689. document.querySelectorAll('.tp-cdd').forEach(r => {
  690. r.addEventListener('change', () => {
  691. const side = r.dataset.side;
  692. const oui = document.querySelector('input[name="temps_partiel_cdd_' + side + '"]:checked')?.value === 'oui';
  693. document.getElementById('tp-oui-cdd-' + side).classList.toggle('is-active', oui);
  694. document.getElementById('tp-oui-cdd-' + side).style.display = oui ? 'block' : 'none';
  695. document.getElementById('tp-non-cdd-' + side).style.display = oui ? 'none' : 'block';
  696. });
  697. });
  698. document.querySelectorAll('.gar-cdd').forEach(r => {
  699. r.addEventListener('change', () => {
  700. const side = r.dataset.side;
  701. const on = document.querySelector('input[name="garantie_cdd_' + side + '"]:checked')?.value === 'oui';
  702. const el = document.getElementById('gar-detail-cdd-' + side);
  703. el.classList.toggle('is-active', on); el.style.display = on ? 'grid' : 'none';
  704. });
  705. });
  706. document.querySelectorAll('.veh-cdd').forEach(r => {
  707. r.addEventListener('change', () => {
  708. const side = r.dataset.side;
  709. const on = document.querySelector('input[name="vehicule_cdd_' + side + '"]:checked')?.value === 'oui';
  710. const el = document.getElementById('veh-detail-cdd-' + side);
  711. if (el) { el.classList.toggle('is-active', on); el.style.display = on ? 'block' : 'none'; }
  712. });
  713. });
  714. document.querySelectorAll('.base-horaire-cdd').forEach(b => {
  715. b.addEventListener('change', () => {
  716. const side = b.dataset.side;
  717. calc35(
  718. document.querySelector('.salaire-cdd[data-side="' + side + '"]'),
  719. b,
  720. document.querySelector('.salaire-35h-cdd[data-side="' + side + '"]')
  721. );
  722. });
  723. });
  724. document.querySelectorAll('.salaire-cdd').forEach(s => {
  725. s.addEventListener('input', () => {
  726. const side = s.dataset.side;
  727. calc35(s, document.querySelector('.base-horaire-cdd[data-side="' + side + '"]'), document.querySelector('.salaire-35h-cdd[data-side="' + side + '"]'));
  728. });
  729. });
  730. }
  731. function toggleContratType() {
  732. const cdiChecked = document.getElementById('type_cdi')?.checked;
  733. const elCdi = document.getElementById('bloc-section-cdi');
  734. const elCdd = document.getElementById('bloc-section-cdd');
  735. if (elCdi) elCdi.classList.toggle('hidden', !cdiChecked);
  736. if (elCdd) elCdd.classList.toggle('hidden', !!cdiChecked);
  737. if (elCdi) elCdi.querySelectorAll('input,select,textarea,button').forEach(e => { e.disabled = !cdiChecked; });
  738. if (elCdd) elCdd.querySelectorAll('input,select,textarea,button').forEach(e => { e.disabled = !!cdiChecked; });
  739. }
  740. document.querySelectorAll('input[name="type_contrat_avenant"]').forEach(r => r.addEventListener('change', toggleContratType));
  741. document.querySelectorAll('.echelon-select').forEach(s => {
  742. s.addEventListener('change', () => majTableauMinima(s));
  743. });
  744. document.querySelectorAll('.btn-add-supervisee').forEach(btn => {
  745. btn.addEventListener('click', () => {
  746. const t = btn.dataset.target.split('-');
  747. const ctx = t[0];
  748. const side = t[1];
  749. const inp = document.getElementById('input-supervisee-' + ctx + '-' + side);
  750. const name = (inp && inp.value || '').trim();
  751. if (!name) return;
  752. const box = document.getElementById('badges-' + ctx + '-' + side);
  753. const hid = document.getElementById('hidden-supervisees-' + ctx + '-' + side);
  754. const b = document.createElement('span');
  755. b.className = 'person-badge';
  756. b.innerHTML = '<span class="nom-badge"></span><button type="button" class="remove" aria-label="Retirer">&times;</button>';
  757. b.querySelector('.nom-badge').textContent = name;
  758. b.querySelector('.remove').addEventListener('click', () => {
  759. b.remove();
  760. syncHid(box, hid);
  761. });
  762. box.appendChild(b);
  763. inp.value = '';
  764. syncHid(box, hid);
  765. });
  766. });
  767. function syncHid(box, hid) {
  768. if (!hid) return;
  769. const names = [...box.querySelectorAll('.nom-badge')].map(el => el.textContent.trim()).filter(Boolean);
  770. hid.value = names.join(', ');
  771. }
  772. document.querySelectorAll('.it-toggle').forEach(t => {
  773. t.addEventListener('change', () => {
  774. const p = document.getElementById(t.dataset.target);
  775. if (p) p.classList.toggle('hidden', !t.checked);
  776. });
  777. });
  778. window.copier = function(id, evt) {
  779. const el = document.getElementById(id);
  780. if (!el) return;
  781. navigator.clipboard.writeText(el.value).catch(() => {});
  782. };
  783. /** Si un champ *_pre ou *_post est renseigné, l’autre côté doit l’être aussi (section CDI ou CDD active uniquement). */
  784. function validatePrePostMirror() {
  785. const errs = [];
  786. const cdiOn = document.getElementById('type_cdi')?.checked;
  787. const rootId = cdiOn ? 'bloc-section-cdi' : 'bloc-section-cdd';
  788. const root = document.getElementById(rootId);
  789. if (!root || root.classList.contains('hidden')) return errs;
  790. function val(el) {
  791. if (!el || el.disabled) return null;
  792. if (el.type === 'checkbox') return el.checked ? '1' : '';
  793. return String(el.value != null ? el.value : '').trim();
  794. }
  795. const seen = new Set();
  796. root.querySelectorAll('[name$="_pre"]').forEach(preEl => {
  797. if (preEl.disabled || preEl.readOnly || preEl.type === 'radio' || preEl.type === 'button' || preEl.type === 'submit') return;
  798. const n = preEl.name;
  799. if (!n.endsWith('_pre')) return;
  800. const base = n.slice(0, -4);
  801. const postName = base + '_post';
  802. if (seen.has(base)) return;
  803. seen.add(base);
  804. const postEl = Array.from(root.querySelectorAll('[name]')).find(el => el.name === postName);
  805. if (!postEl || postEl.type === 'radio' || postEl.readOnly) return;
  806. const pv = val(preEl);
  807. const qv = val(postEl);
  808. if (pv === null || qv === null) return;
  809. const preEmpty = pv === '';
  810. const postEmpty = qv === '';
  811. if (!preEmpty && postEmpty) {
  812. errs.push('« ' + base + ' » : le pré-avenant est renseigné, complétez la même information côté post-avenant.');
  813. }
  814. if (preEmpty && !postEmpty) {
  815. errs.push('« ' + base + ' » : le post-avenant est renseigné, complétez la même information côté pré-avenant.');
  816. }
  817. });
  818. return errs;
  819. }
  820. document.addEventListener('DOMContentLoaded', () => {
  821. toggleContratType();
  822. bindGestionnaireCDI();
  823. bindCDD();
  824. flatpickr('#date_effet_avenant', { locale: 'fr', dateFormat: 'd/m/Y', allowInput: true });
  825. document.querySelectorAll('.fp-date').forEach(inp => flatpickr(inp, { locale: 'fr', dateFormat: 'd/m/Y', allowInput: true }));
  826. document.querySelectorAll('.est-manager-cdi').forEach(r => r.dispatchEvent(new Event('change')));
  827. document.querySelectorAll('.tp-cdi').forEach(r => r.dispatchEvent(new Event('change')));
  828. document.querySelectorAll('.gar-cdi').forEach(r => r.dispatchEvent(new Event('change')));
  829. document.querySelectorAll('.veh-cdi').forEach(r => r.dispatchEvent(new Event('change')));
  830. document.querySelectorAll('.tp-cdd').forEach(r => r.dispatchEvent(new Event('change')));
  831. document.querySelectorAll('.gar-cdd').forEach(r => r.dispatchEvent(new Event('change')));
  832. document.querySelectorAll('.veh-cdd').forEach(r => r.dispatchEvent(new Event('change')));
  833. });
  834. document.getElementById('form-avenant').addEventListener('submit', e => {
  835. e.preventDefault();
  836. const mirrorErrs = validatePrePostMirror();
  837. if (mirrorErrs.length) {
  838. alert(mirrorErrs.join('\n'));
  839. return;
  840. }
  841. if (!document.getElementById('form-avenant').checkValidity()) {
  842. document.getElementById('form-avenant').reportValidity();
  843. return;
  844. }
  845. alert('Maquette : aucun envoi réel. Brancher le traitement serveur ici.');
  846. });
  847. })();
  848. </script>
  849. </body>
  850. </html>