Fix: optimize code

This commit is contained in:
Regis Houssin 2012-11-13 16:20:15 +01:00
parent 84b50f45f8
commit d9efa95e09
2 changed files with 49 additions and 66 deletions

View File

@ -51,6 +51,7 @@ class ActionComm extends CommonObject
var $datep; // Date action start (datep) var $datep; // Date action start (datep)
var $datef; // Date action end (datep2) var $datef; // Date action end (datep2)
var $dateend; // ??
var $durationp = -1; // -1=Unkown duration var $durationp = -1; // -1=Unkown duration
var $fulldayevent = 0; // 1=Event on full day var $fulldayevent = 0; // 1=Event on full day
var $punctual = 1; // Milestone var $punctual = 1; // Milestone

View File

@ -381,54 +381,45 @@ if ($action == 'create')
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript">';
print 'jQuery(document).ready(function () { print '$(document).ready(function () {
function setdatefields() function setdatefields()
{ {
if (jQuery("#fullday:checked").val() == null) if ($("#fullday:checked").val() == null) {
{ $(".fulldaystarthour").removeAttr("disabled");
jQuery(".fulldaystarthour").attr(\'disabled\', false); $(".fulldaystartmin").removeAttr("disabled");
jQuery(".fulldaystartmin").attr(\'disabled\', false); $(".fulldayendhour").removeAttr("disabled");
jQuery(".fulldayendhour").attr(\'disabled\', false); $(".fulldayendmin").removeAttr("disabled");
jQuery(".fulldayendmin").attr(\'disabled\', false); } else {
} $(".fulldaystarthour").attr("disabled","disabled").val("00");
else $(".fulldaystartmin").attr("disabled","disabled").val("00");
{ $(".fulldayendhour").attr("disabled","disabled").val("23");
jQuery(".fulldaystarthour").attr(\'disabled\', true); $(".fulldayendmin").attr("disabled","disabled").val("59");
jQuery(".fulldaystartmin").attr(\'disabled\', true); }
jQuery(".fulldayendhour").attr(\'disabled\', true); }
jQuery(".fulldayendmin").attr(\'disabled\', true);
jQuery(".fulldaystarthour").val("00");
jQuery(".fulldaystartmin").val("00");
//jQuery(".fulldayendhour").val("00");
//jQuery(".fulldayendmin").val("00");
jQuery(".fulldayendhour").val("23");
jQuery(".fulldayendmin").val("59");
}
}
setdatefields(); setdatefields();
jQuery("#fullday").change(function() { $("#fullday").change(function() {
setdatefields(); setdatefields();
}); });
jQuery("#selectcomplete").change(function() { $("#selectcomplete").change(function() {
if (jQuery("#selectcomplete").val() == 100) if ($("#selectcomplete").val() == 100)
{ {
if (jQuery("#doneby").val() <= 0) jQuery("#doneby").val(\''.$user->id.'\'); if ($("#doneby").val() <= 0) $("#doneby").val(\''.$user->id.'\');
} }
if (jQuery("#selectcomplete").val() == 0) if ($("#selectcomplete").val() == 0)
{ {
jQuery("#doneby").val(-1); $("#doneby").val(-1);
} }
}); });
jQuery("#actioncode").change(function() { $("#actioncode").change(function() {
if (jQuery("#actioncode").val() == \'AC_RDV\') jQuery("#dateend").addClass("fieldrequired"); if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
else jQuery("#dateend").removeClass("fieldrequired"); else $("#dateend").removeClass("fieldrequired");
}); });
})'; })';
print '</script>'."\n"; print '</script>'."\n";
} }
print '<form name="formaction" action="'.DOL_URL_ROOT.'/comm/action/fiche.php" method="POST">'; print '<form name="formaction" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add_action">'; print '<input type="hidden" name="action" value="add_action">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">'; if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
@ -647,43 +638,34 @@ if ($id)
if ($action == 'edit') if ($action == 'edit')
{ {
if ($conf->use_javascript_ajax) if (! empty($conf->use_javascript_ajax))
{ {
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript">';
print 'jQuery(document).ready(function () { print '$(document).ready(function () {
function setdatefields() function setdatefields()
{ {
if (jQuery("#fullday:checked").val() == null) if ($("#fullday:checked").val() == null) {
{ $(".fulldaystarthour").removeAttr("disabled");
jQuery(".fulldaystarthour").attr(\'disabled\', false); $(".fulldaystartmin").removeAttr("disabled");
jQuery(".fulldaystartmin").attr(\'disabled\', false); $(".fulldayendhour").removeAttr("disabled");
jQuery(".fulldayendhour").attr(\'disabled\', false); $(".fulldayendmin").removeAttr("disabled");
jQuery(".fulldayendmin").attr(\'disabled\', false); } else {
} $(".fulldaystarthour").attr("disabled","disabled").val("00");
else $(".fulldaystartmin").attr("disabled","disabled").val("00");
{ $(".fulldayendhour").attr("disabled","disabled").val("23");
jQuery(".fulldaystarthour").attr(\'disabled\', true); $(".fulldayendmin").attr("disabled","disabled").val("59");
jQuery(".fulldaystartmin").attr(\'disabled\', true); }
jQuery(".fulldayendhour").attr(\'disabled\', true); }
jQuery(".fulldayendmin").attr(\'disabled\', true); setdatefields();
jQuery(".fulldaystarthour").val("00"); $("#fullday").change(function() {
jQuery(".fulldaystartmin").val("00"); setdatefields();
//jQuery(".fulldayendhour").val("00"); });
//jQuery(".fulldayendmin").val("00");
jQuery(".fulldayendhour").val("23");
jQuery(".fulldayendmin").val("59");
}
}
setdatefields();
jQuery("#fullday").change(function() {
setdatefields();
});
})'; })';
print '</script>'."\n"; print '</script>'."\n";
} }
// Fiche action en mode edition // Fiche action en mode edition
print '<form name="formaction" action="'.DOL_URL_ROOT.'/comm/action/fiche.php" method="post">'; print '<form name="formaction" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';