FIX A form should not be inside a table. Create javascript troubles.

This commit is contained in:
Laurent Destailleur 2016-11-26 12:21:50 +01:00
parent 16ce156631
commit a8c3ce4e55
7 changed files with 91 additions and 170 deletions

View File

@ -238,14 +238,22 @@ if ($object->fetch($id) >= 0)
{ {
print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"),1):''), 'title_generic'); print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"),1):''), 'title_generic');
print '<table class="noborder" width="100%">'; //print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<div class="tagtable centpercent liste_titre_bydiv" id="tablelines">';
print '<td class="liste_titre">'.$langs->trans("RecipientSelectionModules").'</td>';
print '<td class="liste_titre" align="center">'.$langs->trans("NbOfUniqueEMails").'</td>'; //print '<tr class="liste_titre">';
print '<td class="liste_titre" align="left">'.$langs->trans("Filter").'</td>'; print '<div class="tagtr liste_titre">';
print '<td class="liste_titre" align="center">&nbsp;</td>'; //print '<td class="liste_titre">'.$langs->trans("RecipientSelectionModules").'</td>';
print "</tr>\n"; print '<div class="tagtd">'.$langs->trans("RecipientSelectionModules").'</div>';
//print '<td class="liste_titre" align="center">'.$langs->trans("NbOfUniqueEMails").'</td>';
print '<div class="tagtd" align="center">'.$langs->trans("NbOfUniqueEMails").'</div>';
//print '<td class="liste_titre" align="left">'.$langs->trans("Filter").'</td>';
print '<div class="tagtd" align="left">'.$langs->trans("Filter").'</div>';
//print '<td class="liste_titre" align="center">&nbsp;</td>';
print '<div class="tagtd">&nbsp;</div>';
//print "</tr>\n";
print '</div>';
clearstatcache(); clearstatcache();
$var=true; $var=true;
@ -303,19 +311,28 @@ if ($object->fetch($id) >= 0)
if ($qualified) if ($qualified)
{ {
$var = !$var; $var = !$var;
print '<tr '.$bc[$var].'>'; //print '<tr '.$bc[$var].'>';
// print '<div '.$bctag[$var].'>';
if ($allowaddtarget) if ($allowaddtarget)
{ {
print '<form name="'.$modulename.'" action="'.$_SERVER['PHP_SELF'].'?action=add&id='.$object->id.'&module='.$modulename.'" method="POST" enctype="multipart/form-data">'; print '<form '.$bctag[$var].' name="'.$modulename.'" action="'.$_SERVER['PHP_SELF'].'?action=add&id='.$object->id.'&module='.$modulename.'" method="POST" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
} }
else
{
print '<div '.$bctag[$var].'>';
}
print '<td>'; //print '<td>';
print '<div class="tagtd">';
if (empty($obj->picto)) $obj->picto='generic'; if (empty($obj->picto)) $obj->picto='generic';
print img_object($langs->trans("Module").': '.get_class($obj),$obj->picto).' '.$obj->getDesc(); print img_object($langs->trans("Module").': '.get_class($obj),$obj->picto);
print '</td>'; print ' ';
print $obj->getDesc();
//print '</td>';
print '</div>';
try { try {
$nbofrecipient=$obj->getNbOfRecipients(''); $nbofrecipient=$obj->getNbOfRecipients('');
} }
@ -324,7 +341,8 @@ if ($object->fetch($id) >= 0)
dol_syslog($e->getMessage(), LOG_ERR); dol_syslog($e->getMessage(), LOG_ERR);
} }
print '<td align="center">'; //print '<td align="center">';
print '<div class="tagtd center">';
if ($nbofrecipient >= 0) if ($nbofrecipient >= 0)
{ {
print $nbofrecipient; print $nbofrecipient;
@ -333,41 +351,54 @@ if ($object->fetch($id) >= 0)
{ {
print $langs->trans("Error").' '.img_error($obj->error); print $langs->trans("Error").' '.img_error($obj->error);
} }
print '</td>'; //print '</td>';
print '</div>';
print '<td align="left">';
try { //print '<td align="left">';
$filter=$obj->formFilter(); print '<div class="tagtd" align="left">';
}
catch(Exception $e)
{
dol_syslog($e->getMessage(), LOG_ERR);
}
if ($filter) print $filter;
else print $langs->trans("None");
print '</td>';
print '<td align="right">';
if ($allowaddtarget) if ($allowaddtarget)
{ {
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; try {
$filter=$obj->formFilter();
}
catch(Exception $e)
{
dol_syslog($e->getMessage(), LOG_ERR);
}
if ($filter) print $filter;
else print $langs->trans("None");
}
//print '</td>';
print '</div>';
//print '<td align="right">';
print '<div class="tagtd" align="right">';
if ($allowaddtarget)
{
print '<input type="submit" class="button" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
} }
else else
{ {
print '<input type="submit" class="button disabled" disabled="disabled" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
//print $langs->trans("MailNoChangePossible"); //print $langs->trans("MailNoChangePossible");
print "&nbsp;"; print "&nbsp;";
} }
print '</td>'; //print '</td>';
print '</div>';
if ($allowaddtarget) print '</form>'; if ($allowaddtarget) print '</form>';
else print '</div>';
print "</tr>\n";
//print "</tr>\n";
// print '</div>'."\n";
} }
} }
} // End foreach dir } // End foreach dir
print '</table>'; //print '</table>';
print '<br>'; print '</div>';
print '<br><br>';
} }
// List of selected targets // List of selected targets

