Qual: Serious clean of code of formconfirm method. This also solve bugs
of ecm module when using ajax.
This commit is contained in:
parent
7801749874
commit
ed93e5cc7c
@ -1,6 +1,6 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@uers.sourceforge.net>
|
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@uers.sourceforge.net>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -112,9 +112,9 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg=$object->error;
|
$mesg=$object->error;
|
||||||
$action='';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$action='';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Action send emailing for everybody
|
// Action send emailing for everybody
|
||||||
@ -800,12 +800,12 @@ else
|
|||||||
array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true)
|
array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true)
|
||||||
);
|
);
|
||||||
// Paiement incomplet. On demande si motif = escompte ou autre
|
// Paiement incomplet. On demande si motif = escompte ou autre
|
||||||
$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneEMailing'),$langs->trans('ConfirmCloneEMailing',$object->ref),'confirm_clone',$formquestion,'yes');
|
$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneEMailing'),$langs->trans('ConfirmCloneEMailing',$object->ref),'confirm_clone',$formquestion,'yes',2,240);
|
||||||
print '<br>';
|
print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($mesg) print $mesg;
|
dol_htmloutput_mesg($mesg);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -952,8 +952,10 @@ else
|
|||||||
* Mailing en mode edition
|
* Mailing en mode edition
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($mesg) print $mesg."<br>";
|
$mesgs=array();
|
||||||
if ($message) print $message."<br>";
|
if ($mesg) $mesgs[]=$mesg;
|
||||||
|
if ($message) $message[]=$message;
|
||||||
|
dol_htmloutput_mesg('',$mesgs);
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
|||||||
@ -148,13 +148,14 @@ if (! dol_is_dir($upload_dir))
|
|||||||
print '<!-- TYPE='.$type.' -->'."\n";
|
print '<!-- TYPE='.$type.' -->'."\n";
|
||||||
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||||
|
|
||||||
|
$param='';
|
||||||
|
|
||||||
// Dir
|
// Dir
|
||||||
if ($type == 'directory')
|
if ($type == 'directory')
|
||||||
{
|
{
|
||||||
$formfile=new FormFile($db);
|
$formfile=new FormFile($db);
|
||||||
|
|
||||||
$param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'');
|
$param.=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'');
|
||||||
$maxlengthname=40;
|
$maxlengthname=40;
|
||||||
|
|
||||||
// Right area
|
// Right area
|
||||||
@ -242,12 +243,11 @@ if ($type == 'directory')
|
|||||||
}
|
}
|
||||||
else // Manual area
|
else // Manual area
|
||||||
{
|
{
|
||||||
|
|
||||||
$relativepath=$ecmdir->getRelativePath();
|
$relativepath=$ecmdir->getRelativePath();
|
||||||
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
||||||
$filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','\.meta$','^temp$','^CVS$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
|
$filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','\.meta$','^temp$','^CVS$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
|
||||||
|
|
||||||
$param.='§ion='.$section;
|
if ($section) $param.='§ion='.$section;
|
||||||
$textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")));
|
$textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")));
|
||||||
|
|
||||||
$formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
|
$formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
|
||||||
@ -255,14 +255,24 @@ if ($type == 'directory')
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((! isset($mode) || $mode != 'noajax') && empty($conf->global->MAIN_ECM_DISABLE_JS))
|
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
|
||||||
{
|
{
|
||||||
// Enable jquery handlers on new generated HTML objects
|
if ($section)
|
||||||
print "\n".'<script type="text/javascript">'."\n";
|
{
|
||||||
print 'jQuery(".deletefilelink").click(function(e) { jQuery("#dialog-confirm-deletefile").dialog("open"); return false; });'."\n";
|
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php');
|
||||||
print '</script>'."\n";
|
$form = new Form($db);
|
||||||
|
$formquestion=array('urlfile'=>array('type'=>'hidden','value'=>'','name'=>'urlfile'));
|
||||||
|
print $form->formconfirm(DOL_URL_ROOT.'/ecm/index.php'.($param?'?':'').(preg_replace('/^&/','',$param)),$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",'deletefile');
|
||||||
|
|
||||||
if (is_object($db)) $db->close();
|
// Enable jquery handlers on new generated HTML objects
|
||||||
|
print '<script type="text/javascript">'."\n";
|
||||||
|
print 'jQuery(document).ready(function() {'."\n";
|
||||||
|
print 'jQuery(".deletefilelink").click(function(e) { jQuery("#urlfile").val(jQuery(this).attr("rel")); jQuery("#dialog-confirm-deletefile").dialog("open"); return false; });'."\n";
|
||||||
|
print '});'."\n";
|
||||||
|
print '</script>'."\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close db if mode is not noajax
|
||||||
|
if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -2146,7 +2146,8 @@ class Form
|
|||||||
|
|
||||||
$more='';
|
$more='';
|
||||||
$formconfirm='';
|
$formconfirm='';
|
||||||
$inputarray=array();
|
$inputok=array();
|
||||||
|
$inputko=array();
|
||||||
|
|
||||||
if (is_array($formquestion) && count($formquestion) > 0)
|
if (is_array($formquestion) && count($formquestion) > 0)
|
||||||
{
|
{
|
||||||
@ -2207,13 +2208,16 @@ class Form
|
|||||||
$more.=$input['value'];
|
$more.=$input['value'];
|
||||||
$more.='</td></tr>'."\n";
|
$more.='</td></tr>'."\n";
|
||||||
}
|
}
|
||||||
if ($input['type'] != 'hidden') array_push($inputarray,$input['name']);
|
else if ($input['type'] == 'hidden')
|
||||||
|
{
|
||||||
|
$more.='<input type="hidden" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$input['value'].'">';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$more.='</table>'."\n";
|
$more.='</table>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$formconfirm.= "\n<!-- begin form_confirm -->\n";
|
$formconfirm.= "\n<!-- begin form_confirm page=".$page." -->\n";
|
||||||
|
|
||||||
if ($useajax && $conf->use_javascript_ajax)
|
if ($useajax && $conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
@ -2228,16 +2232,13 @@ class Form
|
|||||||
}
|
}
|
||||||
$pageyes=$page.'&action='.$action.'&confirm=yes';
|
$pageyes=$page.'&action='.$action.'&confirm=yes';
|
||||||
$pageno=($useajax == 2?$page.'&confirm=no':'');
|
$pageno=($useajax == 2?$page.'&confirm=no':'');
|
||||||
// Add hidden fields
|
// Add input fields into list of fields to read during submit (inputok and inputko)
|
||||||
if (is_array($formquestion))
|
if (is_array($formquestion))
|
||||||
{
|
{
|
||||||
foreach ($formquestion as $key => $input)
|
foreach ($formquestion as $key => $input)
|
||||||
{
|
{
|
||||||
if ($input['type'] == 'hidden')
|
array_push($inputok,$input['name']);
|
||||||
{
|
if ($input['inputko'] == 1) array_push($inputko,$input['name']);
|
||||||
$pageyes.='&'.$input['name'].'='.urlencode($input['value']);
|
|
||||||
$pageno.=($useajax == 2?$page.'&'.$input['name'].'='.urlencode($input['value']):'');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2247,13 +2248,15 @@ class Form
|
|||||||
$formconfirm.= img_help('','').' '.$question;
|
$formconfirm.= img_help('','').' '.$question;
|
||||||
$formconfirm.= '</div>'."\n";
|
$formconfirm.= '</div>'."\n";
|
||||||
$formconfirm.= '<script type="text/javascript">
|
$formconfirm.= '<script type="text/javascript">
|
||||||
$(function() {
|
var choice=\'ko\';
|
||||||
var choice=\'ko\';
|
var inputok='.json_encode($inputok).';
|
||||||
var $inputarray='.json_encode($inputarray).';
|
var inputko='.json_encode($inputko).';
|
||||||
var button=\''.$button.'\';
|
var pageyes=\''.($pageyes?$pageyes:'').'\';
|
||||||
var dialogconfirm=\''.$dialogconfirm.'\';
|
var pageno=\''.($pageno?$pageno:'').'\';
|
||||||
|
|
||||||
$( "#" + dialogconfirm ).dialog({
|
/* Warning: This function is loaded once and not overwritten if loaded by another ajax page */
|
||||||
|
$(function() {
|
||||||
|
$( "#'.$dialogconfirm.'" ).dialog({
|
||||||
autoOpen: '.($autoOpen?'true':'false').',
|
autoOpen: '.($autoOpen?'true':'false').',
|
||||||
resizable: false,
|
resizable: false,
|
||||||
height:'.$height.',
|
height:'.$height.',
|
||||||
@ -2261,23 +2264,37 @@ class Form
|
|||||||
modal: true,
|
modal: true,
|
||||||
closeOnEscape: false,
|
closeOnEscape: false,
|
||||||
close: function(event, ui) {
|
close: function(event, ui) {
|
||||||
if (choice == \'ok\') {
|
if (choice == \'ok\') {
|
||||||
var options="";
|
var options="";
|
||||||
if ($inputarray.length>0) {
|
if (inputok.length>0) {
|
||||||
$.each($inputarray, function() {
|
$.each(inputok, function() {
|
||||||
var inputname = this;
|
var inputname = this; var more = \'\';
|
||||||
var more = \'\';
|
|
||||||
if ($("#" + this).attr("type") == \'checkbox\') { more = \':checked\'; }
|
if ($("#" + this).attr("type") == \'checkbox\') { more = \':checked\'; }
|
||||||
var inputvalue = $("#" + this + more).val();
|
var inputvalue = $("#" + this + more).val();
|
||||||
if (typeof inputvalue == \'undefined\') { inputvalue=\'\'; }
|
if (typeof inputvalue == \'undefined\') { inputvalue=\'\'; }
|
||||||
options += \'&\' + inputname + \'=\' + inputvalue;
|
options += \'&\' + inputname + \'=\' + inputvalue;
|
||||||
});
|
});
|
||||||
//alert(options);
|
|
||||||
}
|
}
|
||||||
location.href=\''.$pageyes.'\' + options;
|
var urljump=pageyes + (pageyes.indexOf(\'?\')<0?\'?\':\'\') + options;
|
||||||
}
|
//alert(urljump);
|
||||||
'.($pageno?'if (choice == \'ko\') location.href=\''.$pageno.'\';':'').'
|
if (pageyes.length > 0) { location.href=urljump; }
|
||||||
},
|
}
|
||||||
|
if (choice == \'ko\') {
|
||||||
|
var options="";
|
||||||
|
if (inputko.length>0) {
|
||||||
|
$.each(inputko, function() {
|
||||||
|
var inputname = this; var more = \'\';
|
||||||
|
if ($("#" + this).attr("type") == \'checkbox\') { more = \':checked\'; }
|
||||||
|
var inputvalue = $("#" + this + more).val();
|
||||||
|
if (typeof inputvalue == \'undefined\') { inputvalue=\'\'; }
|
||||||
|
options += \'&\' + inputname + \'=\' + inputvalue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var urljump=pageno + (pageno.indexOf(\'?\')<0?\'?\':\'\') + options;
|
||||||
|
//alert(urljump);
|
||||||
|
if (pageno.length > 0) { location.href=urljump; }
|
||||||
|
}
|
||||||
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
\''.dol_escape_js($langs->transnoentities("Yes")).'\': function() {
|
\''.dol_escape_js($langs->transnoentities("Yes")).'\': function() {
|
||||||
choice=\'ok\';
|
choice=\'ok\';
|
||||||
@ -2289,12 +2306,6 @@ class Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (button.length > 0) {
|
|
||||||
$( "#" + button ).click(function() {
|
|
||||||
$("#" + dialogconfirm ).dialog(\'open\');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
|
||||||
@ -2331,15 +2342,6 @@ class Form
|
|||||||
|
|
||||||
$formconfirm.= '</table>'."\n";
|
$formconfirm.= '</table>'."\n";
|
||||||
|
|
||||||
// Add hidden fields
|
|
||||||
if (is_array($formquestion))
|
|
||||||
{
|
|
||||||
foreach ($formquestion as $key => $input)
|
|
||||||
{
|
|
||||||
if ($input['type'] == 'hidden') $formconfirm.= '<input type="hidden" name="'.$input['name'].'" value="'.$input['value'].'">';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$formconfirm.= "</form>\n";
|
$formconfirm.= "</form>\n";
|
||||||
$formconfirm.= '<br>';
|
$formconfirm.= '<br>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -608,7 +608,7 @@ class FormFile
|
|||||||
// Delete or view link
|
// Delete or view link
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
if ($useinecm) print '<a href="'.DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($file['name']).$param.'" class="editfilelink" rel="'.urlencode($file['name']).'">'.img_view().'</a> ';
|
if ($useinecm) print '<a href="'.DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($file['name']).$param.'" class="editfilelink" rel="'.urlencode($file['name']).'">'.img_view().'</a> ';
|
||||||
if ($permtodelete) print '<a href="'.(($useinecm && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':$url.'?id='.$object->id.'&action=delete&urlfile='.urlencode($file['name']).$param).'" class="deletefilelink" rel="'.urlencode($file['name']).'">'.img_delete().'</a>';
|
if ($permtodelete) print '<a href="'.(($useinecm && !empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':$url.'?id='.$object->id.'&action=delete&urlfile='.urlencode($file['name']).$param).'" class="deletefilelink" rel="'.urlencode($file['name']).'">'.img_delete().'</a>';
|
||||||
else print ' ';
|
else print ' ';
|
||||||
print "</td>";
|
print "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user