From 54489e6050c3e3bd576bf502e32626e330eca222 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Sun, 29 Aug 2010 15:38:47 +0000 Subject: [PATCH] Replace javascript by jQuery --- htdocs/lib/lib_head.js | 14 -------------- htdocs/societe/soc.php | 28 ++++++++++++++++++++++------ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/htdocs/lib/lib_head.js b/htdocs/lib/lib_head.js index 2167ed9d1d3..c5e5b6b6aef 100644 --- a/htdocs/lib/lib_head.js +++ b/htdocs/lib/lib_head.js @@ -11,20 +11,6 @@ // -/*================================================================= - Purpose: Resubmit page when type of third party (company/individual) is changed - Input: param - Author: Laurent Destailleur - Licence: GPL -==================================================================*/ -function dolibarr_type_reload(param) -{ - document.formsoc.action.value='create'; - document.formsoc.private.value=param; - document.formsoc.cleartype.value=1; - document.formsoc.submit(); -} - /*================================================================= Purpose: Resubmit page when barcode choice is changed (admin page) Input: formNameID diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 4f0d20ad054..92d7fc4e48f 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -451,14 +451,30 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create') if ($conf->use_javascript_ajax) { + print "\n"; + print '<script type="text/javascript" language="javascript">'; + print 'jQuery(document).ready(function () { + jQuery("#radiocompany").click(function() { + document.formsoc.action.value="create"; + document.formsoc.private.value=0; + document.formsoc.cleartype.value=1; + document.formsoc.submit(); + }); + jQuery("#radioprivate").click(function() { + document.formsoc.action.value="create"; + document.formsoc.private.value=1; + document.formsoc.cleartype.value=1; + document.formsoc.submit(); + }); + });'; + print '</script>'."\n"; + print "<br>\n"; print $langs->trans("ThirdPartyType").': '; - print '<input type="radio" class="flat" name="private" value="0"'.(! $_REQUEST["private"]?' checked="true"':''); - print 'onclick="dolibarr_type_reload(0)"'; + print '<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.(! $_REQUEST["private"]?' checked="true"':''); print '> '.$langs->trans("Company/Fundation"); print ' '; - print '<input type="radio" class="flat" name="private" value="1"'.(! $_REQUEST["private"]?'':' checked="true"'); - print 'onclick="dolibarr_type_reload(1)"'; + print '<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.(! $_REQUEST["private"]?'':' checked="true"'); print '> '.$langs->trans("Individual"); print ' ('.$langs->trans("ToCreateContactWithSameName").')'; print "<br>\n"; @@ -1138,7 +1154,7 @@ else $head = societe_prepare_head($soc); dol_fiche_head($head, 'company', $langs->trans("ThirdParty"),0,'company'); - + $html = new Form($db); @@ -1149,7 +1165,7 @@ else $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2); if ($ret == 'html') print '<br>'; } - + // Template // TODO utiliser la classe canvas include(DOL_DOCUMENT_ROOT."/societe/canvas/default/tpl/view.tpl.php"); -- GitLab