card.php 59 KB

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