noalyss  Version-6.7.2
Public Member Functions | Static Public Member Functions | Data Fields
IPeriod Class Reference

Generate the form for the periode Data Members. More...

Inheritance diagram for IPeriod:
HtmlInput

Public Member Functions

 __construct ($p_name="", $p_value="", $p_exercice='')
 display ()
 print in html the readonly value of the widget
 input ($p_name=null, $p_value=null)
 show the input html for a periode

Static Public Member Functions

static test_me ()

Data Fields

 $cn
 $filter_year
 $show_end_date
 $show_start_date
 $type
 $user

Detailed Description

Generate the form for the periode Data Members.

Definition at line 35 of file class_iperiod.php.


Constructor & Destructor Documentation

IPeriod::__construct ( p_name = "",
p_value = "",
p_exercice = '' 
)

$user if a filter is required then we need who is the user (object User)

Reimplemented from HtmlInput.

Definition at line 43 of file class_iperiod.php.

References disabled, heigh, javascript, name, readOnly, selected, show_end_date, show_start_date, size, table, value, and width.

    {
        $this->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;
    }

Member Function Documentation

print in html the readonly value of the widget

Definition at line 162 of file class_iperiod.php.

References $r.

Referenced by input().

    {
        $r="not implemented ".__FILE__.":".__LINE__;
        return $r;

    }
IPeriod::input ( p_name = null,
p_value = null 
)

show the input html for a periode

Parameters:
$p_nameis the name of the widget
$p_valueis the default value
$p_exerciceis the exercice, if not set then the user preference is used
Returns:
string containing html code for the HTML

Definition at line 69 of file class_iperiod.php.

References $a, $Max, $Res, $ret, $sel, $sql, cn, display(), filter_year, javascript, name, readOnly, show_end_date, show_start_date, type, user, and value.

    {
        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='<SELECT NAME="'.$this->name.'" '.$this->javascript.'>';
        for ( $i = 0; $i < $Max;$i++)
        {
            $l_line=$this->cn->fetch($i);
            if ( $this->value==$l_line['p_id'] )
                $sel="SELECTED";
            else
                $sel="";

            if ( $this->show_start_date == true && $this->show_end_date==true )
            {
                $ret.=sprintf('<OPTION VALUE="%s" %s>%s - %s',$l_line['p_id']
                              ,$sel
                              ,$l_line['p_start_string']
                              ,$l_line['p_end_string']);
            }
            else if ($this->show_start_date == true )
            {
                $ret.=sprintf('<OPTION VALUE="%s" %s>%s ',$l_line['p_id']
                              ,$sel
                              ,$l_line['p_start_string']
                             );
            }
            else if ( $this->show_end_date == true )
            {
                $ret.=sprintf('<OPTION VALUE="%s" %s>%s ',$l_line['p_id']
                              ,$sel
                              ,$l_line['p_end_string']
                             );
            }

        }
        $ret.="</SELECT>";
        return $ret;


    }
static IPeriod::test_me ( ) [static]

Definition at line 168 of file class_iperiod.php.

    {
    }

Field Documentation

IPeriod::$cn

$cn is the database connection

Definition at line 38 of file class_iperiod.php.

IPeriod::$filter_year

$filter_year make a filter on the default exercice by default yes

Definition at line 41 of file class_iperiod.php.

IPeriod::$show_end_date

$show_end_date is not set or false, do not show the end date

Definition at line 39 of file class_iperiod.php.

IPeriod::$show_start_date

$show_start_date is not set or false, do not show the start date

Definition at line 40 of file class_iperiod.php.

IPeriod::$type

$type the type of the periode OPEN CLOSE NOTCENTRALIZED or ALL

Reimplemented from HtmlInput.

Definition at line 37 of file class_iperiod.php.

IPeriod::$user

Definition at line 42 of file class_iperiod.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations