Skip to content
Snippets Groups Projects
Commit d9efa95e authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: optimize code

parent 84b50f45
Branches
No related tags found
No related merge requests found
...@@ -51,6 +51,7 @@ class ActionComm extends CommonObject ...@@ -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
......
...@@ -381,54 +381,45 @@ if ($action == 'create') ...@@ -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,35 +638,26 @@ if ($id) ...@@ -647,35 +638,26 @@ 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);
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();
}); });
})'; })';
...@@ -683,7 +665,7 @@ if ($id) ...@@ -683,7 +665,7 @@ if ($id)
} }
// 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.'">';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment