card.php 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735
  1. <?php
  2. /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
  7. * Copyright (C) 2012-2016 Philippe Grand <philippe.grand@atoo-net.com>
  8. * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/adherents/card.php
  25. * \ingroup member
  26. * \brief Page of member
  27. */
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.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.'/adherents/class/cotisation.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  39. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  40. $langs->load("companies");
  41. $langs->load("bills");
  42. $langs->load("members");
  43. $langs->load("users");
  44. $langs->load('other');
  45. $action=GETPOST('action','alpha');
  46. $cancel=GETPOST('cancel');
  47. $backtopage=GETPOST('backtopage','alpha');
  48. $confirm=GETPOST('confirm','alpha');
  49. $rowid=GETPOST('rowid','int');
  50. $typeid=GETPOST('typeid','int');
  51. $userid=GETPOST('userid','int');
  52. $socid=GETPOST('socid','int');
  53. if (! empty($conf->mailmanspip->enabled))
  54. {
  55. include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';
  56. $langs->load('mailmanspip');
  57. $mailmanspip = new MailmanSpip($db);
  58. }
  59. $object = new Adherent($db);
  60. $extrafields = new ExtraFields($db);
  61. // fetch optionals attributes and labels
  62. $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
  63. // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
  64. $object->getCanvas($rowid);
  65. $canvas = $object->canvas?$object->canvas:GETPOST("canvas");
  66. $objcanvas=null;
  67. if (! empty($canvas))
  68. {
  69. require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
  70. $objcanvas = new Canvas($db, $action);
  71. $objcanvas->getCanvas('adherent', 'membercard', $canvas);
  72. }
  73. // Security check
  74. $result=restrictedArea($user, 'adherent', $rowid, '', '', 'fk_soc', 'rowid', $objcanvas);
  75. if ($rowid > 0)
  76. {
  77. // Load member
  78. $result = $object->fetch($rowid);
  79. // Define variables to know what current user can do on users
  80. $canadduser=($user->admin || $user->rights->user->user->creer);
  81. // Define variables to know what current user can do on properties of user linked to edited member
  82. if ($object->user_id)
  83. {
  84. // $ User is the user who edits, $ object->user_id is the id of the related user in the edited member
  85. $caneditfielduser=((($user->id == $object->user_id) && $user->rights->user->self->creer)
  86. || (($user->id != $object->user_id) && $user->rights->user->user->creer));
  87. $caneditpassworduser=((($user->id == $object->user_id) && $user->rights->user->self->password)
  88. || (($user->id != $object->user_id) && $user->rights->user->user->password));
  89. }
  90. }
  91. // Define variables to determine what the current user can do on the members
  92. $canaddmember=$user->rights->adherent->creer;
  93. // Define variables to determine what the current user can do on the properties of a member
  94. if ($rowid)
  95. {
  96. $caneditfieldmember=$user->rights->adherent->creer;
  97. }
  98. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  99. $hookmanager->initHooks(array('membercard','globalcard'));
  100. /*
  101. * Actions
  102. */
  103. if ($cancel) $action='';
  104. $parameters=array('rowid'=>$rowid, 'objcanvas'=>$objcanvas);
  105. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  106. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  107. if (empty($reshook))
  108. {
  109. if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
  110. {
  111. $error=0;
  112. if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only
  113. {
  114. if ($userid != $user->id && $userid != $object->user_id)
  115. {
  116. $error++;
  117. setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors');
  118. }
  119. }
  120. if (! $error)
  121. {
  122. if ($userid != $object->user_id) // If link differs from currently in database
  123. {
  124. $result=$object->setUserId($userid);
  125. if ($result < 0) dol_print_error($object->db,$object->error);
  126. $action='';
  127. }
  128. }
  129. }
  130. if ($action == 'setsocid')
  131. {
  132. $error=0;
  133. if (! $error)
  134. {
  135. if ($socid != $object->fk_soc) // If link differs from currently in database
  136. {
  137. $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
  138. $sql.=" WHERE fk_soc = '".$socid."'";
  139. $sql.=" AND entity = ".$conf->entity;
  140. $resql = $db->query($sql);
  141. if ($resql)
  142. {
  143. $obj = $db->fetch_object($resql);
  144. if ($obj && $obj->rowid > 0)
  145. {
  146. $othermember=new Adherent($db);
  147. $othermember->fetch($obj->rowid);
  148. $thirdparty=new Societe($db);
  149. $thirdparty->fetch($socid);
  150. $error++;
  151. setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), null, 'errors');
  152. }
  153. }
  154. if (! $error)
  155. {
  156. $result=$object->setThirdPartyId($socid);
  157. if ($result < 0) dol_print_error($object->db,$object->error);
  158. $action='';
  159. }
  160. }
  161. }
  162. }
  163. // Create user from a member
  164. if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer)
  165. {
  166. if ($result > 0)
  167. {
  168. // Creation user
  169. $nuser = new User($db);
  170. $result=$nuser->create_from_member($object,GETPOST('login'));
  171. if ($result < 0)
  172. {
  173. $langs->load("errors");
  174. setEventMessages($langs->trans($nuser->error), null, 'errors');
  175. }
  176. }
  177. else
  178. {
  179. setEventMessages($object->errors, $object->error, 'errors');
  180. }
  181. }
  182. // Create third party from a member
  183. if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer)
  184. {
  185. if ($result > 0)
  186. {
  187. // User creation
  188. $company = new Societe($db);
  189. $result=$company->create_from_member($object,GETPOST('companyname'));
  190. if ($result < 0)
  191. {
  192. $langs->load("errors");
  193. setEventMessages($langs->trans($company->error), null, 'errors');
  194. setEventMessages($company->error, $company->errors, 'errors');
  195. }
  196. }
  197. else
  198. {
  199. setEventMessages($object->error, $object->errors, 'errors');
  200. }
  201. }
  202. if ($action == 'confirm_sendinfo' && $confirm == 'yes')
  203. {
  204. if ($object->email)
  205. {
  206. $from=$conf->email_from;
  207. if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM;
  208. $result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent"));
  209. $langs->load("mails");
  210. setEventMessages($langs->trans("MailSuccessfulySent", $from, $object->email), null, 'mesgs');
  211. }
  212. }
  213. if ($action == 'update' && ! $cancel && $user->rights->adherent->creer)
  214. {
  215. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  216. $birthdate='';
  217. if (isset($_POST["birthday"]) && $_POST["birthday"]
  218. && isset($_POST["birthmonth"]) && $_POST["birthmonth"]
  219. && isset($_POST["birthyear"]) && $_POST["birthyear"])
  220. {
  221. $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]);
  222. }
  223. $lastname=$_POST["lastname"];
  224. $firstname=$_POST["firstname"];
  225. $morphy=$_POST["morphy"];
  226. $login=$_POST["login"];
  227. if ($morphy != 'mor' && empty($lastname)) {
  228. $error++;
  229. $langs->load("errors");
  230. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors');
  231. }
  232. if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) {
  233. $error++;
  234. $langs->load("errors");
  235. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
  236. }
  237. if ($morphy == 'mor' && empty($societe)) {
  238. $error++;
  239. $langs->load("errors");
  240. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors');
  241. }
  242. // Test si le login existe deja
  243. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  244. {
  245. if (empty($login)) {
  246. $error++;
  247. setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Login")), null, 'errors');
  248. }
  249. }
  250. // Create new object
  251. if ($result > 0 && ! $error)
  252. {
  253. $object->oldcopy = clone $object;
  254. // Change values
  255. $object->civility_id = trim($_POST["civility_id"]);
  256. $object->firstname = trim($_POST["firstname"]);
  257. $object->lastname = trim($_POST["lastname"]);
  258. $object->login = trim($_POST["login"]);
  259. $object->pass = trim($_POST["pass"]);
  260. $object->societe = trim($_POST["societe"]);
  261. $object->company = trim($_POST["societe"]);
  262. $object->address = trim($_POST["address"]);
  263. $object->zip = trim($_POST["zipcode"]);
  264. $object->town = trim($_POST["town"]);
  265. $object->state_id = $_POST["state_id"];
  266. $object->country_id = $_POST["country_id"];
  267. $object->phone = trim($_POST["phone"]);
  268. $object->phone_perso = trim($_POST["phone_perso"]);
  269. $object->phone_mobile= trim($_POST["phone_mobile"]);
  270. $object->email = trim($_POST["email"]);
  271. $object->skype = trim($_POST["skype"]);
  272. $object->birth = $birthdate;
  273. $object->typeid = $_POST["typeid"];
  274. //$object->note = trim($_POST["comment"]);
  275. $object->morphy = $_POST["morphy"];
  276. if (GETPOST('deletephoto')) $object->photo='';
  277. elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
  278. // Get status and public property
  279. $object->statut = $_POST["statut"];
  280. $object->public = $_POST["public"];
  281. // Fill array 'array_options' with data from add form
  282. $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
  283. if ($ret < 0) $error++;
  284. // Check if we need to also synchronize user information
  285. $nosyncuser=0;
  286. if ($object->user_id) // If linked to a user
  287. {
  288. if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1; // Disable synchronizing
  289. }
  290. // Check if we need to also synchronize password information
  291. $nosyncuserpass=0;
  292. if ($object->user_id) // If linked to a user
  293. {
  294. if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1; // Disable synchronizing
  295. }
  296. $result=$object->update($user,0,$nosyncuser,$nosyncuserpass);
  297. if ($result >= 0 && ! count($object->errors))
  298. {
  299. $categories = GETPOST('memcats', 'array');
  300. $object->setCategories($categories);
  301. // Logo/Photo save
  302. $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1,$object,'member').'/photos';
  303. $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
  304. if ($file_OK)
  305. {
  306. if (GETPOST('deletephoto'))
  307. {
  308. require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
  309. $fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'member').'/photos/'.$object->photo;
  310. $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'member').'/photos/thumbs';
  311. dol_delete_file($fileimg);
  312. dol_delete_dir_recursive($dirthumbs);
  313. }
  314. if (image_format_supported($_FILES['photo']['name']) > 0)
  315. {
  316. dol_mkdir($dir);
  317. if (@is_dir($dir))
  318. {
  319. $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
  320. if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0)
  321. {
  322. setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
  323. }
  324. else
  325. {
  326. // Create thumbs
  327. $object->addThumbs($newfile);
  328. }
  329. }
  330. }
  331. else
  332. {
  333. setEventMessages("ErrorBadImageFormat", null, 'errors');
  334. }
  335. }
  336. else
  337. {
  338. switch($_FILES['photo']['error'])
  339. {
  340. case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
  341. case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
  342. $errors[] = "ErrorFileSizeTooLarge";
  343. break;
  344. case 3: //uploaded file was only partially uploaded
  345. $errors[] = "ErrorFilePartiallyUploaded";
  346. break;
  347. }
  348. }
  349. $rowid=$object->id;
  350. $action='';
  351. if (! empty($backtopage))
  352. {
  353. header("Location: ".$backtopage);
  354. exit;
  355. }
  356. }
  357. else
  358. {
  359. setEventMessages($object->error, $object->errors, 'errors');
  360. $action='';
  361. }
  362. }
  363. else
  364. {
  365. $action='edit';
  366. }
  367. }
  368. if ($action == 'add' && $user->rights->adherent->creer)
  369. {
  370. if ($canvas) $object->canvas=$canvas;
  371. $birthdate='';
  372. if (isset($_POST["birthday"]) && $_POST["birthday"]
  373. && isset($_POST["birthmonth"]) && $_POST["birthmonth"]
  374. && isset($_POST["birthyear"]) && $_POST["birthyear"])
  375. {
  376. $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]);
  377. }
  378. $datecotisation='';
  379. if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"]))
  380. {
  381. $datecotisation=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
  382. }
  383. $typeid=$_POST["typeid"];
  384. $civility_id=$_POST["civility_id"];
  385. $lastname=$_POST["lastname"];
  386. $firstname=$_POST["firstname"];
  387. $societe=$_POST["societe"];
  388. $address=$_POST["address"];
  389. $zip=$_POST["zipcode"];
  390. $town=$_POST["town"];
  391. $state_id=$_POST["state_id"];
  392. $country_id=$_POST["country_id"];
  393. $phone=$_POST["phone"];
  394. $phone_perso=$_POST["phone_perso"];
  395. $phone_mobile=$_POST["phone_mobile"];
  396. $skype=$_POST["member_skype"];
  397. $email=$_POST["member_email"];
  398. $login=$_POST["member_login"];
  399. $pass=$_POST["password"];
  400. $photo=$_POST["photo"];
  401. //$comment=$_POST["comment"];
  402. $morphy=$_POST["morphy"];
  403. $cotisation=$_POST["cotisation"];
  404. $public=$_POST["public"];
  405. $userid=$_POST["userid"];
  406. $socid=$_POST["socid"];
  407. $object->civility_id = $civility_id;
  408. $object->firstname = $firstname;
  409. $object->lastname = $lastname;
  410. $object->societe = $societe;
  411. $object->address = $address;
  412. $object->zip = $zip;
  413. $object->town = $town;
  414. $object->state_id = $state_id;
  415. $object->country_id = $country_id;
  416. $object->phone = $phone;
  417. $object->phone_perso = $phone_perso;
  418. $object->phone_mobile= $phone_mobile;
  419. $object->skype = $skype;
  420. $object->email = $email;
  421. $object->login = $login;
  422. $object->pass = $pass;
  423. $object->birth = $birthdate;
  424. $object->photo = $photo;
  425. $object->typeid = $typeid;
  426. //$object->note = $comment;
  427. $object->morphy = $morphy;
  428. $object->user_id = $userid;
  429. $object->fk_soc = $socid;
  430. $object->public = $public;
  431. // Fill array 'array_options' with data from add form
  432. $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
  433. if ($ret < 0) $error++;
  434. // Check parameters
  435. if (empty($morphy) || $morphy == "-1") {
  436. $error++;
  437. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Nature")), null, 'errors');
  438. }
  439. // Tests if the login already exists
  440. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  441. {
  442. if (empty($login)) {
  443. $error++;
  444. setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Login")), null, 'errors');
  445. }
  446. else {
  447. $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'";
  448. $result = $db->query($sql);
  449. if ($result) {
  450. $num = $db->num_rows($result);
  451. }
  452. if ($num) {
  453. $error++;
  454. $langs->load("errors");
  455. setEventMessages($langs->trans("ErrorLoginAlreadyExists",$login), null, 'errors');
  456. }
  457. }
  458. if (empty($pass)) {
  459. $error++;
  460. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Password")), null, 'errors');
  461. }
  462. }
  463. if ($morphy == 'mor' && empty($societe)) {
  464. $error++;
  465. $langs->load("errors");
  466. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors');
  467. }
  468. if ($morphy != 'mor' && empty($lastname)) {
  469. $error++;
  470. $langs->load("errors");
  471. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors');
  472. }
  473. if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) {
  474. $error++;
  475. $langs->load("errors");
  476. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
  477. }
  478. if (! ($typeid > 0)) { // Keep () before !
  479. $error++;
  480. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
  481. }
  482. if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) {
  483. $error++;
  484. $langs->load("errors");
  485. setEventMessages($langs->trans("ErrorBadEMail",$email), null, 'errors');
  486. }
  487. $public=0;
  488. if (isset($public)) $public=1;
  489. if (! $error)
  490. {
  491. $db->begin();
  492. // Email about right and login does not exist
  493. $result=$object->create($user);
  494. if ($result > 0)
  495. {
  496. // Foundation categories
  497. $memcats = GETPOST('memcats', 'array');
  498. $object->setCategories($memcats);
  499. $db->commit();
  500. $rowid=$object->id;
  501. $action='';
  502. }
  503. else
  504. {
  505. $db->rollback();
  506. if ($object->error) {
  507. setEventMessages($object->error, $object->errors, 'errors');
  508. } else {
  509. setEventMessages($object->error, $object->errors, 'errors');
  510. }
  511. $action = 'create';
  512. }
  513. }
  514. else {
  515. $action = 'create';
  516. }
  517. }
  518. if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
  519. {
  520. $result=$object->delete($rowid);
  521. if ($result > 0)
  522. {
  523. if (! empty($backtopage))
  524. {
  525. header("Location: ".$backtopage);
  526. exit;
  527. }
  528. else
  529. {
  530. header("Location: list.php");
  531. exit;
  532. }
  533. }
  534. else
  535. {
  536. $errmesg=$object->error;
  537. }
  538. }
  539. if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes')
  540. {
  541. $error=0;
  542. $db->begin();
  543. $adht = new AdherentType($db);
  544. $adht->fetch($object->typeid);
  545. $result=$object->validate($user);
  546. if ($result >= 0 && ! count($object->errors))
  547. {
  548. // Send confirmation email (according to parameters of member type. Otherwise generic)
  549. if ($object->email && GETPOST("send_mail"))
  550. {
  551. $result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2);
  552. if ($result < 0)
  553. {
  554. $error++;
  555. setEventMessages($object->error, $object->errors, 'errors');
  556. }
  557. }
  558. }
  559. else
  560. {
  561. $error++;
  562. if ($object->error) {
  563. setEventMessages($object->error, $object->errors, 'errors');
  564. } else {
  565. setEventMessages($object->error, $object->errors, 'errors');
  566. }
  567. }
  568. if (! $error)
  569. {
  570. $db->commit();
  571. }
  572. else
  573. {
  574. $db->rollback();
  575. }
  576. $action='';
  577. }
  578. if ($user->rights->adherent->supprimer && $action == 'confirm_resign')
  579. {
  580. $error = 0;
  581. if ($confirm == 'yes')
  582. {
  583. $adht = new AdherentType($db);
  584. $adht->fetch($object->typeid);
  585. $result=$object->resiliate($user);
  586. if ($result >= 0 && ! count($object->errors))
  587. {
  588. if ($object->email && GETPOST("send_mail"))
  589. {
  590. $result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1);
  591. }
  592. if ($result < 0)
  593. {
  594. $error++;
  595. setEventMessages($object->error, $object->errors, 'errors');
  596. }
  597. }
  598. else
  599. {
  600. $error++;
  601. if ($object->error) {
  602. setEventMessages($object->error, $object->errors, 'errors');
  603. } else {
  604. setEventMessages($object->error, $object->errors, 'errors');
  605. }
  606. $action='';
  607. }
  608. }
  609. if (! empty($backtopage) && ! $error)
  610. {
  611. header("Location: ".$backtopage);
  612. exit;
  613. }
  614. }
  615. // SPIP Management
  616. if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes')
  617. {
  618. if (! count($object->errors))
  619. {
  620. if (!$mailmanspip->del_to_spip($object))
  621. {
  622. setEventMessages($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, null, 'errors');
  623. }
  624. }
  625. }
  626. if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes')
  627. {
  628. if (! count($object->errors))
  629. {
  630. if (!$mailmanspip->add_to_spip($object))
  631. {
  632. setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors');
  633. }
  634. }
  635. }
  636. }
  637. /*
  638. * View
  639. */
  640. $form = new Form($db);
  641. $formcompany = new FormCompany($db);
  642. $help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
  643. llxHeader('',$langs->trans("Member"),$help_url);
  644. $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
  645. if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
  646. {
  647. // -----------------------------------------
  648. // When used with CANVAS
  649. // -----------------------------------------
  650. if (empty($object->error) && $rowid)
  651. {
  652. $object = new Adherent($db);
  653. $result=$object->fetch($rowid);
  654. if ($result <= 0) dol_print_error('',$object->error);
  655. }
  656. $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
  657. $objcanvas->display_canvas($action); // Show template
  658. }
  659. else
  660. {
  661. // -----------------------------------------
  662. // When used in standard mode
  663. // -----------------------------------------
  664. if ($action == 'create')
  665. {
  666. /* ************************************************************************** */
  667. /* */
  668. /* Creation mode */
  669. /* */
  670. /* ************************************************************************** */
  671. $object->canvas=$canvas;
  672. $object->state_id = GETPOST('state_id', 'int');
  673. // We set country_id, country_code and country for the selected country
  674. $object->country_id=GETPOST('country_id','int')?GETPOST('country_id','int'):$mysoc->country_id;
  675. if ($object->country_id)
  676. {
  677. $tmparray=getCountry($object->country_id,'all');
  678. $object->country_code=$tmparray['code'];
  679. $object->country=$tmparray['label'];
  680. }
  681. $adht = new AdherentType($db);
  682. print load_fiche_titre($langs->trans("NewMember"));
  683. if ($conf->use_javascript_ajax)
  684. {
  685. print "\n".'<script type="text/javascript" language="javascript">';
  686. print 'jQuery(document).ready(function () {
  687. jQuery("#selectcountry_id").change(function() {
  688. document.formsoc.action.value="create";
  689. document.formsoc.submit();
  690. });
  691. function initfieldrequired()
  692. {
  693. jQuery("#tdcompany").removeClass("fieldrequired");
  694. jQuery("#tdlastname").removeClass("fieldrequired");
  695. jQuery("#tdfirstname").removeClass("fieldrequired");
  696. if (jQuery("#morphy").val() == \'mor\')
  697. {
  698. jQuery("#tdcompany").addClass("fieldrequired");
  699. }
  700. if (jQuery("#morphy").val() == \'phy\')
  701. {
  702. jQuery("#tdlastname").addClass("fieldrequired");
  703. jQuery("#tdfirstname").addClass("fieldrequired");
  704. }
  705. }
  706. jQuery("#morphy").change(function() {
  707. initfieldrequired();
  708. });
  709. initfieldrequired();
  710. })';
  711. print '</script>'."\n";
  712. }
  713. print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
  714. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  715. print '<input type="hidden" name="action" value="add">';
  716. dol_fiche_head('');
  717. print '<table class="border" width="100%">';
  718. print '<tbody>';
  719. // Login
  720. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  721. {
  722. print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="member_login" size="40" value="'.(isset($_POST["member_login"])?$_POST["member_login"]:$object->login).'"></td></tr>';
  723. }
  724. // Type
  725. print '<tr><td class="fieldrequired">'.$langs->trans("MemberType").'</td><td>';
  726. $listetype=$adht->liste_array();
  727. if (count($listetype))
  728. {
  729. print $form->selectarray("typeid", $listetype, GETPOST('typeid','int')?GETPOST('typeid','int'):$typeid, count($listetype)>1?1:0);
  730. } else {
  731. print '<font class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</font>';
  732. }
  733. print "</td>\n";
  734. // Morphy
  735. $morphys["phy"] = $langs->trans("Physical");
  736. $morphys["mor"] = $langs->trans("Moral");
  737. print '<tr><td class="fieldrequired">'.$langs->trans("Nature")."</td><td>\n";
  738. print $form->selectarray("morphy", $morphys, GETPOST('morphy','alpha')?GETPOST('morphy','alpha'):$object->morphy, 1);
  739. print "</td>\n";
  740. // Company
  741. print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.(GETPOST('societe','alpha')?GETPOST('societe','alpha'):$object->societe).'"></td></tr>';
  742. // Civility
  743. print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
  744. print $formcompany->select_civility(GETPOST('civility_id','int')?GETPOST('civility_id','int'):$object->civility_id,'civility_id').'</td>';
  745. print '</tr>';
  746. // Lastname
  747. print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" value="'.(GETPOST('lastname','alpha')?GETPOST('lastname','alpha'):$object->lastname).'" size="40"></td>';
  748. print '</tr>';
  749. // Firstname
  750. print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" size="40" value="'.(GETPOST('firstname','alpha')?GETPOST('firstname','alpha'):$object->firstname).'"></td>';
  751. print '</tr>';
  752. // EMail
  753. print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="member_email" size="40" value="'.(GETPOST('member_email','alpha')?GETPOST('member_email','alpha'):$object->email).'"></td></tr>';
  754. // Password
  755. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  756. {
  757. require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
  758. $generated_password=getRandomPassword(false);
  759. print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>';
  760. print '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">';
  761. print '</td></tr>';
  762. }
  763. // Address
  764. print '<tr><td valign="top">'.$langs->trans("Address").'</td><td>';
  765. print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="2">'.(GETPOST('address','alpha')?GETPOST('address','alpha'):$object->address).'</textarea>';
  766. print '</td></tr>';
  767. // Zip / Town
  768. print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
  769. print $formcompany->select_ziptown((GETPOST('zipcode','alpha')?GETPOST('zipcode','alpha'):$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
  770. print ' ';
  771. print $formcompany->select_ziptown((GETPOST('town','alpha')?GETPOST('town','alpha'):$object->town),'town',array('zipcode','selectcountry_id','state_id'));
  772. print '</td></tr>';
  773. // Country
  774. $object->country_id=$object->country_id?$object->country_id:$mysoc->country_id;
  775. print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>';
  776. print $form->select_country(GETPOST('country_id','alpha')?GETPOST('country_id','alpha'):$object->country_id,'country_id');
  777. if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
  778. print '</td></tr>';
  779. // State
  780. if (empty($conf->global->MEMBER_DISABLE_STATE))
  781. {
  782. print '<tr><td>'.$langs->trans('State').'</td><td>';
  783. if ($object->country_id)
  784. {
  785. print $formcompany->select_state(GETPOST('state_id','int')?GETPOST('state_id','int'):$object->state_id,$object->country_code);
  786. }
  787. else
  788. {
  789. print $countrynotdefined;
  790. }
  791. print '</td></tr>';
  792. }
  793. // Pro phone
  794. print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(GETPOST('phone','alpha')?GETPOST('phone','alpha'):$object->phone).'"></td></tr>';
  795. // Personal phone
  796. print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(GETPOST('phone_perso','alpha')?GETPOST('phone_perso','alpha'):$object->phone_perso).'"></td></tr>';
  797. // Mobile phone
  798. print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(GETPOST('phone_mobile','alpha')?GETPOST('phone_mobile','alpha'):$object->phone_mobile).'"></td></tr>';
  799. // Skype
  800. if (! empty($conf->skype->enabled))
  801. {
  802. print '<tr><td>'.$langs->trans("Skype").'</td><td><input type="text" name="member_skype" size="40" value="'.(GETPOST('member_skype','alpha')?GETPOST('member_skype','alpha'):$object->skype).'"></td></tr>';
  803. }
  804. // Birthday
  805. print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
  806. $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc');
  807. print "</td></tr>\n";
  808. // Public profil
  809. print "<tr><td>".$langs->trans("Public")."</td><td>\n";
  810. print $form->selectyesno("public",$object->public,1);
  811. print "</td></tr>\n";
  812. // Categories
  813. if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
  814. {
  815. print '<tr><td>' . fieldLabel('Categories', 'memcars') . '</td><td>';
  816. $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, 'parent', null, null, 1);
  817. print $form->multiselectarray('memcats', $cate_arbo, GETPOST('memcats', 'array'), null, null, null, null, '100%');
  818. print "</td></tr>";
  819. }
  820. // Other attributes
  821. $parameters=array();
  822. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
  823. if (empty($reshook) && ! empty($extrafields->attribute_label))
  824. {
  825. print $object->showOptionals($extrafields,'edit');
  826. }
  827. /*
  828. // Third party Dolibarr
  829. if (! empty($conf->societe->enabled))
  830. {
  831. print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td class="valeur">';
  832. print $form->select_company($object->fk_soc,'socid','',1);
  833. print '</td></tr>';
  834. }
  835. // Login Dolibarr
  836. print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td class="valeur">';
  837. print $form->select_dolusers($object->user_id, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
  838. print '</td></tr>';
  839. */
  840. print '<tbody>';
  841. print "</table>\n";
  842. dol_fiche_end();
  843. print '<div class="center">';
  844. print '<input type="submit" name="button" class="button" value="'.$langs->trans("AddMember").'">';
  845. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  846. print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
  847. print '</div>';
  848. print "</form>\n";
  849. }
  850. if ($action == 'edit')
  851. {
  852. /********************************************
  853. *
  854. * Edition mode
  855. *
  856. ********************************************/
  857. $res=$object->fetch($rowid);
  858. if ($res < 0) {
  859. dol_print_error($db,$object->error); exit;
  860. }
  861. $res=$object->fetch_optionals($object->id,$extralabels);
  862. if ($res < 0) {
  863. dol_print_error($db); exit;
  864. }
  865. $adht = new AdherentType($db);
  866. $adht->fetch($object->typeid);
  867. // We set country_id, and country_code, country of the chosen country
  868. $country=GETPOST('country','int');
  869. if (!empty($country) || $object->country_id)
  870. {
  871. $sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country where rowid = ".(!empty($country)?$country:$object->country_id);
  872. $resql=$db->query($sql);
  873. if ($resql)
  874. {
  875. $obj = $db->fetch_object($resql);
  876. }
  877. else
  878. {
  879. dol_print_error($db);
  880. }
  881. $object->country_id=$obj->rowid;
  882. $object->country_code=$obj->code;
  883. $object->country=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label;
  884. }
  885. $head = member_prepare_head($object);
  886. if ($conf->use_javascript_ajax)
  887. {
  888. print "\n".'<script type="text/javascript" language="javascript">';
  889. print 'jQuery(document).ready(function () {
  890. jQuery("#selectcountry_id").change(function() {
  891. document.formsoc.action.value="edit";
  892. document.formsoc.submit();
  893. });
  894. function initfieldrequired()
  895. {
  896. jQuery("#tdcompany").removeClass("fieldrequired");
  897. jQuery("#tdlastname").removeClass("fieldrequired");
  898. jQuery("#tdfirstname").removeClass("fieldrequired");
  899. if (jQuery("#morphy").val() == \'mor\')
  900. {
  901. jQuery("#tdcompany").addClass("fieldrequired");
  902. }
  903. if (jQuery("#morphy").val() == \'phy\')
  904. {
  905. jQuery("#tdlastname").addClass("fieldrequired");
  906. jQuery("#tdfirstname").addClass("fieldrequired");
  907. }
  908. }
  909. jQuery("#morphy").change(function() {
  910. initfieldrequired();
  911. });
  912. initfieldrequired();
  913. })';
  914. print '</script>'."\n";
  915. }
  916. $rowspan=15;
  917. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
  918. if (! empty($conf->societe->enabled)) $rowspan++;
  919. print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
  920. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
  921. print '<input type="hidden" name="action" value="update" />';
  922. print '<input type="hidden" name="rowid" value="'.$rowid.'" />';
  923. print '<input type="hidden" name="statut" value="'.$object->statut.'" />';
  924. if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
  925. dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
  926. print '<table class="border" width="100%">';
  927. // Ref
  928. print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$object->id.'</td></tr>';
  929. // Login
  930. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  931. {
  932. print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td colspan="2"><input type="text" name="login" size="30" value="'.(isset($_POST["login"])?$_POST["login"]:$object->login).'"></td></tr>';
  933. }
  934. // Morphy
  935. $morphys["phy"] = $langs->trans("Physical");
  936. $morphys["mor"] = $langs->trans("Morale");
  937. print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature").'</span></td><td>';
  938. print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
  939. print "</td>";
  940. // Photo
  941. print '<td align="center" class="hideonsmartphone" valign="middle" width="25%" rowspan="'.$rowspan.'">';
  942. print $form->showphoto('memberphoto',$object)."\n";
  943. if ($caneditfieldmember)
  944. {
  945. if ($object->photo) print "<br>\n";
  946. print '<table class="nobordernopadding">';
  947. if ($object->photo) print '<tr><td align="center"><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
  948. print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
  949. print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
  950. print '</table>';
  951. }
  952. print '</td>';
  953. // Type
  954. print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
  955. if ($user->rights->adherent->creer)
  956. {
  957. print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->typeid));
  958. }
  959. else
  960. {
  961. print $adht->getNomUrl(1);
  962. print '<input type="hidden" name="typeid" value="'.$object->typeid.'">';
  963. }
  964. print "</td></tr>";
  965. // Company
  966. print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.(isset($_POST["societe"])?$_POST["societe"]:$object->societe).'"></td></tr>';
  967. // Civility
  968. print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
  969. print $formcompany->select_civility(isset($_POST["civility_id"])?$_POST["civility_id"]:$object->civility_id)."\n";
  970. print '</td>';
  971. print '</tr>';
  972. // Lastname
  973. print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" size="40" value="'.(isset($_POST["lastname"])?$_POST["lastname"]:$object->lastname).'"></td>';
  974. print '</tr>';
  975. // Firstname
  976. print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" size="40" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td>';
  977. print '</tr>';
  978. // EMail
  979. print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="email" size="40" value="'.(isset($_POST["email"])?$_POST["email"]:$object->email).'"></td></tr>';
  980. // Password
  981. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  982. {
  983. print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td><td><input type="password" name="pass" size="30" value="'.(isset($_POST["pass"])?$_POST["pass"]:$object->pass).'"></td></tr>';
  984. }
  985. // Address
  986. print '<tr><td>'.$langs->trans("Address").'</td><td>';
  987. print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="2">'.(isset($_POST["address"])?$_POST["address"]:$object->address).'</textarea>';
  988. print '</td></tr>';
  989. // Zip / Town
  990. print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
  991. print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
  992. print ' ';
  993. print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id'));
  994. print '</td></tr>';
  995. // Country
  996. //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined
  997. print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>';
  998. print $form->select_country(isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id,'country_id');
  999. if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
  1000. print '</td></tr>';
  1001. // State
  1002. if (empty($conf->global->MEMBER_DISABLE_STATE))
  1003. {
  1004. print '<tr><td>'.$langs->trans('State').'</td><td>';
  1005. print $formcompany->select_state($object->state_id,isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id);
  1006. print '</td></tr>';
  1007. }
  1008. // Pro phone
  1009. print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"])?$_POST["phone"]:$object->phone).'"></td></tr>';
  1010. // Personal phone
  1011. print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"])?$_POST["phone_perso"]:$object->phone_perso).'"></td></tr>';
  1012. // Mobile phone
  1013. print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"])?$_POST["phone_mobile"]:$object->phone_mobile).'"></td></tr>';
  1014. // Skype
  1015. if (! empty($conf->skype->enabled))
  1016. {
  1017. print '<tr><td>'.$langs->trans("Skype").'</td><td><input type="text" name="skype" size="40" value="'.(isset($_POST["skype"])?$_POST["skype"]:$object->skype).'"></td></tr>';
  1018. }
  1019. // Birthday
  1020. print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
  1021. $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc');
  1022. print "</td></tr>\n";
  1023. // Public profil
  1024. print "<tr><td>".$langs->trans("Public")."</td><td>\n";
  1025. print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1);
  1026. print "</td></tr>\n";
  1027. // Categories
  1028. if (! empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire ))
  1029. {
  1030. print '<tr><td>' . fieldLabel('Categories', 'memcats') . '</td>';
  1031. print '<td colspan="2">';
  1032. $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1);
  1033. $c = new Categorie($db);
  1034. $cats = $c->containing($object->id, Categorie::TYPE_MEMBER);
  1035. foreach ($cats as $cat) {
  1036. $arrayselected[] = $cat->id;
  1037. }
  1038. print $form->multiselectarray('memcats', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
  1039. print "</td></tr>";
  1040. }
  1041. // Other attributes
  1042. $parameters=array("colspan"=>2);
  1043. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
  1044. if (empty($reshook) && ! empty($extrafields->attribute_label))
  1045. {
  1046. print $object->showOptionals($extrafields,'edit',$parameters);
  1047. }
  1048. // Third party Dolibarr
  1049. if (! empty($conf->societe->enabled))
  1050. {
  1051. print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td colspan="2" class="valeur">';
  1052. if ($object->fk_soc)
  1053. {
  1054. $company=new Societe($db);
  1055. $result=$company->fetch($object->fk_soc);
  1056. print $company->getNomUrl(1);
  1057. }
  1058. else
  1059. {
  1060. print $langs->trans("NoThirdPartyAssociatedToMember");
  1061. }
  1062. print '</td></tr>';
  1063. }
  1064. // Login Dolibarr
  1065. print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td colspan="2" class="valeur">';
  1066. if ($object->user_id)
  1067. {
  1068. $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
  1069. }
  1070. else print $langs->trans("NoDolibarrAccess");
  1071. print '</td></tr>';
  1072. print '</table>';
  1073. dol_fiche_end();
  1074. print '<div class="center">';
  1075. print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
  1076. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  1077. print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
  1078. print '</div>';
  1079. print '</form>';
  1080. }
  1081. if ($rowid && $action != 'edit')
  1082. {
  1083. /* ************************************************************************** */
  1084. /* */
  1085. /* View mode */
  1086. /* */
  1087. /* ************************************************************************** */
  1088. $res=$object->fetch($rowid);
  1089. if ($res < 0) {
  1090. dol_print_error($db,$object->error); exit;
  1091. }
  1092. $res=$object->fetch_optionals($object->id,$extralabels);
  1093. if ($res < 0) {
  1094. dol_print_error($db); exit;
  1095. }
  1096. $adht = new AdherentType($db);
  1097. $res=$adht->fetch($object->typeid);
  1098. if ($res < 0) {
  1099. dol_print_error($db); exit;
  1100. }
  1101. /*
  1102. * Show tabs
  1103. */
  1104. $head = member_prepare_head($object);
  1105. dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
  1106. // Confirm create user
  1107. if ($action == 'create_user')
  1108. {
  1109. $login=$object->login;
  1110. if (empty($login))
  1111. {
  1112. // Full firstname and name separated with a dot : firstname.name
  1113. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  1114. $login=dol_buildlogin($object->lastname,$object->firstname);
  1115. }
  1116. if (empty($login)) $login=strtolower(substr($object->firstname, 0, 4)) . strtolower(substr($object->lastname, 0, 4));
  1117. // Create a form array
  1118. $formquestion=array(
  1119. array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
  1120. );
  1121. $text=$langs->trans("ConfirmCreateLogin").'<br>';
  1122. if (! empty($conf->societe->enabled))
  1123. {
  1124. if ($object->fk_soc > 0) $text.=$langs->trans("UserWillBeExternalUser");
  1125. else $text.=$langs->trans("UserWillBeInternalUser");
  1126. }
  1127. print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrLogin"),$text,"confirm_create_user",$formquestion,'yes');
  1128. }
  1129. // Confirm create third party
  1130. if ($action == 'create_thirdparty')
  1131. {
  1132. $name = $object->getFullName($langs);
  1133. if (! empty($name))
  1134. {
  1135. if ($object->societe) $name.=' ('.$object->societe.')';
  1136. }
  1137. else
  1138. {
  1139. $name=$object->societe;
  1140. }
  1141. // Create a form array
  1142. $formquestion=array( array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name));
  1143. print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1);
  1144. }
  1145. // Confirm validate member
  1146. if ($action == 'valid')
  1147. {
  1148. $langs->load("mails");
  1149. $adht = new AdherentType($db);
  1150. $adht->fetch($object->typeid);
  1151. $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_VALID_SUBJECT);
  1152. $texttosend=$object->makeSubstitution($adht->getMailOnValid());
  1153. $tmp=$langs->trans("SendAnEMailToMember");
  1154. $tmp.='<br>('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
  1155. $tmp.=$langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
  1156. $helpcontent='';
  1157. $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
  1158. $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
  1159. $helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
  1160. $helpcontent.=$subjecttosend."\n";
  1161. $helpcontent.="<br>";
  1162. $helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>';
  1163. $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
  1164. $label=$form->textwithpicto($tmp,$helpcontent,1,'help');
  1165. // Create form popup
  1166. $formquestion=array();
  1167. if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false));
  1168. if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_MAILMAN)) {
  1169. $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>'');
  1170. }
  1171. if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) {
  1172. $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>'');
  1173. }
  1174. print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1,1);
  1175. }
  1176. // Confirm send card by mail
  1177. if ($action == 'sendinfo')
  1178. {
  1179. print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1);
  1180. }
  1181. // Confirm terminate
  1182. if ($action == 'resign')
  1183. {
  1184. $langs->load("mails");
  1185. $adht = new AdherentType($db);
  1186. $adht->fetch($object->typeid);
  1187. $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_RESIL_SUBJECT);
  1188. $texttosend=$object->makeSubstitution($adht->getMailOnResiliate());
  1189. $tmp=$langs->trans("SendAnEMailToMember");
  1190. $tmp.='<br>('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
  1191. $tmp.=$langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
  1192. $helpcontent='';
  1193. $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
  1194. $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
  1195. $helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
  1196. $helpcontent.=$subjecttosend."\n";
  1197. $helpcontent.="<br>";
  1198. $helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>';
  1199. $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
  1200. $label=$form->textwithpicto($tmp,$helpcontent,1,'help');
  1201. // Create an array
  1202. $formquestion=array();
  1203. if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false'));
  1204. if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
  1205. print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion,'no',1);
  1206. }
  1207. // Confirm remove member
  1208. if ($action == 'delete')
  1209. {
  1210. $formquestion=array();
  1211. if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
  1212. print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1);
  1213. }
  1214. // Confirm add in spip
  1215. if ($action == 'add_spip')
  1216. {
  1217. print $form->formconfirm("card.php?rowid=".$rowid, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip');
  1218. }
  1219. // Confirm removed from spip
  1220. if ($action == 'del_spip')
  1221. {
  1222. print $form->formconfirm("card.php?rowid=$rowid", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip');
  1223. }
  1224. $rowspan=17;
  1225. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
  1226. if (! empty($conf->societe->enabled)) $rowspan++;
  1227. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
  1228. dol_banner_tab($object, 'rowid', $linkback);
  1229. print '<div class="fichecenter">';
  1230. print '<div class="fichehalfleft">';
  1231. print '<div class="underbanner clearboth"></div>';
  1232. print '<table class="border centpercent">';
  1233. // Login
  1234. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  1235. {
  1236. print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
  1237. }
  1238. // Type
  1239. print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
  1240. // Morphy
  1241. print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
  1242. print '</tr>';
  1243. // Company
  1244. print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>';
  1245. // Civility
  1246. print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
  1247. print '</tr>';
  1248. // Password
  1249. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  1250. {
  1251. print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i','*',$object->pass);
  1252. if ($object->pass) print preg_replace('/./i','*',$object->pass);
  1253. else
  1254. {
  1255. if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
  1256. else print $langs->trans("Hidden");
  1257. }
  1258. if ((! empty($object->pass) || ! empty($object->pass_crypted)) && empty($object->user_id))
  1259. {
  1260. $langs->load("errors");
  1261. $htmltext=$langs->trans("WarningPasswordSetWithNoAccount");
  1262. print ' '.$form->textwithpicto('', $htmltext,1,'warning');
  1263. }
  1264. print '</td></tr>';
  1265. }
  1266. print '</table>';
  1267. print '</div>';
  1268. print '<div class="fichehalfright"><div class="ficheaddleft">';
  1269. print '<div class="underbanner clearboth"></div>';
  1270. print '<table class="border tableforfield" width="100%">';
  1271. // Birthday
  1272. print '<tr><td class="titlefield">'.$langs->trans("Birthday").'</td><td class="valeur">'.dol_print_date($object->birth,'day').'</td></tr>';
  1273. // Public
  1274. print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
  1275. // Categories
  1276. if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
  1277. {
  1278. print '<tr><td>' . $langs->trans("Categories") . '</td>';
  1279. print '<td colspan="2">';
  1280. print $form->showCategories($object->id, 'member', 1);
  1281. print '</td></tr>';
  1282. }
  1283. // Other attributes
  1284. $parameters=array('colspan'=>2);
  1285. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
  1286. if (empty($reshook) && ! empty($extrafields->attribute_label))
  1287. {
  1288. print $object->showOptionals($extrafields, 'view', $parameters);
  1289. }
  1290. // Date end subscription
  1291. print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
  1292. if ($object->datefin)
  1293. {
  1294. print dol_print_date($object->datefin,'day');
  1295. if ($object->hasDelay()) {
  1296. print " ".img_warning($langs->trans("Late"));
  1297. }
  1298. }
  1299. else
  1300. {
  1301. if (! $adht->cotisation)
  1302. {
  1303. print $langs->trans("SubscriptionNotRecorded");
  1304. if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
  1305. }
  1306. else
  1307. {
  1308. print $langs->trans("SubscriptionNotReceived");
  1309. if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
  1310. }
  1311. }
  1312. print '</td></tr>';
  1313. // Third party Dolibarr
  1314. if (! empty($conf->societe->enabled))
  1315. {
  1316. print '<tr><td>';
  1317. print '<table class="nobordernopadding" width="100%"><tr><td>';
  1318. print $langs->trans("LinkedToDolibarrThirdParty");
  1319. print '</td>';
  1320. if ($action != 'editthirdparty' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'</a></td>';
  1321. print '</tr></table>';
  1322. print '</td><td colspan="2" class="valeur">';
  1323. if ($action == 'editthirdparty')
  1324. {
  1325. $htmlname='socid';
  1326. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
  1327. print '<input type="hidden" name="rowid" value="'.$object->id.'">';
  1328. print '<input type="hidden" name="action" value="set'.$htmlname.'">';
  1329. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  1330. print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
  1331. print '<tr><td>';
  1332. print $form->select_company($object->fk_soc,'socid','',1);
  1333. print '</td>';
  1334. print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
  1335. print '</tr></table></form>';
  1336. }
  1337. else
  1338. {
  1339. if ($object->fk_soc)
  1340. {
  1341. $company=new Societe($db);
  1342. $result=$company->fetch($object->fk_soc);
  1343. print $company->getNomUrl(1);
  1344. }
  1345. else
  1346. {
  1347. print $langs->trans("NoThirdPartyAssociatedToMember");
  1348. }
  1349. }
  1350. print '</td></tr>';
  1351. }
  1352. // Login Dolibarr
  1353. print '<tr><td>';
  1354. print '<table class="nobordernopadding" width="100%"><tr><td>';
  1355. print $langs->trans("LinkedToDolibarrUser");
  1356. print '</td>';
  1357. if ($action != 'editlogin' && $user->rights->adherent->creer)
  1358. {
  1359. print '<td align="right">';
  1360. if ($user->rights->user->user->creer)
  1361. {
  1362. print '<a href="'.$_SERVER["PHP_SELF"].'?action=editlogin&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToUser'),1).'</a>';
  1363. }
  1364. print '</td>';
  1365. }
  1366. print '</tr></table>';
  1367. print '</td><td colspan="2" class="valeur">';
  1368. if ($action == 'editlogin')
  1369. {
  1370. $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
  1371. }
  1372. else
  1373. {
  1374. if ($object->user_id)
  1375. {
  1376. $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
  1377. }
  1378. else print $langs->trans("NoDolibarrAccess");
  1379. }
  1380. print '</td></tr>';
  1381. print "</table>\n";
  1382. print "</div></div></div>\n";
  1383. print '<div style="clear:both"></div>';
  1384. dol_fiche_end();
  1385. /*
  1386. * Hotbar
  1387. */
  1388. print '<div class="tabsAction">';
  1389. $parameters = array();
  1390. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
  1391. if (empty($reshook)) {
  1392. if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty')
  1393. {
  1394. // Modify
  1395. if ($user->rights->adherent->creer)
  1396. {
  1397. print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=edit">'.$langs->trans("Modify")."</a></div>";
  1398. }
  1399. else
  1400. {
  1401. print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Modify").'</font></div>';
  1402. }
  1403. // Validate
  1404. if ($object->statut == -1)
  1405. {
  1406. if ($user->rights->adherent->creer)
  1407. {
  1408. print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=valid">'.$langs->trans("Validate")."</a></div>\n";
  1409. }
  1410. else
  1411. {
  1412. print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Validate").'</font></div>';
  1413. }
  1414. }
  1415. // Reactivate
  1416. if ($object->statut == 0)
  1417. {
  1418. if ($user->rights->adherent->creer)
  1419. {
  1420. print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=valid">'.$langs->trans("Reenable")."</a></div>\n";
  1421. }
  1422. else
  1423. {
  1424. print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Reenable")."</font></div>";
  1425. }
  1426. }
  1427. // Send card by email
  1428. if ($user->rights->adherent->creer)
  1429. {
  1430. if ($object->statut >= 1)
  1431. {
  1432. if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a></div>\n";
  1433. else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendCardByMail")."</a></div>\n";
  1434. }
  1435. else
  1436. {
  1437. print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("SendCardByMail")."</font></div>";
  1438. }
  1439. }
  1440. else
  1441. {
  1442. print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</font></div>";
  1443. }
  1444. // Terminate
  1445. if ($object->statut >= 1)
  1446. {
  1447. if ($user->rights->adherent->supprimer)
  1448. {
  1449. print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=resign">'.$langs->trans("Resiliate")."</a></div>\n";
  1450. }
  1451. else
  1452. {
  1453. print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Resiliate")."</font></div>";
  1454. }
  1455. }
  1456. // Create third party
  1457. if (! empty($conf->societe->enabled) && ! $object->fk_soc)
  1458. {
  1459. if ($user->rights->societe->creer)
  1460. {
  1461. if ($object->statut != -1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">'.$langs->trans("CreateDolibarrThirdParty").'</a></div>';
  1462. else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrThirdParty").'</a></div>';
  1463. }
  1464. else
  1465. {
  1466. print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrThirdParty")."</font></div>";
  1467. }
  1468. }
  1469. // Create user
  1470. if (! $user->societe_id && ! $object->user_id)
  1471. {
  1472. if ($user->rights->user->user->creer)
  1473. {
  1474. if ($object->statut != -1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
  1475. else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
  1476. }
  1477. else
  1478. {
  1479. print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin")."</font></div>";
  1480. }
  1481. }
  1482. // Delete
  1483. if ($user->rights->adherent->supprimer)
  1484. {
  1485. print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete">'.$langs->trans("Delete")."</a></div>\n";
  1486. }
  1487. else
  1488. {
  1489. print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Delete")."</font></div>";
  1490. }
  1491. // Action SPIP
  1492. if (! empty($conf->mailmanspip->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP))
  1493. {
  1494. $isinspip = $mailmanspip->is_in_spip($object);
  1495. if ($isinspip == 1)
  1496. {
  1497. print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=del_spip">'.$langs->trans("DeleteIntoSpip")."</a></div>\n";
  1498. }
  1499. if ($isinspip == 0)
  1500. {
  1501. print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=add_spip">'.$langs->trans("AddIntoSpip")."</a></div>\n";
  1502. }
  1503. }
  1504. }
  1505. }
  1506. print '</div>';
  1507. if ($isinspip == -1)
  1508. {
  1509. print '<br><br><font class="error">'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.'</font>';
  1510. }
  1511. print "<br>\n";
  1512. }
  1513. }
  1514. llxFooter();
  1515. $db->close();