name=$p_name; $this->readOnly=false; $this->size=20; $this->width=50; $this->heigh=20; $this->value=$p_value; $this->selected=""; $this->table=0; $this->disabled=false; $this->javascript=""; $this->extra2="all"; $this->show_start_date=true; $this->show_end_date=true; $this->exercice=$p_exercice; } /*! * \brief show the input html for a periode *\param $p_name is the name of the widget *\param $p_value is the default value *\param $p_exercice is the exercice, if not set then the user preference is used * \return string containing html code for the HTML * * */ public function input($p_name=null,$p_value=null) { foreach (array('type','cn') as $a) { if ( ! isset ($this->$a) ) throw new Exception('Variable non définie [ '.$a.']'); } $this->name=($p_name==null)?$this->name:$p_name; $this->value=($p_value==null)?$this->value:$p_value; if ( $this->readOnly==true) return $this->display(); switch ($this->type) { case CLOSED: $sql_closed="where p_closed=true and p_central = false "; break; case OPEN: $sql_closed="where p_closed=false"; break; case NOTCENTRALIZED: $sql_closed="where p_closed=true and p_central = false "; break; case ALL: $sql_closed=""; break; default: throw new Exception("invalide p_type in ".__FILE__.':'.__LINE__); } $sql="select p_id,to_char(p_start,'DD.MM.YYYY') as p_start_string, to_char(p_end,'DD.MM.YYYY') as p_end_string from parm_periode $sql_closed "; $cond=""; /* Create a filter on the current exercice */ if ( ! isset($this->filter_year) || (isset($this->filter_year) && $this->filter_year==true)) { if ( $this->exercice=='') { if (! isset($this->user) ) throw new Exception (__FILE__.':'.__LINE__.' user is not set'); $this->exercice=$this->user->get_exercice(); } $cond=''; if ( $sql_closed=="") $and=" where " ; else $and=" and "; if ($this->type == 'all' ) $cond=$and.' true '; $cond.=" $and p_exercice='".sql_string($this->exercice)."'"; } $sql.=$cond." order by p_start,p_end"; $Res=$this->cn->exec_sql($sql); $Max=$this->cn->size($Res); if ( $Max == 0 ) throw new Exception(_('Aucune periode trouvée'),1); $ret='"; return $ret; } /*!\brief print in html the readonly value of the widget*/ public function display() { $r="not implemented ".__FILE__.":".__LINE__; return $r; } static public function test_me() { } }