diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index ccdcbb37a72..e5041e082eb 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -85,13 +85,14 @@ if ($action == 'add_action') } $fulldayevent=$_POST["fullday"]; + $percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):GETPOST("percentage"); // If status is -1 or 100, percentage is not defined and we must use status // Clean parameters $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"]); // Check parameters - if (! $datef && $_POST["percentage"] == 100) + if (! $datef && $percentage == 100) { $error++; $action = 'create'; @@ -135,7 +136,7 @@ if ($action == 'add_action') $actioncomm->fk_project = isset($_POST["projectid"])?$_POST["projectid"]:0; $actioncomm->datep = $datep; $actioncomm->datef = $datef; - $actioncomm->percentage = isset($_POST["percentage"])?$_POST["percentage"]:0; + $actioncomm->percentage = $percentage; $actioncomm->duree=(($_POST["dureehour"] * 60) + $_POST["dureemin"]) * 60; $usertodo=new User($db); @@ -257,21 +258,20 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') } /* - * Action mise a jour de l'action + * Action update event */ if ($action == 'update') { if (! $_POST["cancel"]) { $fulldayevent=$_POST["fullday"]; + $percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):GETPOST("percentage"); // If status is -1 or 100, percentage is not defined and we must use status // Clean parameters if ($_POST["aphour"] == -1) $_POST["aphour"]='0'; if ($_POST["apmin"] == -1) $_POST["apmin"]='0'; if ($_POST["p2hour"] == -1) $_POST["p2hour"]='0'; if ($_POST["p2min"] == -1) $_POST["p2min"]='0'; - //if ($_POST["adhour"] == -1) $_POST["adhour"]='0'; - //if ($_POST["admin"] == -1) $_POST["admin"]='0'; $actioncomm = new Actioncomm($db); $actioncomm->fetch($id); @@ -282,9 +282,7 @@ if ($action == 'update') $actioncomm->label = $_POST["label"]; $actioncomm->datep = $datep; $actioncomm->datef = $datef; - //$actioncomm->date = $datea; - //$actioncomm->dateend = $datea2; - $actioncomm->percentage = $_POST["percentage"]; + $actioncomm->percentage = $percentage; $actioncomm->priority = $_POST["priority"]; $actioncomm->fulldayevent= $_POST["fullday"]?1:0; $actioncomm->location = isset($_POST["location"])?$_POST["location"]:''; @@ -294,7 +292,7 @@ if ($action == 'update') $actioncomm->note = $_POST["note"]; $actioncomm->pnote = $_POST["note"]; - if (! $datef && $_POST["percentage"] == 100) + if (! $datef && $percentage == 100) { $error=$langs->trans("ErrorFieldRequired",$langs->trans("DateEnd")); $action = 'edit'; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 6405577e228..77f6bbfa60e 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -1,185 +1,215 @@ * Copyright (C) 2010-2011 Regis Houssin - * Copyright (C) 2010 Juanjo Menent - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +* Copyright (C) 2010 Juanjo Menent +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ /** * \file htdocs/core/class/html.formactions.class.php * \ingroup core * \brief Fichier de la classe des fonctions predefinie de composants html actions - */ +*/ /** * Class to manage building of HTML components - */ +*/ class FormActions { - var $db; - var $error; + var $db; + var $error; - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - function FormActions($db) - { - $this->db = $db; - return 1; - } + */ + function FormActions($db) + { + $this->db = $db; + return 1; + } - /** - * Show list of action status - * - * @param string $formname Name of form where select in included - * @param string $selected Preselected value - * @param int $canedit 1=can edit, 0=read only - * @param string $htmlname Name of html prefix for html fields (selectX and valX) - * @return void - */ - function form_select_status_action($formname,$selected,$canedit=1,$htmlname='complete') - { - global $langs,$conf; + /** + * Show list of action status + * + * @param string $formname Name of form where select in included + * @param string $selected Preselected value (-1..100) + * @param int $canedit 1=can edit, 0=read only + * @param string $htmlname Name of html prefix for html fields (selectX and valX) + * @return void + */ + function form_select_status_action($formname,$selected,$canedit=1,$htmlname='complete') + { + global $langs,$conf; - $listofstatus=array('-1'=>$langs->trans("ActionNotApplicable"), - '0'=>$langs->trans("ActionRunningNotStarted"), - '50'=>$langs->trans("ActionRunningShort"), - '100'=>$langs->trans("ActionDoneShort")); + $listofstatus = array( + '-1' => $langs->trans("ActionNotApplicable"), + '0' => $langs->trans("ActionRunningNotStarted"), + '50' => $langs->trans("ActionRunningShort"), + '100' => $langs->trans("ActionDoneShort") + ); - if ($conf->use_javascript_ajax) - { - print "\n"; - print ''."\n"; - print ''; - if ($selected == 0 || $selected == 100) $canedit=0; - print ' =0)?'':' disabled="disabled"').'>'; - print '%'; - print ' '; - } - else - { - print ' %'; - } - } + if (! empty($conf->use_javascript_ajax)) + { + print "\n"; + print "\n"; + print ''; + if ($selected == 0 || $selected == 100) $canedit=0; + print ' =0)?'':' disabled="disabled"').'>'; + print '%'; + } + else + { + print ' %'; + } + } - /** - * Show list of actions for element - * - * @param Object $object Object - * @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter' - * @param int $socid socid of user - * @return int <0 if KO, >=0 if OK - */ - function showactions($object,$typeelement,$socid=0) - { - global $langs,$conf,$user; - global $bc; + /** + * Show list of actions for element + * + * @param Object $object Object + * @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter' + * @param int $socid socid of user + * @return int <0 if KO, >=0 if OK + */ + function showactions($object,$typeelement,$socid=0) + { + global $langs,$conf,$user; + global $bc; - require_once(DOL_DOCUMENT_ROOT."/comm/action/class/actioncomm.class.php"); + require_once(DOL_DOCUMENT_ROOT."/comm/action/class/actioncomm.class.php"); - $actioncomm = new ActionComm($this->db); - $actioncomm->getActions($socid, $object->id, $typeelement); + $actioncomm = new ActionComm($this->db); + $actioncomm->getActions($socid, $object->id, $typeelement); - $num = count($actioncomm->actions); - if ($num) - { - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'project') $title=$langs->trans('ActionsOnProject'); - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); - elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); - else $title=$langs->trans("Actions"); + $num = count($actioncomm->actions); + if ($num) + { + if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); + elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); + elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); + elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); + elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); + elseif ($typeelement == 'project') $title=$langs->trans('ActionsOnProject'); + elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); + elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); + else $title=$langs->trans("Actions"); - print_titre($title); + print_titre($title); - $total = 0; $var=true; - print ''; - print ''; - print "\n"; + $total = 0; $var=true; + print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'; + print ''; + print "\n"; - foreach($actioncomm->actions as $action) - { - $var=!$var; - print ''; - print ''; - print ''; - print ''; - $userstatic = new User($this->db); - $userstatic->id = $action->author->id; - $userstatic->firstname = $action->author->firstname; - $userstatic->lastname = $action->author->lastname; - print ''; - print ''; - } - print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'.$action->getNomUrl(1).''.dol_print_date($action->datep,'day').''.dol_trunc($action->label,32).''.$userstatic->getNomUrl(1).'
'; - } + foreach($actioncomm->actions as $action) + { + $var=!$var; + print ''; + print ''.$action->getNomUrl(1).''; + print ''.dol_print_date($action->datep,'day').''; + print ''.dol_trunc($action->label,32).''; + $userstatic = new User($this->db); + $userstatic->id = $action->author->id; + $userstatic->firstname = $action->author->firstname; + $userstatic->lastname = $action->author->lastname; + print ''.$userstatic->getNomUrl(1).''; + print ''; + } + print ''; + } - return $num; - } + return $num; + } - /** - * Output list of type of event - * - * @param string $selected Type pre-selectionne - * @param string $htmlname Nom champ formulaire - * @return void - */ - function select_type_actions($selected='',$htmlname='actioncode') - { - global $langs,$user; + /** + * Output list of type of event + * + * @param string $selected Type pre-selectionne + * @param string $htmlname Nom champ formulaire + * @return void + */ + function select_type_actions($selected='',$htmlname='actioncode') + { + global $langs,$user; - require_once(DOL_DOCUMENT_ROOT."/comm/action/class/cactioncomm.class.php"); - require_once(DOL_DOCUMENT_ROOT."/core/class/html.form.class.php"); - $caction=new CActionComm($this->db); - $form=new Form($this->db); + require_once(DOL_DOCUMENT_ROOT."/comm/action/class/cactioncomm.class.php"); + require_once(DOL_DOCUMENT_ROOT."/core/class/html.form.class.php"); + $caction=new CActionComm($this->db); + $form=new Form($this->db); - $arraylist=$caction->liste_array(1,'code'); - array_unshift($arraylist,' '); // Add empty line at start - //asort($arraylist); + $arraylist=$caction->liste_array(1,'code'); + array_unshift($arraylist,' '); // Add empty line at start + //asort($arraylist); - print $form->selectarray($htmlname, $arraylist, $selected); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - } + print $form->selectarray($htmlname, $arraylist, $selected); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + } }