51 $this->numero = 63000;
54 $this->rights_class =
'resource';
58 $this->family =
"projects";
59 $this->module_position =
'20';
63 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
67 $this->
description =
"Manage resources (printers, cars, room, ...) you can then share into events";
69 $this->version =
'dolibarr';
72 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
78 $this->picto =
'resource';
83 $this->module_parts = array();
91 $this->config_page_url = array(
"resource.php");
95 $this->depends = array();
97 $this->requiredby = array(
'');
99 $this->phpmin = array(7, 0);
101 $this->langfiles = array(
"resource");
106 $this->
const = array();
138 $this->boxes = array();
150 $this->rights = array();
153 $this->rights[$r][0] = 63001;
154 $this->rights[$r][1] =
'Read resources';
155 $this->rights[$r][3] = 0;
156 $this->rights[$r][4] =
'read';
159 $this->rights[$r][0] = 63002;
160 $this->rights[$r][1] =
'Create/Modify resources';
161 $this->rights[$r][3] = 0;
162 $this->rights[$r][4] =
'write';
165 $this->rights[$r][0] = 63003;
166 $this->rights[$r][1] =
'Delete resources';
167 $this->rights[$r][3] = 0;
168 $this->rights[$r][4] =
'delete';
171 $this->rights[$r][0] = 63004;
172 $this->rights[$r][1] =
'Link resources to agenda events';
173 $this->rights[$r][3] = 0;
174 $this->rights[$r][4] =
'link';
184 $this->menu = array();
188 $this->menu[$r] = array(
189 'fk_menu' =>
'fk_mainmenu=agenda',
191 'titre' =>
'MenuResourceIndex',
192 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth em92"'),
193 'mainmenu' =>
'agenda',
194 'leftmenu' =>
'resource',
195 'url' =>
'/resource/list.php',
196 'langs' =>
'resource',
199 'perms' =>
'$user->rights->resource->read',
204 $this->menu[$r++] = array(
205 'fk_menu' =>
'fk_mainmenu=agenda,fk_leftmenu=resource',
207 'titre' =>
'MenuResourceAdd',
208 'mainmenu' =>
'agenda',
209 'leftmenu' =>
'resource_add',
210 'url' =>
'/resource/card.php?action=create',
211 'langs' =>
'resource',
214 'perms' =>
'$user->rights->resource->write',
219 $this->menu[$r++] = array(
220 'fk_menu' =>
'fk_mainmenu=agenda,fk_leftmenu=resource',
223 'mainmenu' =>
'agenda',
224 'leftmenu' =>
'resource_list',
225 'url' =>
'/resource/list.php',
226 'langs' =>
'resource',
229 'perms' =>
'$user->rights->resource->read',
240 $this->export_code[$r] = $this->rights_class.
'_'.$r;
241 $this->export_label[$r] =
"ResourceSingular";
242 $this->export_permission[$r] = array(array(
"resource",
"read"));
244 $this->export_fields_array[$r] = array(
'r.rowid' =>
'IdResource',
'r.ref' =>
'ResourceFormLabel_ref',
'c.rowid' =>
'ResourceTypeID',
'c.code' =>
'ResourceTypeCode',
'c.label' =>
'ResourceTypeLabel',
'r.description' =>
'ResourceFormLabel_description',
'r.note_private' =>
"NotePrivate",
'r.note_public' =>
"NotePublic",
'r.asset_number' =>
'AssetNumber',
'r.datec' =>
"DateCreation",
'r.tms' =>
"DateLastModification");
245 $this->export_TypeFields_array[$r] = array(
'r.rowid' =>
'List:resource:ref',
'r.ref' =>
'Text',
'r.asset_number' =>
'Text',
'r.description' =>
'Text',
'c.rowid' =>
'List:c_type_resource:label',
'c.code' =>
'Text',
'c.label' =>
'Text',
'r.datec' =>
'Date',
'r.tms' =>
'Date',
'r.note_private' =>
'Text',
'r.note_public' =>
'Text');
246 $this->export_entities_array[$r] = array(
'r.rowid' =>
'resource',
'r.ref' =>
'resource',
'c.rowid' =>
'resource',
'c.code' =>
'resource',
'c.label' =>
'resource',
'r.description' =>
'resource',
'r.note_private' =>
"resource",
'r.resource' =>
"resource",
'r.asset_number' =>
'resource',
'r.datec' =>
"resource",
'r.tms' =>
"resource");
248 $keyforselect =
'resource';
249 $keyforelement =
'resource';
250 $keyforaliasextra =
'extra';
252 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
254 $this->export_dependencies_array[$r] = array(
'resource' => array(
'r.rowid'));
255 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
256 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'resource as r';
257 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_type_resource as c ON c.code = r.fk_code_type_resource';
258 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'resource_extrafields as extra ON extra.fk_object = r.rowid';
259 $this->export_sql_end[$r] .=
' WHERE r.entity IN ('.getEntity(
'resource').
')';
269 $this->import_code[$r] = $this->rights_class.
'_'.$r;
270 $this->import_label[$r] =
'ImportDataset_resource_1';
271 $this->import_icon[$r] =
'resource';
272 $this->import_entities_array[$r] = array();
273 $this->import_tables_array[$r] = array(
'r' => MAIN_DB_PREFIX.
'resource',
'extra' => MAIN_DB_PREFIX.
'resource_extrafields');
274 $this->import_fields_array[$r] = array(
'r.ref' =>
"ResourceFormLabel_ref*",
'r.fk_code_type_resource' =>
'ResourceTypeCode',
'r.description' =>
'ResourceFormLabel_description',
'r.note_private' =>
"NotePrivate",
'r.note_public' =>
"NotePublic",
'r.asset_number' =>
'AssetNumber',
'r.datec' =>
'DateCreation');
276 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'resource' AND entity IN (0,".
$conf->entity.
")";
277 $resql = $this->db->query($sql);
279 while ($obj = $this->db->fetch_object($resql)) {
280 $fieldname =
'extra.'.$obj->name;
281 $fieldlabel = ucfirst($obj->label);
282 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
286 $this->import_fieldshidden_array[$r] = array(
'r.fk_user_author' =>
'user->id',
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'resource');
287 $this->import_convertvalue_array[$r] = array(
288 'r.fk_code_type_resource' => array(
'rule' =>
'fetchidfromcodeorlabel',
'classfile' =>
'/core/class/ctyperesource.class.php',
'class' =>
'Ctyperesource',
'method' =>
'fetch',
'dict' =>
'DictionaryResourceType'),
291 $this->import_regex_array[$r] = array(
's.datec' =>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
292 $this->import_examplevalues_array[$r] = array(
'r.ref' =>
"REF1",
'r.fk_code_type_resource' =>
"Code from dictionary resource type",
'r.datec' =>
"2017-01-01 or 2017-01-01 12:30:00");
293 $this->import_updatekeys_array[$r] = array(
'r.rf' =>
'ResourceFormLabel_ref');