47 $this->module_position =
'43';
49 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
50 $this->
description =
"Gestion des notes de frais et deplacements";
53 $this->version =
'dolibarr_deprecated';
55 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
56 $this->picto =
"trip";
59 $this->dirs = array();
62 $this->config_page_url = array();
63 $this->langfiles = array(
"companies",
"trips");
66 $this->depends = array();
67 $this->requiredby = array();
70 $this->
const = array();
73 $this->boxes = array();
76 $this->rights = array();
77 $this->rights_class =
'deplacement';
79 $this->rights[1][0] = 171;
80 $this->rights[1][1] =
'Lire ses notes de frais et deplacements et celles de sa hierarchy';
81 $this->rights[1][2] =
'r';
82 $this->rights[1][3] = 0;
83 $this->rights[1][4] =
'lire';
85 $this->rights[2][0] = 172;
86 $this->rights[2][1] =
'Creer/modifier une note de frais et deplacements';
87 $this->rights[2][2] =
'w';
88 $this->rights[2][3] = 0;
89 $this->rights[2][4] =
'creer';
91 $this->rights[3][0] = 173;
92 $this->rights[3][1] =
'Supprimer les notes de frais et deplacements';
93 $this->rights[3][2] =
'd';
94 $this->rights[3][3] = 0;
95 $this->rights[3][4] =
'supprimer';
97 $this->rights[4][0] = 174;
98 $this->rights[4][1] =
'Lire toutes les notes de frais';
99 $this->rights[4][2] =
'd';
100 $this->rights[4][3] = 0;
101 $this->rights[4][4] =
'readall';
103 $this->rights[5][0] = 178;
104 $this->rights[5][1] =
'Exporter les notes de frais et deplacements';
105 $this->rights[5][2] =
'd';
106 $this->rights[5][3] = 0;
107 $this->rights[5][4] =
'export';
119 $this->export_code[$r] =
'trips_'.$r;
120 $this->export_label[$r] =
'ListTripsAndExpenses';
121 $this->export_permission[$r] = array(array(
"deplacement",
"export"));
122 $this->export_fields_array[$r] = array(
'u.login'=>
'Login',
'u.lastname'=>
'Lastname',
'u.firstname'=>
'Firstname',
'd.rowid'=>
"TripId",
'd.type'=>
"Type",
'd.km'=>
"FeesKilometersOrAmout",
'd.dated'=>
"Date",
'd.note_private'=>
'NotePrivate',
'd.note_public'=>
'NotePublic',
's.nom'=>
'ThirdParty');
123 $this->export_TypeFields_array[$r] = array(
'u.rowid'=>
'List:user:name',
'u.login'=>
'Text',
'u.lastname'=>
'Text',
'u.firstname'=>
'Text',
'd.type'=>
"Text",
'd.km'=>
"Numeric",
'd.dated'=>
"Date",
'd.note_private'=>
'Text',
'd.note_public'=>
'Text',
's.rowid'=>
"Numeric",
's.nom'=>
'Text');
124 $this->export_entities_array[$r] = array(
'u.login'=>
'user',
'u.lastname'=>
'user',
'u.firstname'=>
'user',
'd.rowid'=>
"trip",
'd.type'=>
"trip",
'd.km'=>
"trip",
'd.dated'=>
"trip",
'd.note_private'=>
'trip',
'd.note_public'=>
'trip',
's.nom'=>
'company');
125 $this->export_dependencies_array[$r] = array(
'trip'=>
'd.rowid');
127 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
128 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'user as u';
129 $this->export_sql_end[$r] .=
', '.MAIN_DB_PREFIX.
'deplacement as d';
130 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON d.fk_soc = s.rowid';
131 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
132 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
134 $this->export_sql_end[$r] .=
' WHERE d.fk_user = u.rowid';
135 $this->export_sql_end[$r] .=
' AND d.entity IN ('.getEntity(
'deplacement').
')';
136 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
137 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).
' OR d.fk_soc IS NULL)';
141 $childids = $user->getAllChildIds();
142 $childids[] = $user->id;
144 if (!$user->hasRight(
'deplacement',
'readall') && !$user->hasRight(
'deplacement',
'lire_tous')) {
145 $this->export_sql_end[$r] .=
' AND d.fk_user IN ('.$this->db->sanitize(join(
',', $childids)).
')';