absences_RightList::getSearchForm()   B
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 105
Code Lines 59

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 59
c 0
b 0
f 0
nc 8
nop 0
dl 0
loc 105
rs 8.1935

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/************************************************************************
3
 * OVIDENTIA http://www.ovidentia.org                                   *
4
 ************************************************************************
5
 * Copyright (c) 2003 by CANTICO ( http://www.cantico.fr )              *
6
 *                                                                      *
7
 * This file is part of Ovidentia.                                      *
8
 *                                                                      *
9
 * Ovidentia is free software; you can redistribute it and/or modify    *
10
 * it under the terms of the GNU General Public License as published by *
11
 * the Free Software Foundation; either version 2, or (at your option)  *
12
 * any later version.													*
13
 *																		*
14
 * This program is distributed in the hope that it will be useful, but  *
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of			*
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.					*
17
 * See the  GNU General Public License for more details.				*
18
 *																		*
19
 * You should have received a copy of the GNU General Public License	*
20
 * along with this program; if not, write to the Free Software			*
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,*
22
 * USA.																	*
23
************************************************************************/
24
25
26
27
28
class absences_RightList extends absences_Paginate
29
{
30
    public $typetxt;
31
    public $desctxt;
32
    public $quantitytxt;
33
    public $creditortxt;
34
    public $datetxt;
35
    public $date2txt;
36
    public $vrurl;
37
    public $vrviewurl;
38
    public $description;
39
40
    public $typename;
41
    public $quantity;
42
    public $creditor;
43
    public $date;
44
    public $addtxt;
45
    public $addurl;
46
    public $filteron;
47
    public $statustxt;
48
    public $activeyes;
49
    public $activeno;
50
    public $yselected;
51
    public $nselected;
52
53
    public $urllistp;
54
    public $altlistp;
55
    public $selected;
56
57
    public $begintxt;
58
    public $endtxt;
59
60
    public $arr = array();
61
    public $count;
62
    public $res;
63
    public $topurl;
64
    public $bottomurl;
65
    public $nexturl;
66
    public $prevurl;
67
    public $topname;
68
    public $bottomname;
69
    public $nextname;
70
    public $prevname;
71
    public $pos;
72
    public $bclose;
73
    public $closedtxt;
74
    public $openedtxt;
75
    public $statusval;
76
    public $alttxt;
77
    public $altbg = true;
78
79
    public function __construct($idtype, $idcoll, $rgroup, $dateb, $datee, $active, $pos, $archived, $recovery, $name)
80
    {
81
82
        $this->desctxt = absences_translate("Description");
83
        $this->typetxt = absences_translate("Type");
84
        $this->nametxt = absences_translate("Name");
0 ignored issues
show
Bug introduced by
The property nametxt does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
85
        $this->kindtxt = absences_translate("Right kind");
0 ignored issues
show
Bug introduced by
The property kindtxt does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
86
        $this->quantitytxt = absences_translate("Quantity");
87
        $this->creditortxt = absences_translate("Author");
88
        $this->datetxt = absences_translate("Entry date");
89
        $this->date2txt = absences_translate("Entry date ( dd-mm-yyyy )");
90
        $this->addtxt = absences_translate("Allocate vacation rights");
91
        $this->filteron = absences_translate("Filter on");
92
        $this->begintxt = absences_translate("Begin");
93
        $this->endtxt = absences_translate("End");
94
        $this->altlistp = absences_translate("Beneficiaries");
95
        $this->statustxt = absences_translate("Active");
96
        $this->activeyes = absences_translate("Opened rights");
97
        $this->activeno = absences_translate("Closed rights");
98
        $this->closedtxt = absences_translate("Vac. closed");
99
        $this->openedtxt = absences_translate("Vac. opened");
100
        $this->alttxt = absences_translate("Modify");
101
        $this->t_edit = absences_translate("Modification");
0 ignored issues
show
Bug introduced by
The property t_edit does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
102
        $this->t_first_page = absences_translate("First page");
0 ignored issues
show
Bug introduced by
The property t_first_page does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
103
        $this->t_previous_page = absences_translate("Previous page");
0 ignored issues
show
Bug introduced by
The property t_previous_page does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
104
        $this->t_next_page = absences_translate("Next page");
0 ignored issues
show
Bug introduced by
The property t_next_page does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
105
        $this->t_last_page = absences_translate("Last page");
0 ignored issues
show
Bug introduced by
The property t_last_page does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
106
        $this->t_available = absences_translate("Availability");
0 ignored issues
show
Bug introduced by
The property t_available does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
107
        $this->topurl = "";
108
        $this->bottomurl = "";
109
        $this->nexturl = "";
110
        $this->prevurl = "";
111
        $this->yselected = "";
112
        $this->nselected = "";
113
        $this->t_position = '';
114
        global $babDB;
115
116
        $this->pos = $pos;
117
118
        $aaareq = array();
119
        $req = "".ABSENCES_RIGHTS_TBL." r LEFT JOIN ".ABSENCES_TYPES_TBL." t ON t.id=r.id_type where ";
120
121
        if( $name != "") {
122
            $aaareq[] = "r.description LIKE '%".$babDB->db_escape_like($name)."%'";
123
        }
124
125
        if( $active != "")
126
            $aaareq[] = "r.active='".$babDB->db_escape_string($active)."'";
127
128
        if( $idcoll != "")
129
        {
130
            $aaareq[] = "r.id IN(SELECT id_right FROM absences_coll_rights WHERE id_coll=".$babDB->quote($idcoll).")";
131
        }
132
        
133
        if( $idtype != "")
134
        {
135
            $aaareq[] = "r.id_type=".$babDB->quote($idtype);
136
        }
137
138
        if( $rgroup != "")
139
        {
140
            $aaareq[] = "r.id_rgroup=".$babDB->quote($rgroup);
141
        }
142
143
        if( $dateb != "" )
144
        {
145
            $ar = explode("-", $dateb);
146
            $dateb = $ar[2]."-".$ar[1]."-".$ar[0];
147
        }
148
149 View Code Duplication
        if( $datee != "" )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
150
        {
151
            $ar = explode("-", $datee);
152
            $datee = $ar[2]."-".$ar[1]."-".$ar[0];
153
        }
154
155
        if( $dateb != "" && $datee != "")
156
        {
157
            $aaareq[] = "( r.date_entry between '".$babDB->db_escape_string($dateb)."' and '".$babDB->db_escape_string($datee)."')";
158
        }
159
        else if( $dateb == "" && $datee != "" )
160
        {
161
            $aaareq[] = "r.date_entry <= '".$babDB->db_escape_string($datee)."'";
162
        }
163
        else if ($dateb != "" )
164
        {
165
            $aaareq[] = "r.date_entry >= '".$babDB->db_escape_string($dateb)."'";
166
        }
167
168
        if ($archived)
169
        {
170
            $aaareq[] = "r.archived = ".$babDB->quote(1);
171
        } else {
172
            $aaareq[] = "r.archived = ".$babDB->quote(0);
173
        }
174
175
        if ($recovery)
176
        {
177
            $aaareq[] = "r.kind = ".$babDB->quote(absences_Right::RECOVERY);
178
        } else {
179
            $aaareq[] = "r.kind <> ".$babDB->quote(absences_Right::RECOVERY);
180
        }
181
182
183 View Code Duplication
        if( isset($aaareq) && sizeof($aaareq) > 0 )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
184
        {
185
            if( sizeof($aaareq) > 1 )
186
                $req .= implode(' and ', $aaareq);
187
            else
188
                $req .= $aaareq[0];
189
        }
190
        $req .= " order by r.date_entry desc, r.id";
191
192
        list($total) = $babDB->db_fetch_row($babDB->db_query("select count(*) as total from ".$req));
193
194
        $this->paginate($total, ABSENCES_MAX_RIGHTS_LIST);
195
196
        if( $total > ABSENCES_MAX_RIGHTS_LIST)
197
        {
198
            $req .= " limit ".$pos.",".ABSENCES_MAX_RIGHTS_LIST;
199
        }
200
        bab_debug("select r.*, t.name type, t.color typecolor from ".$req);
201
        $this->res = $babDB->db_query("select r.*, t.name type, t.color typecolor from ".$req);
202
        $this->count = $babDB->db_num_rows($this->res);
203
        $this->addurl = absences_addon()->getUrl()."vacadma&idx=addvr";
204
205
206
        $this->dateburl = $GLOBALS['babUrlScript']."?tg=month&callback=dateBegin&ymin=0&ymax=3";
0 ignored issues
show
Bug introduced by
The property dateburl does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
207
        $this->dateeurl = $GLOBALS['babUrlScript']."?tg=month&callback=dateEnd&ymin=0&ymax=3";
0 ignored issues
show
Bug introduced by
The property dateeurl does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
208
209
        $this->searchform = $this->getSearchForm();
0 ignored issues
show
Bug introduced by
The property searchform does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
210
    }
211
212
213
    private function getSearchForm()
214
    {
215
        global $babDB;
216
        bab_functionality::includeOriginal('Icons');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class bab_functionality as the method includeOriginal() does only exist in the following sub-classes of bab_functionality: Func_Archive, Func_Archive_Zip, Func_Archive_Zip_ZipArchive, Func_Archive_Zip_Zlib, Func_CalendarBackend, Func_CalendarBackend_Ovi, Func_ContextActions, Func_ContextActions_Article, Func_ContextActions_ArticleTopic, Func_Home, Func_Home_Ovidentia, Func_Icons, Func_Icons_Default, Func_Ovml, Func_Ovml_Container, Func_Ovml_Container_Addon, Func_Ovml_Container_Article, Func_Ovml_Container_ArticleCategories, Func_Ovml_Container_ArticleCategory, Func_Ovml_Container_ArticleCategoryNext, Func_Ovml_Container_ArticleCategoryPrevious, Func_Ovml_Container_ArticleFiles, Func_Ovml_Container_ArticleNext, Func_Ovml_Container_ArticlePrevious, Func_Ovml_Container_ArticleTopic, Func_Ovml_Container_ArticleTopicNext, Func_Ovml_Container_ArticleTopicPrevious, Func_Ovml_Container_ArticleTopics, Func_Ovml_Container_Articles, Func_Ovml_Container_ArticlesHomePages, Func_Ovml_Container_CalendarCategories, Func_Ovml_Container_CalendarEventDomains, Func_Ovml_Container_CalendarEvents, Func_Ovml_Container_CalendarGroupEvents, Func_Ovml_Container_CalendarResourceEvents, Func_Ovml_Container_CalendarUserEvents, Func_Ovml_Container_Calendars, Func_Ovml_Container_DbDirectories, Func_Ovml_Container_DbDirectory, Func_Ovml_Container_DbDirectoryAcl, Func_Ovml_Container_DbDirectoryEntry, Func_Ovml_Container_DbDirectoryEntryFields, Func_Ovml_Container_DbDirectoryFields, Func_Ovml_Container_DbDirectoryMemberFields, Func_Ovml_Container_DbDirectoryMembers, Func_Ovml_Container_Delegation, Func_Ovml_Container_DelegationAdministrators, Func_Ovml_Container_DelegationItems, Func_Ovml_Container_DelegationManaged, Func_Ovml_Container_Delegations, Func_Ovml_Container_DelegationsCategories, Func_Ovml_Container_DelegationsCategory, Func_Ovml_Container_DelegationsManaged, Func_Ovml_Container_Faq, Func_Ovml_Container_FaqNext, Func_Ovml_Container_FaqPrevious, Func_Ovml_Container_FaqQuestion, Func_Ovml_Container_FaqQuestionNext, Func_Ovml_Container_FaqQuestionPrevious, Func_Ovml_Container_FaqQuestions, Func_Ovml_Container_FaqSubCategories, Func_Ovml_Container_FaqSubCategory, Func_Ovml_Container_Faqs, Func_Ovml_Container_File, Func_Ovml_Container_FileFields, Func_Ovml_Container_FileNext, Func_Ovml_Container_FilePrevious, Func_Ovml_Container_Files, Func_Ovml_Container_Folder, Func_Ovml_Container_FolderNext, Func_Ovml_Container_FolderPrevious, Func_Ovml_Container_Folders, Func_Ovml_Container_Forum, Func_Ovml_Container_ForumNext, Func_Ovml_Container_ForumPrevious, Func_Ovml_Container_Forums, Func_Ovml_Container_IfEqual, Func_Ovml_Container_IfGreaterThan, Func_Ovml_Container_IfGreaterThanOrEqual, Func_Ovml_Container_IfIsSet, Func_Ovml_Container_IfLessThan, Func_Ovml_Container_IfLessThanOrEqual, Func_Ovml_Container_IfNotEqual, Func_Ovml_Container_IfNotIsSet, Func_Ovml_Container_IfUserMemberOfGroups, Func_Ovml_Container_Multipages, Func_Ovml_Container_ObjectsInfo, Func_Ovml_Container_OrgPathToEntity, Func_Ovml_Container_OrgUserEntities, Func_Ovml_Container_OvmlArray, Func_Ovml_Container_OvmlArrayFields, Func_Ovml_Container_OvmlSoap, Func_Ovml_Container_ParentsArticleCategory, Func_Ovml_Container_Post, Func_Ovml_Container_PostFiles, Func_Ovml_Container_RecentArticles, Func_Ovml_Container_RecentComments, Func_Ovml_Container_RecentFaqQuestions, Func_Ovml_Container_RecentFiles, Func_Ovml_Container_RecentPosts, Func_Ovml_Container_RecentThreads, Func_Ovml_Container_SitemapCustomNode, Func_Ovml_Container_SitemapEntries, Func_Ovml_Container_SitemapEntry, Func_Ovml_Container_SitemapPath, Func_Ovml_Container_Soap, Func_Ovml_Container_SubFolders, Func_Ovml_Container_Tags, Func_Ovml_Container_Thread, Func_Ovml_Container_TmProjects, Func_Ovml_Container_TmSpaces, Func_Ovml_Container_TmTaskFields, Func_Ovml_Container_TmTasks, Func_Ovml_Container_WaitingArticles, Func_Ovml_Container_WaitingComments, Func_Ovml_Container_WaitingFiles, Func_Ovml_Container_WaitingPosts, Func_Ovml_Function, Func_Ovml_Function_AOAddition, Func_Ovml_Function_AODivision, Func_Ovml_Function_AOModulus, Func_Ovml_Function_AOMultiplication, Func_Ovml_Function_AOSubtraction, Func_Ovml_Function_AddStyleSheet, Func_Ovml_Function_Addon, Func_Ovml_Function_Ajax, Func_Ovml_Function_ArticleTree, Func_Ovml_Function_CurrentNode, Func_Ovml_Function_FileTree, Func_Ovml_Function_Get, Func_Ovml_Function_GetCookie, Func_Ovml_Function_GetCsrfProtectToken, Func_Ovml_Function_GetCurrentAdmGroup, Func_Ovml_Function_GetLanguage, Func_Ovml_Function_GetPageTitle, Func_Ovml_Function_GetPath, Func_Ovml_Function_GetSelectedSkinPath, Func_Ovml_Function_GetSessionVar, Func_Ovml_Function_GetVar, Func_Ovml_Function_Header, Func_Ovml_Function_IfNotIsSet, Func_Ovml_Function_Include, Func_Ovml_Function_NextArticle, Func_Ovml_Function_Post, Func_Ovml_Function_PreviousArticle, Func_Ovml_Function_PreviousOrNextArticle, Func_Ovml_Function_PutArray, Func_Ovml_Function_PutSoapArray, Func_Ovml_Function_PutVar, Func_Ovml_Function_Recurse, Func_Ovml_Function_Request, Func_Ovml_Function_SetCookie, Func_Ovml_Function_SetSessionVar, Func_Ovml_Function_SitemapCustomNodeId, Func_Ovml_Function_SitemapMenu, Func_Ovml_Function_SitemapPosition, Func_Ovml_Function_SitemapUrl, Func_Ovml_Function_Translate, Func_Ovml_Function_UrlContent, Func_Ovml_Function_WebStat, Func_PortalAuthentication, Func_PortalAuthentication_AuthOvidentia, Func_PwdComplexity, Func_PwdComplexity_DefaultPortal, Func_SearchUi, Func_SitemapDynamicNode, Func_SitemapDynamicNode_Topic, Func_UserEditor, Func_WorkingHours, Func_WorkingHours_Ovidentia, Ovml_Container_Sitemap, bab_ArithmeticOperator, bab_Ovml_Container_Operator, bab_rgp. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
217
        $W = bab_Widgets();
218
        $form = $W->Form(null, $W->FlowLayout()->setSpacing(1,'em', 3,'em'));
219
        $form->setSelfPageHiddenFields()->setReadOnly();
220
221
        $form->addClass('widget-bordered');
222
        $form->addClass('BabLoginMenuBackground');
223
        $form->addClass('widget-centered');
224
        $form->addClass(Func_Icons::ICON_LEFT_16);
225
        $form->colon();
226
227
        $form->setCanvasOptions($form->Options()->width(97,'%'));
0 ignored issues
show
Bug introduced by
It seems like $form->Options()->width(97, '%') targeting Widget_CanvasOptions::width() can also be of type double; however, Widget_Item::setCanvasOptions() does only seem to accept object<Widget_CanvasOptions>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
228
        
229
        
230
        
231
        $form->addItem(
232
            $W->LabelledWidget(
233
                absences_translate('Name'),
234
                $W->LineEdit(),
235
                'name'
236
            )
237
        );
238
        
239
        
240
241
        $types = $W->Select()->addOption('', '');
242
        $restype = $babDB->db_query("select * from ".ABSENCES_TYPES_TBL." order by name asc");
243
        while ($arr = $babDB->db_fetch_assoc($restype))
244
        {
245
            $types->addOption($arr['id'], $arr['name']);
246
        }
247
248
        $form->addItem(
249
                $W->LabelledWidget(
250
                        absences_translate('Type'),
251
                        $types,
252
                        'idtype'
253
                )
254
        );
255
256
257
        $collections = $W->Select()->addOption('', '');
258
        $rescoll = $babDB->db_query("select * from ".ABSENCES_COLLECTIONS_TBL." order by name asc");
259
        while ($arr = $babDB->db_fetch_assoc($rescoll))
260
        {
261
            $collections->addOption($arr['id'], $arr['name']);
262
        }
263
264
        $form->addItem(
265
                $W->LabelledWidget(
266
                        absences_translate('Collection'),
267
                        $collections,
268
                        'idcoll'
269
                )
270
        );
271
272
273
        $rgroups = $W->Select()->addOption('', '');
274
        $resrg = $babDB->db_query("select * from absences_rgroup order by name asc");
275
        while ($arr = $babDB->db_fetch_assoc($resrg))
276
        {
277
            $rgroups->addOption($arr['id'], $arr['name']);
278
        }
279
280
281
        $form->addItem(
282
                $W->LabelledWidget(
283
                        absences_translate('Right group'),
284
                        $rgroups,
285
                        'rgroup'
286
                )
287
        );
288
289
290
        $form->addItem(
291
                $W->LabelledWidget(
292
                        absences_translate('Status'),
293
                        $W->Select()
294
                        ->addOption('', '')
295
                        ->addOption('Y', absences_translate('Active'))
296
                        ->addOption('N', absences_translate('Inactive')),
297
                        'active'
298
                )
299
        );
300
301
302
        $form->addItem(
303
                $W->LabelledWidget(
304
                        absences_translate('Write date'),
305
                        $W->PeriodPicker()->setNames('dateb', 'datee')
306
                )
307
        );
308
309
310
        $form->setValues($_REQUEST);
311
312
313
314
        $form->addItem($W->SubmitButton()->setLabel(absences_translate('Search')));
315
316
        return $form->display($W->HtmlCanvas());
317
    }
318
319
    public function getnext()
320
    {
321
        static $i = 0;
322
        if( $i < $this->count)
323
        {
324
            global $babDB;
325
            $this->altbg = !$this->altbg;
326
            $arr = $babDB->db_fetch_array($this->res);
327
328
329
            $this->typecolor	= bab_toHtml($arr['typecolor']);
0 ignored issues
show
Bug introduced by
The property typecolor does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
330
            $this->typename		= bab_toHtml($arr['type']);
331
332
            unset($arr['typecolor']);
333
            unset($arr['type']);
334
335
336
            $right = new absences_Right($arr['id']);
337
            $right->setRow($arr);
338
339
340
            $this->vrurl		= bab_toHtml(absences_addon()->getUrl()."vacadma&idx=modvr&idvr=".$arr['id']);
341
            $this->vrviewurl	= bab_toHtml(absences_addon()->getUrl()."vacadma&idx=viewvr&idvr=".$arr['id']);
342
343
            $this->kind 		= bab_toHtml($right->getKindLabel());
0 ignored issues
show
Bug introduced by
The property kind does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
344
            $this->description	= bab_toHtml($right->description);
345
            if (0 === (int) round(100*$arr['quantity']))
346
            {
347
                $this->quantity	= '';
348
            } else {
349
                $this->quantity	= bab_toHtml(absences_quantity($arr['quantity'], $arr['quantity_unit']));
350
            }
351
            $this->creditor		= bab_toHtml(bab_getUserName($arr['id_creditor']));
352
            $this->date			= bab_toHtml(bab_shortDate(bab_mktime($arr['date_entry']), false));
353
            $this->bclose		= $arr['active'] == "N";
354
355
356
            $this->available	= $right->isAvailable() ? absences_translate('Available') : '';
0 ignored issues
show
Bug introduced by
The property available does not seem to exist. Did you mean t_available?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
357
358
            if( $this->bclose )
359
                $this->statusval = $this->closedtxt;
360
            else
361
                $this->statusval = $this->openedtxt;
362
363
            if (absences_Right::RECOVERY === $right->getKind())
364
            {
365
                $this->urllistp = false;
366
            } else {
367
                $this->urllistp = absences_addon()->getUrl()."vacadma&idx=lvrc&idvr=".$arr['id'];
368
            }
369
370
            $i++;
371
            return true;
372
        }
373
        else
374
            return false;
375
376
    }
377
378
}
379
380
381
382
383
384
/**
385
 * Display a menu to add items to the agent list
386
 * @return string
387
 */
388
function absences_rightListMenu()
389
{
390
    $toolbar = absences_getToolbar();
391
392
    $sImgPath = $GLOBALS['babInstallPath'] . 'skins/ovidentia/images/Puces/';
393
394
    $url = bab_url::get_request('tg', 'filter');
395
    $url->idx = 'addvr';
396
397
    $toolbar->addToolbarItem(
398
        new BAB_ToolbarItem(absences_translate('Add'), $url->toString(),
399
            $sImgPath . 'edit_add.png', '', '', '')
400
    );
401
    
402
403
    return $toolbar->printTemplate();
404
}
405