PageRenderTime 55ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/public/members/new.php

https://bitbucket.org/speedealing/speedealing
PHP | 609 lines | 456 code | 56 blank | 97 comment | 87 complexity | 2bda25d9837dece746d21fcbc0210e4e MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2001-2002 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/public/members/new.php
  23. * \ingroup member
  24. * \brief Example of form to add a new member
  25. *
  26. * Note that you can add following constant to change behaviour of page
  27. * MEMBER_NEWFORM_AMOUNT Default amount for autosubscribe form
  28. * MEMBER_NEWFORM_EDITAMOUNT Amount can be edited
  29. * MEMBER_NEWFORM_PAYONLINE Suggest paypemt with paypal of paybox
  30. * MEMBER_NEWFORM_DOLIBARRTURNOVER Show field turnover (specific for dolibarr foundation)
  31. * MEMBER_URL_REDIRECT_SUBSCRIPTION Url to redirect once subscribe submitted
  32. * MEMBER_NEWFORM_FORCETYPE Force type of member
  33. * MEMBER_NEWFORM_FORCEMORPHY Force nature of member (mor/phy)
  34. * MEMBER_NEWFORM_FORCECOUNTRYCODE Force country
  35. */
  36. define("NOLOGIN",1); // This means this output page does not require to be logged.
  37. define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
  38. // For MultiCompany module
  39. $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
  40. if (is_int($entity))
  41. {
  42. define("DOLENTITY", $entity);
  43. }
  44. require '../../main.inc.php';
  45. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  46. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  47. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  48. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  49. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  50. // Init vars
  51. $errmsg='';
  52. $num=0;
  53. $error=0;
  54. $backtopage=GETPOST('backtopage','alpha');
  55. $action=GETPOST('action','alpha');
  56. // Load translation files
  57. $langs->load("main");
  58. $langs->load("members");
  59. $langs->load("companies");
  60. $langs->load("install");
  61. $langs->load("other");
  62. // Security check
  63. if (empty($conf->adherent->enabled)) accessforbidden('',1,1,1);
  64. if (empty($conf->global->MEMBER_ENABLE_PUBLIC))
  65. {
  66. print $langs->trans("Auto subscription form for public visitors has no been enabled");
  67. exit;
  68. }
  69. /**
  70. * Show header for new member
  71. *
  72. * @param string $title Title
  73. * @param string $head Head array
  74. * @param int $disablejs More content into html header
  75. * @param int $disablehead More content into html header
  76. * @param array $arrayofjs Array of complementary js files
  77. * @param array $arrayofcss Array of complementary css files
  78. * @return void
  79. */
  80. function llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='')
  81. {
  82. global $user, $conf, $langs, $mysoc;
  83. top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
  84. print '<body id="mainbody" class="publicnewmemberform" style="margin-top: 10px;">';
  85. // Print logo
  86. $urllogo=DOL_URL_ROOT.'/theme/login_logo.png';
  87. if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
  88. {
  89. $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=companylogo&amp;file='.urlencode('thumbs/'.$mysoc->logo_small);
  90. }
  91. elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
  92. {
  93. $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=companylogo&amp;file='.urlencode($mysoc->logo);
  94. $width=128;
  95. }
  96. elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png'))
  97. {
  98. $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png';
  99. }
  100. print '<center>';
  101. print '<img alt="Logo" id="logosubscribe" title="" src="'.$urllogo.'" />';
  102. print '</center><br>';
  103. print '<div style="margin-left: 50px; margin-right: 50px;">';
  104. }
  105. /**
  106. * Show footer for new member
  107. *
  108. * @return void
  109. */
  110. function llxFooterVierge()
  111. {
  112. print '</div>';
  113. printCommonFooter('public');
  114. print "</body>\n";
  115. print "</html>\n";
  116. }
  117. /*
  118. * Actions
  119. */
  120. // Action called when page is submited
  121. if ($action == 'add')
  122. {
  123. // test if login already exists
  124. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  125. {
  126. if(! GETPOST('login'))
  127. {
  128. $error+=1;
  129. $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Login"))."<br>\n";
  130. }
  131. $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape(GETPOST('login'))."'";
  132. $result = $db->query($sql);
  133. if ($result)
  134. {
  135. $num = $db->num_rows($result);
  136. }
  137. if ($num !=0)
  138. {
  139. $error+=1;
  140. $langs->load("errors");
  141. $errmsg .= $langs->trans("ErrorLoginAlreadyExists")."<br>\n";
  142. }
  143. if (!isset($_POST["pass1"]) || !isset($_POST["pass2"]) || $_POST["pass1"] == '' || $_POST["pass2"] == '' || $_POST["pass1"]!=$_POST["pass2"])
  144. {
  145. $error+=1;
  146. $langs->load("errors");
  147. $errmsg .= $langs->trans("ErrorPasswordsMustMatch")."<br>\n";
  148. }
  149. if (! GETPOST("email"))
  150. {
  151. $error+=1;
  152. $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("EMail"))."<br>\n";
  153. }
  154. }
  155. if (GETPOST('type') <= 0)
  156. {
  157. $error+=1;
  158. $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"))."<br>\n";
  159. }
  160. if (! in_array(GETPOST('morphy'),array('mor','phy')))
  161. {
  162. $error+=1;
  163. $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Nature'))."<br>\n";
  164. }
  165. if (empty($_POST["nom"]))
  166. {
  167. $error+=1;
  168. $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Lastname"))."<br>\n";
  169. }
  170. if (empty($_POST["prenom"]))
  171. {
  172. $error+=1;
  173. $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Firstname"))."<br>\n";
  174. }
  175. if (GETPOST("email") && ! isValidEmail(GETPOST("email")))
  176. {
  177. $error+=1;
  178. $langs->load("errors");
  179. $errmsg .= $langs->trans("ErrorBadEMail",GETPOST("email"))."<br>\n";
  180. }
  181. $birthday=dol_mktime($_POST["birthhour"],$_POST["birthmin"],$_POST["birthsec"],$_POST["birthmonth"],$_POST["birthday"],$_POST["birthyear"]);
  182. if ($_POST["birthmonth"] && empty($birthday))
  183. {
  184. $error+=1;
  185. $langs->load("errors");
  186. $errmsg .= $langs->trans("ErrorBadDateFormat")."<br>\n";
  187. }
  188. if (! empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER))
  189. {
  190. if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0)
  191. {
  192. $error+=1;
  193. $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("TurnoverOrBudget"))."<br>\n";
  194. }
  195. }
  196. if (isset($public)) $public=1;
  197. else $public=0;
  198. if (! $error)
  199. {
  200. // email a peu pres correct et le login n'existe pas
  201. $adh = new Adherent($db);
  202. $adh->statut = -1;
  203. $adh->public = $_POST["public"];
  204. $adh->prenom = $_POST["prenom"];
  205. $adh->nom = $_POST["nom"];
  206. $adh->civilite_id = $_POST["civilite_id"];
  207. $adh->societe = $_POST["societe"];
  208. $adh->address = $_POST["address"];
  209. $adh->zip = $_POST["zipcode"];
  210. $adh->town = $_POST["town"];
  211. $adh->email = $_POST["email"];
  212. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  213. {
  214. $adh->login = $_POST["login"];
  215. $adh->pass = $_POST["pass1"];
  216. }
  217. $adh->photo = $_POST["photo"];
  218. $adh->note = $_POST["note"];
  219. $adh->country_id = $_POST["country_id"];
  220. $adh->state_id = $_POST["state_id"];
  221. $adh->typeid = $_POST["type"];
  222. $adh->note = $_POST["comment"];
  223. $adh->morphy = $_POST["morphy"];
  224. $adh->naiss = $birthday;
  225. foreach($_POST as $key => $value){
  226. if (preg_match("/^options_/",$key)){
  227. $adh->array_options[$key]=$_POST[$key];
  228. }
  229. }
  230. $result=$adh->create($user->id);
  231. if ($result > 0)
  232. {
  233. require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
  234. // Send email to say it has been created and will be validated soon...
  235. if (! empty($conf->global->ADHERENT_AUTOREGISTER_MAIL) && ! empty($conf->global->ADHERENT_AUTOREGISTER_MAIL_SUBJECT))
  236. {
  237. $result=$adh->send_an_email($conf->global->ADHERENT_AUTOREGISTER_MAIL,$conf->global->ADHERENT_AUTOREGISTER_MAIL_SUBJECT,array(),array(),array(),"","",0,-1);
  238. }
  239. // Send email to the foundation to say a new member subscribed with autosubscribe form
  240. if (! empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && ! empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
  241. ! empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL) )
  242. {
  243. $to=$adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL);
  244. $from=$conf->global->ADHERENT_MAIL_FROM;
  245. $mailfile = new CMailFile(
  246. $conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT,
  247. $to,
  248. $from,
  249. $adh->makeSubstitution($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL),
  250. array(),
  251. array(),
  252. array(),
  253. "",
  254. "",
  255. 0,
  256. -1
  257. );
  258. if (! $mailfile->sendfile())
  259. {
  260. dol_syslog($langs->trans("ErrorFailedToSendMail",$from,$to), LOG_ERR);
  261. }
  262. }
  263. if (! empty($backtopage)) $urlback=$backtopage;
  264. else if (! empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION))
  265. {
  266. $urlback=$conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION;
  267. // TODO Make replacement of __AMOUNT__, etc...
  268. }
  269. else $urlback=$_SERVER["PHP_SELF"]."?action=added";
  270. if (! empty($conf->global->MEMBER_NEWFORM_PAYONLINE))
  271. {
  272. if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox')
  273. {
  274. $urlback=DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref;
  275. if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount'));
  276. if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email'));
  277. if (! empty($entity)) $urlback.='&entity='.$entity;
  278. }
  279. else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal')
  280. {
  281. $urlback=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref;
  282. if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount'));
  283. if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email'));
  284. if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE))
  285. {
  286. $urlback.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2);
  287. }
  288. if (! empty($entity)) $urlback.='&entity='.$entity;
  289. }
  290. else
  291. {
  292. dol_print_error('',"Autosubscribe form is setup to ask an online payment for a not managed online payment");
  293. exit;
  294. }
  295. }
  296. dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback);
  297. Header("Location: ".$urlback);
  298. exit;
  299. }
  300. else
  301. {
  302. $errmsg .= join('<br>',$adh->errors);
  303. }
  304. }
  305. }
  306. // Action called after a submited was send and member created succesfully
  307. // If MEMBER_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url.
  308. // backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
  309. if ($action == 'added')
  310. {
  311. llxHeaderVierge($langs->trans("NewMemberForm"));
  312. // Si on a pas ete redirige
  313. print '<br>';
  314. print '<center>';
  315. print $langs->trans("NewMemberbyWeb");
  316. print '</center>';
  317. llxFooterVierge();
  318. exit;
  319. }
  320. /*
  321. * View
  322. */
  323. $form = new Form($db);
  324. $formcompany = new FormCompany($db);
  325. $adht = new AdherentType($db);
  326. $extrafields = new ExtraFields($db);
  327. $extrafields->fetch_name_optionals_label('member'); // fetch optionals attributes and labels
  328. llxHeaderVierge($langs->trans("NewSubscription"));
  329. print_titre($langs->trans("NewSubscription"));
  330. if (! empty($conf->global->MEMBER_NEWFORM_TEXT)) print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."<br>\n";
  331. else print $langs->trans("NewSubscriptionDesc",$conf->global->MAIN_INFO_SOCIETE_MAIL)."<br>\n";
  332. dol_htmloutput_errors($errmsg);
  333. print '<div align="center">';
  334. print '<br>'.$langs->trans("FieldsWithAreMandatory",'*').'<br>';
  335. //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
  336. print '<script type="text/javascript">
  337. jQuery(document).ready(function () {
  338. jQuery(document).ready(function () {
  339. function initmorphy()
  340. {
  341. if (jQuery("#morphy").val()==\'phy\') {
  342. jQuery("#trcompany").hide();
  343. }
  344. if (jQuery("#morphy").val()==\'mor\') {
  345. jQuery("#trcompany").show();
  346. }
  347. };
  348. initmorphy();
  349. jQuery("#morphy").click(function() {
  350. initmorphy();
  351. });
  352. jQuery("#selectcountry_id").change(function() {
  353. document.newmember.action.value="create";
  354. document.newmember.submit();
  355. });
  356. });
  357. });
  358. </script>';
  359. // Print form
  360. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
  361. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" / >';
  362. print '<input type="hidden" name="entity" value="'.$entity.'" />';
  363. print '<input type="hidden" name="action" value="add" />';
  364. print '<div id="divsubscribe">';
  365. print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
  366. // Type
  367. if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE))
  368. {
  369. $listoftype=$adht->liste_array();
  370. $tmp=array_keys($listoftype);
  371. $defaulttype='';
  372. $isempty=1;
  373. if (count($listoftype)==1) { $defaulttype=$tmp[0]; $isempty=0; }
  374. print '<tr><td width="15%">'.$langs->trans("Type").' <FONT COLOR="red">*</FONT></td><td width="35%">';
  375. print $form->selectarray("type", $adht->liste_array(), GETPOST('type')?GETPOST('type'):$defaulttype, $isempty);
  376. print '</td></tr>'."\n";
  377. }
  378. else
  379. {
  380. $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE);
  381. //print $adht->libelle;
  382. print '<input type="hidden" id="type" name="type" value="'.$conf->global->MEMBER_NEWFORM_FORCETYPE.'">';
  383. }
  384. // Moral/Physic attribute
  385. $morphys["phy"] = $langs->trans("Physical");
  386. $morphys["mor"] = $langs->trans("Moral");
  387. if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY))
  388. {
  389. print '<tr class="morphy"><td>'.$langs->trans('Nature').' <FONT COLOR="red">*</FONT></td><td>'."\n";
  390. print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1);
  391. print '</td></tr>'."\n";
  392. }
  393. else
  394. {
  395. print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY];
  396. print '<input type="hidden" id="morphy" name="morphy" value="'.$conf->global->MEMBER_NEWFORM_FORCEMORPHY.'">';
  397. }
  398. // Civility
  399. print '<tr><td>'.$langs->trans('UserTitle').'</td><td>';
  400. print $formcompany->select_civility(GETPOST('civilite_id'),'civilite_id').'</td></tr>'."\n";
  401. // Lastname
  402. print '<tr><td>'.$langs->trans("Lastname").' <FONT COLOR="red">*</FONT></td><td><input type="text" name="nom" size="40" value="'.dol_escape_htmltag(GETPOST('nom')).'"></td></tr>'."\n";
  403. // Firstname
  404. print '<tr><td>'.$langs->trans("Firstname").' <FONT COLOR="red">*</FONT></td><td><input type="text" name="prenom" size="40" value="'.dol_escape_htmltag(GETPOST('prenom')).'"></td></tr>'."\n";
  405. // Company
  406. print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
  407. // Address
  408. print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
  409. print '<textarea name="address" id="address" wrap="soft" cols="40" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('address')).'</textarea></td></tr>'."\n";
  410. // Zip / Town
  411. print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
  412. print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town','selectcountry_id','state_id'), 6, 1);
  413. print ' / ';
  414. print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode','selectcountry_id','state_id'), 0, 1);
  415. print '</td></tr>';
  416. // Country
  417. print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>';
  418. $country_id=GETPOST('country_id');
  419. if (! $country_id && ! empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) $country_id=getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE,2,$db,$langs);
  420. if (! $country_id && ! empty($conf->geoipmaxmind->enabled))
  421. {
  422. $country_code=dol_user_country();
  423. //print $country_code;
  424. if ($country_code)
  425. {
  426. $new_country_id=getCountry($country_code,3,$db,$langs);
  427. //print 'xxx'.$country_code.' - '.$new_country_id;
  428. if ($new_country_id) $country_id=$new_country_id;
  429. }
  430. }
  431. $country_code=getCountry($country_id,2,$db,$langs);
  432. print $form->select_country($country_id,'country_id');
  433. print '</td></tr>';
  434. // State
  435. if (empty($conf->global->SOCIETE_DISABLE_STATE))
  436. {
  437. print '<tr><td>'.$langs->trans('State').'</td><td>';
  438. if ($country_code) print $formcompany->select_state(GETPOST("state_id"),$country_code);
  439. else print '';
  440. print '</td></tr>';
  441. }
  442. // EMail
  443. print '<tr><td>'.$langs->trans("Email").' <FONT COLOR="red">*</FONT></td><td><input type="text" name="email" size="40" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
  444. // Login
  445. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  446. {
  447. print '<tr><td>'.$langs->trans("Login").' <FONT COLOR="red">*</FONT></td><td><input type="text" name="login" size="20" value="'.dol_escape_htmltag(GETPOST('login')).'"></td></tr>'."\n";
  448. print '<tr><td>'.$langs->trans("Password").' <FONT COLOR="red">*</FONT></td><td><input type="password" name="pass1" size="20" value="'.GETPOST("pass1").'"></td></tr>'."\n";
  449. print '<tr><td>'.$langs->trans("PasswordAgain").' <FONT COLOR="red">*</FONT></td><td><input type="password" name="pass2" size="20" value="'.GETPOST("pass2").'"></td></tr>'."\n";
  450. }
  451. // Birthday
  452. print '<tr><td>'.$langs->trans("DateToBirth").'</td><td>';
  453. print $form->select_date($birthday,'birth',0,0,1,"newmember");
  454. print '</td></tr>'."\n";
  455. // Photo
  456. print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" size="40" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
  457. // Public
  458. print '<tr><td>'.$langs->trans("Public").'</td><td><input type="checkbox" name="public" value="1" checked></td></tr>'."\n";
  459. // Extrafields
  460. foreach($extrafields->attribute_label as $key=>$value)
  461. {
  462. print "<tr><td>".$value."</td><td>";
  463. print $extrafields->showInputField($key,GETPOST('options_'.$key));
  464. print "</td></tr>\n";
  465. }
  466. // Comments
  467. print '<tr>';
  468. print '<td valign="top">'.$langs->trans("Comments").'</td>';
  469. print '<td valign="top"><textarea name="comment" wrap="soft" cols="60" rows="'.ROWS_4.'">'.dol_escape_htmltag(GETPOST('comment')).'</textarea></td>';
  470. print '</tr>'."\n";
  471. // Add specific fields used by Dolibarr foundation for example
  472. if (! empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER))
  473. {
  474. $arraybudget=array('50'=>'<= 100 000','100'=>'<= 200 000','200'=>'<= 500 000','400'=>'<= 1 500 000','750'=>'<= 3 000 000','1500'=>'<= 5 000 000','2000'=>'5 000 000+');
  475. print '<tr id="trbudget" class="trcompany"><td>'.$langs->trans("TurnoverOrBudget").' <FONT COLOR="red">*</FONT></td><td>';
  476. print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1);
  477. print ' € or $';
  478. print '<script type="text/javascript">
  479. jQuery(document).ready(function () {
  480. initturnover();
  481. jQuery("#morphy").click(function() {
  482. initturnover();
  483. });
  484. jQuery("#budget").change(function() {
  485. if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
  486. else { jQuery("#budget").val(\'\'); }
  487. });
  488. /*jQuery("#type").change(function() {
  489. if (jQuery("#type").val()==1) { jQuery("#morphy").val(\'mor\'); }
  490. if (jQuery("#type").val()==2) { jQuery("#morphy").val(\'phy\'); }
  491. if (jQuery("#type").val()==3) { jQuery("#morphy").val(\'mor\'); }
  492. if (jQuery("#type").val()==4) { jQuery("#morphy").val(\'mor\'); }
  493. initturnover();
  494. });*/
  495. function initturnover() {
  496. if (jQuery("#morphy").val()==\'phy\') {
  497. jQuery(".amount").val(20);
  498. jQuery("#trbudget").hide();
  499. jQuery("#trcompany").hide();
  500. }
  501. if (jQuery("#morphy").val()==\'mor\') {
  502. jQuery(".amount").val(\'\');
  503. jQuery("#trbudget").show();
  504. jQuery("#trcompany").show();
  505. if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
  506. else { jQuery("#budget").val(\'\'); }
  507. }
  508. }
  509. });
  510. </script>';
  511. print '</td></tr>'."\n";
  512. }
  513. if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)
  514. || ! empty($conf->global->MEMBER_NEWFORM_PAYONLINE))
  515. {
  516. // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount
  517. $amount=0;
  518. if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
  519. $amount=$conf->global->MEMBER_NEWFORM_AMOUNT;
  520. }
  521. if (! empty($conf->global->MEMBER_NEWFORM_PAYONLINE))
  522. {
  523. $amount=GETPOST('amount')?GETPOST('amount'):$conf->global->MEMBER_NEWFORM_AMOUNT;
  524. }
  525. // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal' or 'paybox'
  526. print '<tr><td>'.$langs->trans("Subscription").'</td><td nowrap="nowrap">';
  527. if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT))
  528. {
  529. print '<input type="text" name="amount" id="amount" class="flat amount" size="6" value="'.$amount.'">';
  530. }
  531. else
  532. {
  533. print '<input type="text" name="amount" id="amounthidden" class="flat amount" disabled="disabled" size="6" value="'.$amount.'">';
  534. print '<input type="hidden" name="amount" id="amount" class="flat amount" size="6" value="'.$amount.'">';
  535. }
  536. print ' '.$langs->trans("Currency".$conf->currency);
  537. print '</td></tr>';
  538. }
  539. print "</table>\n";
  540. // Save
  541. print '<br><center>';
  542. print '<input type="submit" value="'.$langs->trans("Save").'" id="submitsave" class="button">';
  543. if (! empty($backtopage))
  544. {
  545. print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button">';
  546. }
  547. print '</center>';
  548. print "<br></div></form>\n";
  549. print '</div>';
  550. print
  551. llxFooterVierge();
  552. $db->close();
  553. ?>