type.php 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. <?php
  2. /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  7. * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
  8. * Copyright (C) 2019-2022 Thibault Foucart <support@ptibogxiv.net>
  9. * Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
  10. * Copyright (C) 2021 Waël Almoman <info@almoman.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/adherents/type.php
  27. * \ingroup member
  28. * \brief Member's type setup
  29. */
  30. // Load Dolibarr environment
  31. require '../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
  37. // Load translation files required by the page
  38. $langs->load("members");
  39. $rowid = GETPOST('rowid', 'int');
  40. $action = GETPOST('action', 'aZ09');
  41. $massaction = GETPOST('massaction', 'alpha');
  42. $cancel = GETPOST('cancel', 'alpha');
  43. $toselect = GETPOST('toselect', 'array');
  44. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
  45. $backtopage = GETPOST('backtopage', 'alpha');
  46. $mode = GETPOST('mode', 'alopha');
  47. $sall = GETPOST("sall", "alpha");
  48. $filter = GETPOST("filter", 'alpha');
  49. $search_ref = GETPOST('search_ref', 'alpha');
  50. $search_lastname = GETPOST('search_lastname', 'alpha');
  51. $search_login = GETPOST('search_login', 'alpha');
  52. $search_email = GETPOST('search_email', 'alpha');
  53. $type = GETPOST('type', 'intcomma');
  54. $status = GETPOST('status', 'alpha');
  55. $optioncss = GETPOST('optioncss', 'alpha');
  56. // Load variable for pagination
  57. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  58. $sortfield = GETPOST('sortfield', 'aZ09comma');
  59. $sortorder = GETPOST('sortorder', 'aZ09comma');
  60. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  61. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  62. // If $page is not defined, or '' or -1 or if we click on clear filters
  63. $page = 0;
  64. }
  65. $offset = $limit * $page;
  66. $pageprev = $page - 1;
  67. $pagenext = $page + 1;
  68. if (!$sortorder) {
  69. $sortorder = "DESC";
  70. }
  71. if (!$sortfield) {
  72. $sortfield = "d.lastname";
  73. }
  74. $label = GETPOST("label", "alpha");
  75. $morphy = GETPOST("morphy", "alpha");
  76. $status = GETPOST("status", "int");
  77. $subscription = GETPOST("subscription", "int");
  78. $amount = GETPOST('amount', 'alpha');
  79. $duration_value = GETPOST('duration_value', 'int');
  80. $duration_unit = GETPOST('duration_unit', 'alpha');
  81. $vote = GETPOST("vote", "int");
  82. $comment = GETPOST("comment", 'restricthtml');
  83. $mail_valid = GETPOST("mail_valid", 'restricthtml');
  84. $caneditamount = GETPOSTINT("caneditamount");
  85. // Initialize technical objects
  86. $object = new AdherentType($db);
  87. $extrafields = new ExtraFields($db);
  88. $hookmanager->initHooks(array('membertypecard', 'globalcard'));
  89. // Fetch optionals attributes and labels
  90. $extrafields->fetch_name_optionals_label($object->table_element);
  91. // Security check
  92. $result = restrictedArea($user, 'adherent', $rowid, 'adherent_type');
  93. /*
  94. * Actions
  95. */
  96. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  97. $search_ref = "";
  98. $search_lastname = "";
  99. $search_login = "";
  100. $search_email = "";
  101. $type = "";
  102. $sall = "";
  103. }
  104. if (GETPOST('cancel', 'alpha')) {
  105. $action = 'list';
  106. $massaction = '';
  107. }
  108. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  109. $massaction = '';
  110. }
  111. if ($cancel) {
  112. $action = '';
  113. if (!empty($backtopage)) {
  114. header("Location: ".$backtopage);
  115. exit;
  116. }
  117. }
  118. if ($action == 'add' && $user->hasRight('adherent', 'configurer')) {
  119. $object->label = trim($label);
  120. $object->morphy = trim($morphy);
  121. $object->status = (int) $status;
  122. $object->subscription = (int) $subscription;
  123. $object->amount = ($amount == '' ? '' : price2num($amount, 'MT'));
  124. $object->caneditamount = $caneditamount;
  125. $object->duration_value = $duration_value;
  126. $object->duration_unit = $duration_unit;
  127. $object->note_public = trim($comment);
  128. $object->note_private = '';
  129. $object->mail_valid = trim($mail_valid);
  130. $object->vote = (int) $vote;
  131. // Fill array 'array_options' with data from add form
  132. $ret = $extrafields->setOptionalsFromPost(null, $object);
  133. if ($ret < 0) {
  134. $error++;
  135. }
  136. if (empty($object->label)) {
  137. $error++;
  138. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
  139. } else {
  140. $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle = '".$db->escape($object->label)."'";
  141. $sql .= " WHERE entity IN (".getEntity('member_type').")";
  142. $result = $db->query($sql);
  143. $num = null;
  144. if ($result) {
  145. $num = $db->num_rows($result);
  146. }
  147. if ($num) {
  148. $error++;
  149. $langs->load("errors");
  150. setEventMessages($langs->trans("ErrorLabelAlreadyExists", $login), null, 'errors');
  151. }
  152. }
  153. if (!$error) {
  154. $id = $object->create($user);
  155. if ($id > 0) {
  156. header("Location: ".$_SERVER["PHP_SELF"]);
  157. exit;
  158. } else {
  159. setEventMessages($object->error, $object->errors, 'errors');
  160. $action = 'create';
  161. }
  162. } else {
  163. $action = 'create';
  164. }
  165. }
  166. if ($action == 'update' && $user->hasRight('adherent', 'configurer')) {
  167. $object->fetch($rowid);
  168. $object->oldcopy = dol_clone($object, 2);
  169. $object->label= trim($label);
  170. $object->morphy = trim($morphy);
  171. $object->status = (int) $status;
  172. $object->subscription = (int) $subscription;
  173. $object->amount = ($amount == '' ? '' : price2num($amount, 'MT'));
  174. $object->caneditamount = $caneditamount;
  175. $object->duration_value = $duration_value;
  176. $object->duration_unit = $duration_unit;
  177. $object->note_public = trim($comment);
  178. $object->note_private = '';
  179. $object->mail_valid = trim($mail_valid);
  180. $object->vote = (boolean) trim($vote);
  181. // Fill array 'array_options' with data from add form
  182. $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
  183. if ($ret < 0) {
  184. $error++;
  185. }
  186. $ret = $object->update($user);
  187. if ($ret >= 0 && !count($object->errors)) {
  188. setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs');
  189. } else {
  190. setEventMessages($object->error, $object->errors, 'errors');
  191. }
  192. header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id);
  193. exit;
  194. }
  195. if ($action == 'confirm_delete' && $user->hasRight('adherent', 'configurer')) {
  196. $object->fetch($rowid);
  197. $res = $object->delete();
  198. if ($res > 0) {
  199. setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs');
  200. header("Location: ".$_SERVER["PHP_SELF"]);
  201. exit;
  202. } else {
  203. setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors');
  204. $action = '';
  205. }
  206. }
  207. /*
  208. * View
  209. */
  210. $form = new Form($db);
  211. $formproduct = new FormProduct($db);
  212. $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
  213. llxHeader('', $langs->trans("MembersTypeSetup"), $help_url);
  214. $arrayofselected = is_array($toselect) ? $toselect : array();
  215. // List of members type
  216. if (!$rowid && $action != 'create' && $action != 'edit') {
  217. //print dol_get_fiche_head('');
  218. $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.statut as status, d.morphy, d.duration";
  219. $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
  220. $sql .= " WHERE d.entity IN (".getEntity('member_type').")";
  221. $result = $db->query($sql);
  222. if ($result) {
  223. $num = $db->num_rows($result);
  224. $nbtotalofrecords = $num;
  225. $i = 0;
  226. $param = '';
  227. if (!empty($mode)) {
  228. $param .= '&mode'.urlencode($mode);
  229. }
  230. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  231. $param .= '&contextpage='.$contextpage;
  232. }
  233. if ($limit > 0 && $limit != $conf->liste_limit) {
  234. $param .= '&limit='.$limit;
  235. }
  236. $newcardbutton = '';
  237. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
  238. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
  239. if ($user->hasRight('adherent', 'configurer')) {
  240. $newcardbutton .= dolGetButtonTitleSeparator();
  241. $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create');
  242. }
  243. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  244. if ($optioncss != '') {
  245. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  246. }
  247. print '<input type="hidden" name="token" value="'.newToken().'">';
  248. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  249. print '<input type="hidden" name="action" value="list">';
  250. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  251. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  252. print '<input type="hidden" name="mode" value="'.$mode.'">';
  253. print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit, 0, 0, 1);
  254. $moreforfilter = '';
  255. print '<div class="div-table-responsive">';
  256. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  257. print '<tr class="liste_titre">';
  258. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  259. print '<th>&nbsp;</th>';
  260. }
  261. print '<th>'.$langs->trans("Ref").'</th>';
  262. print '<th>'.$langs->trans("Label").'</th>';
  263. print '<th class="center">'.$langs->trans("MembersNature").'</th>';
  264. print '<th class="center">'.$langs->trans("MembershipDuration").'</th>';
  265. print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>';
  266. print '<th class="center">'.$langs->trans("Amount").'</th>';
  267. print '<th class="center">'.$langs->trans("CanEditAmountShort").'</th>';
  268. print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
  269. print '<th class="center">'.$langs->trans("Status").'</th>';
  270. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  271. print '<th>&nbsp;</th>';
  272. }
  273. print "</tr>\n";
  274. $membertype = new AdherentType($db);
  275. $i = 0;
  276. $savnbfield = 9;
  277. /*$savnbfield = $totalarray['nbfield'];
  278. $totalarray = array();
  279. $totalarray['nbfield'] = 0;*/
  280. $imaxinloop = ($limit ? min($num, $limit) : $num);
  281. while ($i < $imaxinloop) {
  282. $objp = $db->fetch_object($result);
  283. $membertype->id = $objp->rowid;
  284. $membertype->ref = $objp->rowid;
  285. $membertype->label = $objp->rowid;
  286. $membertype->status = $objp->status;
  287. $membertype->subscription = $objp->subscription;
  288. $membertype->amount = $objp->amount;
  289. $membertype->caneditamount = $objp->caneditamount;
  290. if ($mode == 'kanban') {
  291. if ($i == 0) {
  292. print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
  293. print '<div class="box-flex-container kanban">';
  294. }
  295. //output kanban
  296. $membertype->label = $objp->label;
  297. print $membertype->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
  298. if ($i == ($imaxinloop - 1)) {
  299. print '</div>';
  300. print '</td></tr>';
  301. }
  302. } else {
  303. print '<tr class="oddeven">';
  304. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  305. if ($user->hasRight('adherent', 'configurer')) {
  306. print '<td class="center"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
  307. }
  308. }
  309. print '<td class="nowraponall">';
  310. print $membertype->getNomUrl(1);
  311. //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
  312. print '</td>';
  313. print '<td>'.dol_escape_htmltag($objp->label).'</td>';
  314. print '<td class="center">';
  315. if ($objp->morphy == 'phy') {
  316. print $langs->trans("Physical");
  317. } elseif ($objp->morphy == 'mor') {
  318. print $langs->trans("Moral");
  319. } else {
  320. print $langs->trans("MorAndPhy");
  321. }
  322. print '</td>';
  323. print '<td class="center nowrap">';
  324. if ($objp->duration) {
  325. $duration_value = intval($objp->duration);
  326. if ($duration_value > 1) {
  327. $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
  328. } else {
  329. $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year"));
  330. }
  331. $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration);
  332. print max(1, $duration_value).' '.$dur[$unit];
  333. }
  334. print '</td>';
  335. print '<td class="center">'.yn($objp->subscription).'</td>';
  336. print '<td class="center"><span class="amount">'.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).'</span></td>';
  337. print '<td class="center">'.yn($objp->caneditamount).'</td>';
  338. print '<td class="center">'.yn($objp->vote).'</td>';
  339. print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
  340. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  341. if ($user->hasRight('adherent', 'configurer')) {
  342. print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
  343. }
  344. }
  345. print "</tr>";
  346. }
  347. $i++;
  348. }
  349. // If no record found
  350. if ($num == 0) {
  351. /*$colspan = 1;
  352. foreach ($arrayfields as $key => $val) {
  353. if (!empty($val['checked'])) {
  354. $colspan++;
  355. }
  356. }*/
  357. $colspan = 9;
  358. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  359. }
  360. print "</table>";
  361. print '</div>';
  362. print '</form>';
  363. } else {
  364. dol_print_error($db);
  365. }
  366. }
  367. // Creation
  368. if ($action == 'create') {
  369. $object = new AdherentType($db);
  370. print load_fiche_titre($langs->trans("NewMemberType"), '', 'members');
  371. print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
  372. print '<input type="hidden" name="token" value="'.newToken().'">';
  373. print '<input type="hidden" name="action" value="add">';
  374. print dol_get_fiche_head('');
  375. print '<table class="border centpercent">';
  376. print '<tbody>';
  377. print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
  378. print '<tr><td>'.$langs->trans("Status").'</td><td>';
  379. print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
  380. print '</td></tr>';
  381. // Morphy
  382. $morphys = array();
  383. $morphys[""] = $langs->trans("MorAndPhy");
  384. $morphys["phy"] = $langs->trans("Physical");
  385. $morphys["mor"] = $langs->trans("Moral");
  386. print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>';
  387. print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy');
  388. print "</td></tr>";
  389. print '<tr><td>'.$form->textwithpicto($langs->trans("SubscriptionRequired"), $langs->trans("SubscriptionRequiredDesc")).'</td><td>';
  390. print $form->selectyesno("subscription", 1, 1);
  391. print '</td></tr>';
  392. print '<tr><td>'.$langs->trans("Amount").'</td><td>';
  393. print '<input name="amount" size="5" value="'.(GETPOSTISSET('amount') ? GETPOST('amount') : price($amount)).'">';
  394. print '</td></tr>';
  395. print '<tr><td>'.$form->textwithpicto($langs->trans("CanEditAmountShort"), $langs->transnoentities("CanEditAmount")).'</td><td>';
  396. print $form->selectyesno("caneditamount", GETPOSTISSET('caneditamount') ? GETPOST('caneditamount') : 0, 1);
  397. print '</td></tr>';
  398. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  399. print $form->selectyesno("vote", GETPOSTISSET("vote") ? GETPOST('vote', 'aZ09') : 1, 1);
  400. print '</td></tr>';
  401. print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">';
  402. print '<input name="duration_value" size="5" value="'.GETPOST('duraction_unit', 'aZ09').'"> ';
  403. print $formproduct->selectMeasuringUnits("duration_unit", "time", GETPOSTISSET("duration_unit") ? GETPOST('duration_unit', 'aZ09') : 'y', 0, 1);
  404. print '</td></tr>';
  405. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  406. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  407. $doleditor = new DolEditor('comment', (GETPOSTISSET('comment') ? GETPOST('comment', 'restricthtml') : $object->note_public), '', 200, 'dolibarr_notes', '', false, true, isModEnabled('fckeditor'), 15, '90%');
  408. $doleditor->Create();
  409. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  410. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  411. $doleditor = new DolEditor('mail_valid', GETPOSTISSET('mail_valid') ? GETPOST('mail_valid') : $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, isModEnabled('fckeditor'), 15, '90%');
  412. $doleditor->Create();
  413. print '</td></tr>';
  414. // Other attributes
  415. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
  416. print '<tbody>';
  417. print "</table>\n";
  418. print dol_get_fiche_end();
  419. print $form->buttonsSaveCancel();
  420. print "</form>\n";
  421. }
  422. // View
  423. if ($rowid > 0) {
  424. if ($action != 'edit') {
  425. $object = new AdherentType($db);
  426. $object->fetch($rowid);
  427. $object->fetch_optionals();
  428. /*
  429. * Confirmation deletion
  430. */
  431. if ($action == 'delete') {
  432. print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id, $langs->trans("DeleteAMemberType"), $langs->trans("ConfirmDeleteMemberType", $object->label), "confirm_delete", '', 0, 1);
  433. }
  434. $head = member_type_prepare_head($object);
  435. print dol_get_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group');
  436. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  437. dol_banner_tab($object, 'rowid', $linkback);
  438. print '<div class="fichecenter">';
  439. print '<div class="underbanner clearboth"></div>';
  440. print '<table class="tableforfield border centpercent">';
  441. // Morphy
  442. print '<tr><td>'.$langs->trans("MembersNature").'</td><td class="valeur" >'.$object->getmorphylib($object->morphy).'</td>';
  443. print '</tr>';
  444. print '<tr><td>'.$form->textwithpicto($langs->trans("SubscriptionRequired"), $langs->trans("SubscriptionRequiredDesc")).'</td><td>';
  445. print yn($object->subscription);
  446. print '</tr>';
  447. // Amount
  448. print '<tr><td class="titlefield">'.$langs->trans("Amount").'</td><td>';
  449. print ((is_null($object->amount) || $object->amount === '') ? '' : '<span class="amount">'.price($object->amount).'</span>');
  450. print '</tr>';
  451. print '<tr><td>'.$form->textwithpicto($langs->trans("CanEditAmountShort"), $langs->transnoentities("CanEditAmount")).'</td><td>';
  452. print yn($object->caneditamount);
  453. print '</td></tr>';
  454. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  455. print yn($object->vote);
  456. print '</tr>';
  457. print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.'&nbsp;';
  458. if ($object->duration_value > 1) {
  459. $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
  460. } elseif ($object->duration_value > 0) {
  461. $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year"));
  462. }
  463. print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')."&nbsp;";
  464. print '</td></tr>';
  465. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  466. print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
  467. print "</td></tr>";
  468. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  469. print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->mail_valid));
  470. print "</td></tr>";
  471. // Other attributes
  472. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  473. print '</table>';
  474. print '</div>';
  475. print dol_get_fiche_end();
  476. /*
  477. * Buttons
  478. */
  479. print '<div class="tabsAction">';
  480. // Edit
  481. if ($user->hasRight('adherent', 'configurer')) {
  482. print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
  483. }
  484. // Add
  485. if ($object->morphy == 'phy') {
  486. $morphy = 'phy';
  487. } elseif ($object->morphy == 'mor') {
  488. $morphy = 'mor';
  489. } else {
  490. $morphy = '';
  491. }
  492. if ($user->hasRight('adherent', 'configurer')&& !empty($object->status)) {
  493. print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&token='.newToken().'&typeid='.$object->id.($morphy ? '&morphy='.urlencode($morphy) : '').'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
  494. } else {
  495. print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>';
  496. }
  497. // Delete
  498. if ($user->hasRight('adherent', 'configurer')) {
  499. print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>';
  500. }
  501. print "</div>";
  502. // Show list of members (nearly same code than in page list.php)
  503. $membertypestatic = new AdherentType($db);
  504. $now = dol_now();
  505. $sql = "SELECT d.rowid, d.ref, d.entity, d.login, d.firstname, d.lastname, d.societe as company, d.fk_soc,";
  506. $sql .= " d.datefin,";
  507. $sql .= " d.email, d.photo, d.fk_adherent_type as type_id, d.morphy, d.statut as status,";
  508. $sql .= " t.libelle as type, t.subscription, t.amount";
  509. $sqlfields = $sql; // $sql fields to remove for count total
  510. $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
  511. $sql .= " WHERE d.fk_adherent_type = t.rowid ";
  512. $sql .= " AND d.entity IN (".getEntity('adherent').")";
  513. $sql .= " AND t.rowid = ".((int) $object->id);
  514. if ($sall) {
  515. $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall);
  516. }
  517. if ($status != '') {
  518. $sql .= natural_search('d.statut', $status, 2);
  519. }
  520. if ($action == 'search') {
  521. if (GETPOST('search', 'alpha')) {
  522. $sql .= natural_search(array("d.firstname", "d.lastname"), GETPOST('search', 'alpha'));
  523. }
  524. }
  525. if (!empty($search_ref)) {
  526. $sql .= natural_search("d.ref", $search_ref);
  527. }
  528. if (!empty($search_lastname)) {
  529. $sql .= natural_search(array("d.firstname", "d.lastname"), $search_lastname);
  530. }
  531. if (!empty($search_login)) {
  532. $sql .= natural_search("d.login", $search_login);
  533. }
  534. if (!empty($search_email)) {
  535. $sql .= natural_search("d.email", $search_email);
  536. }
  537. if ($filter == 'uptodate') {
  538. $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
  539. }
  540. if ($filter == 'outofdate') {
  541. $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
  542. }
  543. // Count total nb of records
  544. $nbtotalofrecords = '';
  545. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  546. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  547. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  548. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  549. $resql = $db->query($sqlforcount);
  550. if ($resql) {
  551. $objforcount = $db->fetch_object($resql);
  552. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  553. } else {
  554. dol_print_error($db);
  555. }
  556. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
  557. $page = 0;
  558. $offset = 0;
  559. }
  560. $db->free($resql);
  561. }
  562. // Complete request and execute it with limit
  563. $sql .= $db->order($sortfield, $sortorder);
  564. if ($limit) {
  565. $sql .= $db->plimit($limit + 1, $offset);
  566. }
  567. $resql = $db->query($sql);
  568. if ($resql) {
  569. $num = $db->num_rows($resql);
  570. $i = 0;
  571. $titre = $langs->trans("MembersList");
  572. if ($status != '') {
  573. if ($status == '-1,1') {
  574. $titre = $langs->trans("MembersListQualified");
  575. } elseif ($status == '-1') {
  576. $titre = $langs->trans("MembersListToValid");
  577. } elseif ($status == '1' && !$filter) {
  578. $titre = $langs->trans("MembersListValid");
  579. } elseif ($status == '1' && $filter == 'uptodate') {
  580. $titre = $langs->trans("MembersListUpToDate");
  581. } elseif ($status == '1' && $filter == 'outofdate') {
  582. $titre = $langs->trans("MembersListNotUpToDate");
  583. } elseif ($status == '0') {
  584. $titre = $langs->trans("MembersListResiliated");
  585. } elseif ($status == '-2') {
  586. $titre = $langs->trans("MembersListExcluded");
  587. }
  588. } elseif ($action == 'search') {
  589. $titre = $langs->trans("MembersListQualified");
  590. }
  591. if ($type > 0) {
  592. $membertype = new AdherentType($db);
  593. $result = $membertype->fetch($type);
  594. $titre .= " (".$membertype->label.")";
  595. }
  596. $param = "&rowid=".urlencode($object->id);
  597. if (!empty($mode)) {
  598. $param .= '&mode='.urlencode($mode);
  599. }
  600. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  601. $param .= '&contextpage='.urlencode($contextpage);
  602. }
  603. if ($limit > 0 && $limit != $conf->liste_limit) {
  604. $param .= '&limit='.((int) $limit);
  605. }
  606. if (!empty($status)) {
  607. $param .= "&status=".urlencode($status);
  608. }
  609. if (!empty($search_ref)) {
  610. $param .= "&search_ref=".urlencode($search_ref);
  611. }
  612. if (!empty($search_lastname)) {
  613. $param .= "&search_lastname=".urlencode($search_lastname);
  614. }
  615. if (!empty($search_firstname)) {
  616. $param .= "&search_firstname=".urlencode($search_firstname);
  617. }
  618. if (!empty($search_login)) {
  619. $param .= "&search_login=".urlencode($search_login);
  620. }
  621. if (!empty($search_email)) {
  622. $param .= "&search_email=".urlencode($search_email);
  623. }
  624. if (!empty($filter)) {
  625. $param .= "&filter=".urlencode($filter);
  626. }
  627. if ($sall) {
  628. print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
  629. }
  630. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">';
  631. print '<input type="hidden" name="token" value="'.newToken().'">';
  632. print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'"></td>';
  633. print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, '', '', $limit);
  634. $moreforfilter = '';
  635. print '<div class="div-table-responsive">';
  636. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  637. // Fields title search
  638. print '<tr class="liste_titre_filter">';
  639. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  640. print '<td class="liste_titre center maxwidthsearch">';
  641. $searchpicto = $form->showFilterButtons('left');
  642. print $searchpicto;
  643. print '</td>';
  644. }
  645. print '<td class="liste_titre left">';
  646. print '<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
  647. print '<td class="liste_titre left">';
  648. print '<input class="flat maxwidth100" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
  649. print '<td class="liste_titre left">';
  650. print '<input class="flat maxwidth100" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
  651. print '<td class="liste_titre">&nbsp;</td>';
  652. print '<td class="liste_titre left">';
  653. print '<input class="flat maxwidth100" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'"></td>';
  654. print '<td class="liste_titre">&nbsp;</td>';
  655. print '<td class="liste_titre">&nbsp;</td>';
  656. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  657. print '<td class="liste_titre center nowraponall">';
  658. print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
  659. print '&nbsp; ';
  660. print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
  661. print '</td>';
  662. }
  663. print "</tr>\n";
  664. print '<tr class="liste_titre">';
  665. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  666. print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
  667. }
  668. print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.ref", $param, "", "", $sortfield, $sortorder);
  669. print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
  670. print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
  671. print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder);
  672. print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder);
  673. print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder);
  674. print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder);
  675. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  676. print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
  677. }
  678. print "</tr>\n";
  679. $adh = new Adherent($db);
  680. $imaxinloop = ($limit ? min($num, $limit) : $num);
  681. while ($i < $imaxinloop) {
  682. $objp = $db->fetch_object($resql);
  683. $datefin = $db->jdate($objp->datefin);
  684. $adh->id = $objp->rowid;
  685. $adh->ref = $objp->ref;
  686. $adh->login = $objp->login;
  687. $adh->lastname = $objp->lastname;
  688. $adh->firstname = $objp->firstname;
  689. $adh->datefin = $datefin;
  690. $adh->need_subscription = $objp->subscription;
  691. $adh->statut = $objp->status;
  692. $adh->email = $objp->email;
  693. $adh->photo = $objp->photo;
  694. print '<tr class="oddeven">';
  695. // Actions
  696. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  697. print '<td class="center">';
  698. if ($user->hasRight('adherent', 'creer')) {
  699. print '<a class="editfielda marginleftonly" href="card.php?rowid='.$objp->rowid.'&action=edit&token='.newToken().'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
  700. }
  701. if ($user->hasRight('adherent', 'supprimer')) {
  702. print '<a class="marginleftonly" href="card.php?rowid='.$objp->rowid.'&action=resiliate&token='.newToken().'">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>';
  703. }
  704. print "</td>";
  705. }
  706. // Ref
  707. print "<td>";
  708. print $adh->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1);
  709. print "</td>\n";
  710. // Lastname
  711. if ($objp->company != '') {
  712. print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->company, 12).'</a></td>'."\n";
  713. } else {
  714. print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n";
  715. }
  716. // Login
  717. print "<td>".dol_escape_htmltag($objp->login)."</td>\n";
  718. // Type
  719. /*print '<td class="nowrap">';
  720. $membertypestatic->id=$objp->type_id;
  721. $membertypestatic->label=$objp->type;
  722. print $membertypestatic->getNomUrl(1,12);
  723. print '</td>';
  724. */
  725. // Moral/Physique
  726. print "<td>".$adh->getmorphylib($objp->morphy, 1)."</td>\n";
  727. // EMail
  728. print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n";
  729. // Status
  730. print '<td class="nowrap">';
  731. print $adh->getLibStatut(2);
  732. print "</td>";
  733. // Date end subscription
  734. if ($datefin) {
  735. print '<td class="nowrap center">';
  736. if ($datefin < dol_now() && $objp->status > 0) {
  737. print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate"));
  738. } else {
  739. print dol_print_date($datefin, 'day');
  740. }
  741. print '</td>';
  742. } else {
  743. print '<td class="nowrap center">';
  744. if (!empty($objp->subscription)) {
  745. print '<span class="opacitymedium">'.$langs->trans("SubscriptionNotReceived").'</span>';
  746. if ($objp->status > 0) {
  747. print " ".img_warning();
  748. }
  749. } else {
  750. print '&nbsp;';
  751. }
  752. print '</td>';
  753. }
  754. // Actions
  755. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  756. print '<td class="center">';
  757. if ($user->hasRight('adherent', 'creer')) {
  758. print '<a class="editfielda marginleftonly" href="card.php?rowid='.$objp->rowid.'&action=edit&token='.newToken().'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
  759. }
  760. if ($user->hasRight('adherent', 'supprimer')) {
  761. print '<a class="marginleftonly" href="card.php?rowid='.$objp->rowid.'&action=resiliate&token='.newToken().'">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>';
  762. }
  763. print "</td>";
  764. }
  765. print "</tr>\n";
  766. $i++;
  767. }
  768. if ($i == 0) {
  769. print '<tr><td colspan="7"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
  770. }
  771. print "</table>\n";
  772. print '</div>';
  773. print '</form>';
  774. } else {
  775. dol_print_error($db);
  776. }
  777. }
  778. /* ************************************************************************** */
  779. /* */
  780. /* Edition mode */
  781. /* */
  782. /* ************************************************************************** */
  783. if ($action == 'edit') {
  784. $object = new AdherentType($db);
  785. $object->fetch($rowid);
  786. $object->fetch_optionals();
  787. $head = member_type_prepare_head($object);
  788. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">';
  789. print '<input type="hidden" name="token" value="'.newToken().'">';
  790. print '<input type="hidden" name="rowid" value="'.$object->id.'">';
  791. print '<input type="hidden" name="action" value="update">';
  792. print dol_get_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
  793. print '<table class="border centpercent">';
  794. print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
  795. print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth300" name="label" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
  796. print '<tr><td>'.$langs->trans("Status").'</td><td>';
  797. print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
  798. print '</td></tr>';
  799. // Morphy
  800. $morphys[""] = $langs->trans("MorAndPhy");
  801. $morphys["phy"] = $langs->trans("Physical");
  802. $morphys["mor"] = $langs->trans("Moral");
  803. print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>';
  804. print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : $object->morphy);
  805. print "</td></tr>";
  806. print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
  807. print $form->selectyesno("subscription", $object->subscription, 1);
  808. print '</td></tr>';
  809. print '<tr><td>'.$langs->trans("Amount").'</td><td>';
  810. print '<input name="amount" size="5" value="';
  811. print ((is_null($object->amount) || $object->amount === '') ? '' : price($object->amount));
  812. print '">';
  813. print '</td></tr>';
  814. print '<tr><td>'.$form->textwithpicto($langs->trans("CanEditAmountShort"), $langs->transnoentities("CanEditAmountDetail")).'</td><td>';
  815. print $form->selectyesno("caneditamount", $object->caneditamount, 1);
  816. print '</td></tr>';
  817. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  818. print $form->selectyesno("vote", $object->vote, 1);
  819. print '</td></tr>';
  820. print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">';
  821. print '<input name="duration_value" size="5" value="'.$object->duration_value.'"> ';
  822. print $formproduct->selectMeasuringUnits("duration_unit", "time", ($object->duration_unit === '' ? 'y' : $object->duration_unit), 0, 1);
  823. print '</td></tr>';
  824. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  825. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  826. $doleditor = new DolEditor('comment', $object->note_public, '', 220, 'dolibarr_notes', '', false, true, isModEnabled('fckeditor'), 15, '90%');
  827. $doleditor->Create();
  828. print "</td></tr>";
  829. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  830. $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, isModEnabled('fckeditor'), 15, '90%');
  831. $doleditor->Create();
  832. print "</td></tr>";
  833. // Other attributes
  834. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
  835. print '</table>';
  836. print dol_get_fiche_end();
  837. print $form->buttonsSaveCancel();
  838. print "</form>";
  839. }
  840. }
  841. // End of page
  842. llxFooter();
  843. $db->close();