View File

@ -33,7 +33,8 @@ class MailingTargets // This can't be abstract as it is used for some method
{ {
var $db; var $db;
var $error; var $error;
var $tooltip='';
/** /**
* Constructor * Constructor
@ -52,11 +53,16 @@ class MailingTargets // This can't be abstract as it is used for some method
*/ */
function getDesc() function getDesc()
{ {
global $langs; global $langs, $form;
$langs->load("mails"); $langs->load("mails");
$transstring="MailingModuleDesc".$this->name; $transstring="MailingModuleDesc".$this->name;
if ($langs->trans($transstring) != $transstring) return $langs->trans($transstring); $s='';
else return $this->desc; if ($langs->trans($transstring) != $transstring) $s=$langs->trans($transstring);
else $s=$this->desc;
if ($this->tooltip && is_object($form)) $s .= ' '.$form->textwithpicto('', $langs->trans($this->tooltip), 1, 1);
return $s;
} }
/** /**

View File

@ -31,12 +31,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
class mailing_xinputfile extends MailingTargets class mailing_xinputfile extends MailingTargets
{ {
var $name='EmailsFromFile'; // Identifiant du module mailing var $name='EmailsFromFile'; // Identifiant du module mailing
var $desc='EMails issus d\'un fichier'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv<75>e var $desc='EMails from a file'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv<75>e
var $require_module=array(); // Module mailing actif si modules require_module actifs var $require_module=array(); // Module mailing actif si modules require_module actifs
var $require_admin=0; // Module mailing actif pour user admin ou non var $require_admin=0; // Module mailing actif pour user admin ou non
var $picto='generic'; var $picto='generic';
var $tooltip='UseFormatFileEmailToTarget';
var $db;
/** /**

View File

@ -35,9 +35,8 @@ class mailing_xinputuser extends MailingTargets
var $require_module=array(); // Module mailing actif si modules require_module actifs var $require_module=array(); // Module mailing actif si modules require_module actifs
var $require_admin=0; // Module mailing actif pour user admin ou non var $require_admin=0; // Module mailing actif pour user admin ou non
var $picto='generic'; var $picto='generic';
var $tooltip='UseFormatInputEmailToTarget';
var $db;
/** /**
* Constructor * Constructor
@ -104,7 +103,7 @@ class mailing_xinputuser extends MailingTargets
global $langs; global $langs;
$s=''; $s='';
$s.='<input type="text" name="xinputuser" class="flat" size="40" value="'.GETPOST("xinputuser").'">'; $s.='<input type="text" name="xinputuser" class="flat minwidth300" value="'.GETPOST("xinputuser").'">';
return $s; return $s;
} }

View File

@ -118,6 +118,8 @@ MailSendSetupIs2=You must first go, with an admin account, into menu %sHome - Se
MailSendSetupIs3=If you have any questions on how to setup your SMTP server, you can ask to %s. MailSendSetupIs3=If you have any questions on how to setup your SMTP server, you can ask to %s.
YouCanAlsoUseSupervisorKeyword=You can also add the keyword <strong>__SUPERVISOREMAIL__</strong> to have email being sent to the supervisor of user (works only if an email is defined for this supervisor) YouCanAlsoUseSupervisorKeyword=You can also add the keyword <strong>__SUPERVISOREMAIL__</strong> to have email being sent to the supervisor of user (works only if an email is defined for this supervisor)
NbOfTargetedContacts=Current number of targeted contact emails NbOfTargetedContacts=Current number of targeted contact emails
UseFormatFileEmailToTarget=Imported file must have format <strong>email;name;firstname;other</strong>
UseFormatInputEmailToTarget=Enter a string with format <strong>email;name;firstname;other</strong>
MailAdvTargetRecipients=Recipients (advanced selection) MailAdvTargetRecipients=Recipients (advanced selection)
AdvTgtTitle=Fill input fields to preselect the thirdparties or contacts/addresses to target AdvTgtTitle=Fill input fields to preselect the thirdparties or contacts/addresses to target
AdvTgtSearchTextHelp=Use %% as magic caracters. For exemple to find all item like <b>jean, joe, jim</b>, you can input <b>j%%</b>, you can also use ; as separator for value, and use ! for except this value. For exemple <b>jean;joe;jim%%;!jimo;!jima%</b> will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima AdvTgtSearchTextHelp=Use %% as magic caracters. For exemple to find all item like <b>jean, joe, jim</b>, you can input <b>j%%</b>, you can also use ; as separator for value, and use ! for except this value. For exemple <b>jean;joe;jim%%;!jimo;!jima%</b> will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima

View File

@ -849,6 +849,7 @@ if (! defined('NOREQUIRETRAN'))
$bc=array(0=>'class="impair"',1=>'class="pair"'); $bc=array(0=>'class="impair"',1=>'class="pair"');
$bcdd=array(0=>'class="impair drag drop"',1=>'class="pair drag drop"'); $bcdd=array(0=>'class="impair drag drop"',1=>'class="pair drag drop"');
$bcnd=array(0=>'class="impair nodrag nodrop nohover"',1=>'class="pair nodrag nodrop nohoverpair"'); // Used for tr to add new lines $bcnd=array(0=>'class="impair nodrag nodrop nohover"',1=>'class="pair nodrag nodrop nohoverpair"'); // Used for tr to add new lines
$bctag=array(0=>'class="impair tagtr"',1=>'class="pair tagtr"');
// Define messages variables // Define messages variables
$mesg=''; $warning=''; $error=0; $mesg=''; $warning=''; $error=0;

View File

@ -242,8 +242,8 @@ if (! empty($moreforfilter))
<br> <br>
<!--
<br><hr><br>Example 2 : Table using tags: table/thead/tbody/tr/th-td + dataTable => Use this for short result tables<br> <br><hr><br>Example 1b : Table using tags: table/thead/tbody/tr/th-td + dataTable => Use this for short result tables<br>
@ -278,9 +278,6 @@ $(document).ready(function(){
} }
}, },
"aaSorting": [[0,'desc']], "aaSorting": [[0,'desc']],
/* To use in ajax mode /* To use in ajax mode
"bProcessing": true, "bProcessing": true,
"stateSave": true, "stateSave": true,
@ -292,126 +289,12 @@ $(document).ready(function(){
*/ */
}) })
}); });
/*
// counts total number of td in a head so that we can use it for label extraction
var head_col_count = $('xxxthead td').size();
// loop which replaces td
for ( i=0; i <= head_col_count; i++ ) {
// head column label extraction
var head_col_label = $('xxxthead td:nth-child('+ i +')').text();
// replaces td with <div class="column" data-label="label">
$('xxxtr td:nth-child('+ i +')').replaceWith(
function(){
return $('<div class="column" data-label="'+ head_col_label +'">').append($(this).contents());
}
);
}
// replaces table with <div class="table">
$('xxxtable').replaceWith(
function(){
return $('<div class="table">').append($(this).contents());
}
);
// replaces thead with <div class="table-head">
$('xxxthead').replaceWith(
function(){
return $('<div class="table-head">').append($(this).contents());
}
);
// replaces tr with <div class="row">
$('xxxtr').replaceWith(
function(){
return $('<div class="row">').append($(this).contents());
}
);
// replaces th with <div class="column">
$('xxxth').replaceWith(
function(){
return $('<div class="column">').append($(this).contents());
}
);
*/
</script> </script>
<table id="idtableexample2" class="centpercent"> -->
<thead>
<tr class="liste_titre">
<th>Column A</th>
<th><label><input type="checkbox" name="hidedetails" value="2"> A checkbox inside a title of Column B</label></th>
<?php
print getTitleFieldOfList($langs->trans('Column C'),1,$_SERVER["PHP_SELF"],'','','','align="center" class="tagtd"',$sortfield,$sortorder);
?>
</tr>
</thead>
<tbody>
<tr>
<td>line1</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line2</td>
<td>dfsdf</td>
<td align="center" class="nowrap"> xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx </td>
</tr>
<tr>
<td>line3</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line4</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line5</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line6</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line7</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line8</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line9</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line10</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line11</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line12</td>
<td>dfsdf</td>
<td align="center"> xxx </td>
</tr>
</tbody>
</table>
<br>
<br><hr><br>Example 3 : Table using tags: div.tagtable+div.tagtr+div or div.tagtable+div.tagtr+div.tagtd => Use this for tables that need to have a different form for each line, but AVOID IT if possible (drag and drop of lines does not work for this case, also height of title can't be forced to a minimum)<br><br> <br><hr><br>Example 2 : Table using tags: div.tagtable+(div|form).tagtr+div[.tagtd] => Use this for tables that need to have a different form for each line, but AVOID IT if possible (drag and drop of lines does not work for this case, also height of title can't be forced to a minimum)<br><br>
<?php <?php
@ -419,7 +302,7 @@ $('xxxth').replaceWith(
$tagidfortablednd='tablelines'; $tagidfortablednd='tablelines';
if (! empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; if (! empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
?> ?>
<div class="tagtable centpercent" id="tablelines"> <div class="tagtable centpercent liste_titre_bydiv" id="tablelines">
<div class="tagtr liste_titre"> <div class="tagtr liste_titre">
<div class="tagtd">Title A<input type="hidden" name="cartitem" value="3"></div> <div class="tagtd">Title A<input type="hidden" name="cartitem" value="3"></div>
<div class="tagtd">title B</div> <div class="tagtd">title B</div>