25require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
35 public $element =
'expenserule';
40 public $table_element =
'expensereport_rules';
45 public $fk_element =
'fk_expense_rule';
87 public $fk_c_type_fees;
93 public $code_expense_rules_type;
114 public $fields = array(
115 'rowid'=>array(
'type'=>
'integer',
'index'=>
true)
116 ,
'dates'=>array(
'type'=>
'date')
117 ,
'datee'=>array(
'type'=>
'date')
118 ,
'amount'=>array(
'type'=>
'double')
119 ,
'restrictive'=>array(
'type'=>
'integer')
120 ,
'fk_user'=>array(
'type'=>
'integer')
121 ,
'fk_usergroup'=>array(
'type'=>
'integer')
122 ,
'fk_c_type_fees'=>array(
'type'=>
'integer')
123 ,
'code_expense_rules_type'=>array(
'type'=>
'string')
124 ,
'is_for_all'=>array(
'type'=>
'integer')
125 ,
'entity'=>array(
'type'=>
'integer')
153 return $resultcreate;
164 public function fetch($id, $ref =
null)
167 if ($result > 0 && !empty($this->table_element_line)) {
181 $this->lines = array();
206 public function delete(
User $user, $notrigger =
false)
221 public function getAllRule($fk_c_type_fees =
'', $date =
'', $fk_user =
'')
225 $sql =
'SELECT er.rowid';
226 $sql .=
' FROM '.MAIN_DB_PREFIX.
'expensereport_rules er';
227 $sql .=
' WHERE er.entity IN (0,'.getEntity($this->element).
')';
228 if (!empty($fk_c_type_fees)) {
229 $sql .=
' AND er.fk_c_type_fees IN (-1, '.((int) $fk_c_type_fees).
')';
232 $sql .=
" AND er.dates <= '".$this->db->idate($date).
"'";
233 $sql .=
" AND er.datee >= '".$this->db->idate($date).
"'";
236 $sql .=
' AND (er.is_for_all = 1';
237 $sql .=
' OR er.fk_user = '.((int) $fk_user);
238 $sql .=
' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.
'usergroup_user ugu WHERE ugu.fk_user = '.((int) $fk_user).
') )';
240 $sql .=
' ORDER BY er.is_for_all, er.fk_usergroup, er.fk_user';
244 $resql = $this->db->query($sql);
246 while ($obj = $this->db->fetch_object($resql)) {
248 if ($rule->fetch($obj->rowid) > 0) {
249 $rules[$rule->id] = $rule;
268 include_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
270 if ($this->fk_usergroup > 0) {
272 if ($group->fetch($this->fk_usergroup) > 0) {
275 $this->error = $group->error;
276 $this->errors[] = $this->error;
290 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
292 if ($this->fk_user > 0) {
293 $u =
new User($this->db);
294 if ($u->fetch($this->fk_user) > 0) {
297 $this->error = $u->error;
298 $this->errors[] = $this->error;
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the database.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchLinesCommon($morewhere='')
Load object in memory from the database.
Class to manage Dolibarr database access.
Class to manage inventories.
getAllRule($fk_c_type_fees='', $date='', $fk_user='')
Return all rules or filtered by something.
getGroupLabel()
Return the label of group for the current object.
create(User $user, $notrigger=false)
Create object into database.
fetch($id, $ref=null)
Load object in memory from the database.
getUserName()
Return the name of user for the current object.
__construct(DoliDB $db)
Constructor.
fetchLines()
Load object lines in memory from the database.
update(User $user, $notrigger=false)
Update object into database.
Class to manage user groups.
Class to manage Dolibarr users.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.