25 require_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)) {
193 public function delete(
User $user, $notrigger =
false)
208 public function getAllRule($fk_c_type_fees =
'', $date =
'', $fk_user =
'')
212 $sql =
'SELECT er.rowid';
213 $sql .=
' FROM '.MAIN_DB_PREFIX.
'expensereport_rules er';
214 $sql .=
' WHERE er.entity IN (0,'.getEntity($this->element).
')';
215 if (!empty($fk_c_type_fees)) {
216 $sql .=
' AND er.fk_c_type_fees IN (-1, '.((int) $fk_c_type_fees).
')';
219 $sql .=
" AND er.dates <= '".$this->db->idate($date).
"'";
220 $sql .=
" AND er.datee >= '".$this->db->idate($date).
"'";
223 $sql .=
' AND (er.is_for_all = 1';
224 $sql .=
' OR er.fk_user = '.((int) $fk_user);
225 $sql .=
' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.
'usergroup_user ugu WHERE ugu.fk_user = '.((int) $fk_user).
') )';
227 $sql .=
' ORDER BY er.is_for_all, er.fk_usergroup, er.fk_user';
233 while ($obj = $this->
db->fetch_object(
$resql)) {
235 if ($rule->fetch($obj->rowid) > 0) {
236 $rules[$rule->id] = $rule;
255 include_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
257 if ($this->fk_usergroup > 0) {
259 if ($group->fetch($this->fk_usergroup) > 0) {
262 $this->error = $group->error;
263 $this->errors[] = $this->error;
277 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
279 if ($this->fk_user > 0) {
281 if ($u->fetch($this->fk_user) > 0) {
284 $this->error = $u->error;
285 $this->errors[] = $this->error;
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
getAllRule($fk_c_type_fees='', $date='', $fk_user='')
Return all rules or filtered by something.
$conf db
API class for accounts.
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the database.
Class to manage Dolibarr database access.
fetch($id, $ref=null)
Load object in memory from the database.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage user groups.
getUserName()
Return the name of user for the current object.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
create(User $user, $notrigger=false)
Create object into database.
createCommon(User $user, $notrigger=false)
Create object into database.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
updateCommon(User $user, $notrigger=false)
Update object into database.
update(User $user, $notrigger=false)
Update object into database.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
Class to manage Dolibarr users.
__construct(DoliDB $db)
Constructor.
Class to manage inventories.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
getGroupLabel()
Return the label of group for the current object.