Merge branch 'develop' of git://github.com/Dolibarr/dolibarr into develop

This commit is contained in:
Philippe Grand 2012-08-20 11:07:28 +02:00
commit 158019f161
3 changed files with 58 additions and 48 deletions

View File

@ -92,14 +92,14 @@ if ($action == 'add_action')
exit; exit;
} }
$fulldayevent=$_POST["fullday"]; $fulldayevent=GETPOST('fullday');
// Clean parameters // Clean parameters
$datep=dol_mktime($fulldayevent?'00':$_POST["aphour"], $fulldayevent?'00':$_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datep=dol_mktime($fulldayevent?'00':$_POST["aphour"], $fulldayevent?'00':$_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
$datef=dol_mktime($fulldayevent?'23':$_POST["p2hour"], $fulldayevent?'59':$_POST["p2min"], $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); $datef=dol_mktime($fulldayevent?'23':$_POST["p2hour"], $fulldayevent?'59':$_POST["p2min"], $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
// Check parameters // Check parameters
if (! $datef && $_POST["percentage"] == 100) if (! $datef && GETPOST('percentage') == 100)
{ {
$error++; $error++;
$action = 'create'; $action = 'create';
@ -107,7 +107,7 @@ if ($action == 'add_action')
} }
// Initialisation objet cactioncomm // Initialisation objet cactioncomm
if (! $_POST["actioncode"]) if (! GETPOST('actioncode'))
{ {
$error++; $error++;
$action = 'create'; $action = 'create';
@ -115,14 +115,14 @@ if ($action == 'add_action')
} }
else else
{ {
$result=$cactioncomm->fetch($_POST["actioncode"]); $result=$cactioncomm->fetch(GETPOST('actioncode'));
} }
// Initialisation objet actioncomm // Initialisation objet actioncomm
$actioncomm->type_id = $cactioncomm->id; $actioncomm->type_id = $cactioncomm->id;
$actioncomm->type_code = $cactioncomm->code; $actioncomm->type_code = $cactioncomm->code;
$actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0; $actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0;
$actioncomm->fulldayevent = $_POST["fullday"]?1:0; $actioncomm->fulldayevent = (! empty($fulldayevent)?1:0);
$actioncomm->location = isset($_POST["location"])?$_POST["location"]:''; $actioncomm->location = isset($_POST["location"])?$_POST["location"]:'';
$actioncomm->label = trim($_POST["label"]); $actioncomm->label = trim($_POST["label"]);
if (! $_POST["label"]) if (! $_POST["label"])
@ -144,7 +144,7 @@ if ($action == 'add_action')
$actioncomm->datep = $datep; $actioncomm->datep = $datep;
$actioncomm->datef = $datef; $actioncomm->datef = $datef;
$actioncomm->percentage = isset($_POST["percentage"])?$_POST["percentage"]:0; $actioncomm->percentage = isset($_POST["percentage"])?$_POST["percentage"]:0;
$actioncomm->duree=(($_POST["dureehour"] * 60) + $_POST["dureemin"]) * 60; $actioncomm->duree=((GETPOST('dureehour') * 60) + GETPOST('dureemin')) * 60;
$usertodo=new User($db); $usertodo=new User($db);
if ($_POST["affectedto"] > 0) if ($_POST["affectedto"] > 0)
@ -169,8 +169,9 @@ if ($action == 'add_action')
} }
// Special for module webcal and phenix // Special for module webcal and phenix
if ($_POST["add_webcal"] == 'on' && $conf->webcalendar->enabled) $actioncomm->use_webcal=1; // FIXME external modules
if ($_POST["add_phenix"] == 'on' && $conf->phenix->enabled) $actioncomm->use_phenix=1; if (! empty($conf->webcalendar->enabled) && GETPOST('add_webcal') == 'on') $actioncomm->use_webcal=1;
if (! empty($conf->phenix->enabled) && GETPOST('add_phenix') == 'on') $actioncomm->use_phenix=1;
// Check parameters // Check parameters
if ($actioncomm->type_code == 'AC_RDV' && ($datep == '' || $datef == '')) if ($actioncomm->type_code == 'AC_RDV' && ($datep == '' || $datef == ''))
@ -179,14 +180,14 @@ if ($action == 'add_action')
$action = 'create'; $action = 'create';
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")).'</div>';
} }
if ($datea && $_POST["percentage"] == 0) if (! empty($datea) && GETPOST('percentage') == 0)
{ {
$error++; $error++;
$action = 'create'; $action = 'create';
$mesg='<div class="error">'.$langs->trans("ErrorStatusCantBeZeroIfStarted").'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorStatusCantBeZeroIfStarted").'</div>';
} }
if (! $_POST["apyear"] && ! $_POST["adyear"]) if (! GETPOST('apyear') && ! GETPOST('adyear'))
{ {
$error++; $error++;
$action = 'create'; $action = 'create';
@ -269,23 +270,27 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes')
*/ */
if ($action == 'update') if ($action == 'update')
{ {
if (! $_POST["cancel"]) if (empty($cancel))
{ {
$fulldayevent=$_POST["fullday"]; $fulldayevent=GETPOST('fullday');
$aphour=GETPOST('aphour');
$apmin=GETPOST('apmin');
$p2hour=GETPOST('p2hour');
$p2min=GETPOST('p2min');
// Clean parameters // Clean parameters
if ($_POST["aphour"] == -1) $_POST["aphour"]='0'; if ($aphour == -1) $aphour='0';
if ($_POST["apmin"] == -1) $_POST["apmin"]='0'; if ($apmin == -1) $apmin='0';
if ($_POST["p2hour"] == -1) $_POST["p2hour"]='0'; if ($p2hour == -1) $p2hour='0';
if ($_POST["p2min"] == -1) $_POST["p2min"]='0'; if ($p2min == -1) $p2min='0';
//if ($_POST["adhour"] == -1) $_POST["adhour"]='0'; //if ($_POST["adhour"] == -1) $_POST["adhour"]='0';
//if ($_POST["admin"] == -1) $_POST["admin"]='0'; //if ($_POST["admin"] == -1) $_POST["admin"]='0';
$actioncomm = new Actioncomm($db); $actioncomm = new Actioncomm($db);
$actioncomm->fetch($id); $actioncomm->fetch($id);
$datep=dol_mktime($fulldayevent?'00':$_POST["aphour"], $fulldayevent?'00':$_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
$datef=dol_mktime($fulldayevent?'23':$_POST["p2hour"], $fulldayevent?'59':$_POST["p2min"], $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
$actioncomm->label = $_POST["label"]; $actioncomm->label = $_POST["label"];
$actioncomm->datep = $datep; $actioncomm->datep = $datep;
@ -478,14 +483,14 @@ if ($action == 'create')
print '<tr><td width="10%">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td>'; print '<tr><td width="10%">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td>';
print '<td>'; print '<td>';
$percent=-1; $percent=-1;
if (isset($_GET['percentage']) || isset($_POST['percentage'])) if (GETPOST('percentage'))
{ {
$percent=GETPOST('percentage'); $percent=GETPOST('percentage');
} }
else else
{ {
if (GETPOST("afaire") == 1) $percent=0; if (GETPOST("afaire") == 1) $percent=0;
if (GETPOST("afaire") == 2) $percent=100; else if (GETPOST("afaire") == 2) $percent=100;
} }
print $htmlactions->form_select_status_action('formaction',$percent,1,'complete'); print $htmlactions->form_select_status_action('formaction',$percent,1,'complete');
print '</td></tr>'; print '</td></tr>';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (c) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (c) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2010-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -65,54 +65,59 @@ class FormActions
'100' => $langs->trans("ActionDoneShort") '100' => $langs->trans("ActionDoneShort")
); );
if ($conf->use_javascript_ajax) if (! empty($conf->use_javascript_ajax))
{ {
print "\n"; print "\n";
print "<script type=\"text/javascript\"> print "<script type=\"text/javascript\">
var htmlname = '".$htmlname."'; var htmlname = '".$htmlname."';
jQuery(document).ready(function () { $(document).ready(function () {
jQuery('#select'+htmlname).change(function() { select_status();
$('#select' + htmlname).change(function() {
select_status(); select_status();
}); });
jQuery('#val'+htmlname).change(function() { // FIXME use another method for update combobox
select_status(); //$('#val' + htmlname).change(function() {
}); //select_status();
//});
select_status();
}); });
function select_status() { function select_status() {
mypercentage = jQuery('#val'+htmlname).val(); var defaultvalue = $('#select' + htmlname).val();
jQuery('input[name=percentageshown]').val((mypercentage>=0?mypercentage:'')); var percentage = $('input[name=percentage]');
jQuery('input[name=percentage]').val(mypercentage); var selected = '".(isset($selected)?$selected:'')."';
if (mypercentage == -1) { var value = (selected>0?selected:(defaultvalue>=0?defaultvalue:''));
jQuery('input[name=percentageshown]').attr('disabled', 'disabled');
jQuery('.hideifna').hide(); percentage.val(value);
if (defaultvalue == -1) {
percentage.attr('disabled', 'disabled');
$('.hideifna').hide();
} }
else if (mypercentage == 0) { else if (defaultvalue == 0) {
jQuery('input[name=percentageshown]').attr('disabled', 'disabled'); percentage.attr('disabled', 'disabled');
jQuery('.hideifna').show(); $('.hideifna').show();
} }
else if (mypercentage == 100) { else if (defaultvalue == 100) {
jQuery('input[name=percentageshown]').attr('disabled', 'disabled'); percentage.attr('disabled', 'disabled');
jQuery('.hideifna').show(); $('.hideifna').show();
} }
else { else {
jQuery('input[name=percentageshown]').removeAttr('disabled'); percentage.removeAttr('disabled');
$('.hideifna').show();
} }
} }
</script>\n"; </script>\n";
print '<select '.($canedit?'':'disabled="disabled" ').'name="status" id="select'.$htmlname.'" class="flat">'; print '<select '.($canedit?'':'disabled="disabled" ').'name="status" id="select'.$htmlname.'" class="flat">';
foreach($listofstatus as $key => $val) foreach($listofstatus as $key => $val)
{ {
print '<option value="'.$key.'"'.($selected == $key?' selected="selected"':'').'>'.$val.'</option>'; print '<option value="'.$key.'"'.(($selected == $key) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected="selected"' : '').'>'.$val.'</option>';
} }
print '</select>'; print '</select>';
if ($selected == 0 || $selected == 100) $canedit=0; if ($selected == 0 || $selected == 100) $canedit=0;
print ' <input type="text" id="val'.$htmlname.'" name="percentageshown" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled="disabled"').'>'; print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled="disabled"').'>';
print '<span class="hideifna">%</span>'; print '<span class="hideifna">%</span>';
print ' <input type="hidden" name="percentage" value="'.$selected.'">';
} }
else else
{ {

View File

@ -232,8 +232,8 @@ function displayBox($selectedDate,$month,$year)
// Sur click dans calendrier, appelle fonction dpClickDay // Sur click dans calendrier, appelle fonction dpClickDay
echo "<TD class=\"".$dayclass."\""; echo "<TD class=\"".$dayclass."\"";
echo " onMouseOver=\"dpHighlightDay(".$mydate["year"].",".dol_print_date($thedate,"%m").",".$mydate["mday"].",tradMonths)\""; echo " onMouseOver=\"dpHighlightDay(".$mydate["year"].",parseInt('".dol_print_date($thedate,"%m")."',10),".$mydate["mday"].",tradMonths)\"";
echo " onClick=\"dpClickDay(".$mydate["year"].",".dol_print_date($thedate,"%m").",".$mydate["mday"].",'".$langs->trans("FormatDateShortJava")."')\""; echo " onClick=\"dpClickDay(".$mydate["year"].",parseInt('".dol_print_date($thedate,"%m")."',10),".$mydate["mday"].",'".$langs->trans("FormatDateShortJava")."')\"";
echo ">".sprintf("%02s",$mydate["mday"])."</TD>"; echo ">".sprintf("%02s",$mydate["mday"])."</TD>";
$cols++; $cols++;
@ -278,4 +278,4 @@ function displayBox($selectedDate,$month,$year)
<?php <?php
}//end function }//end function
?> ?>