50 $this->numero = 63000;
53 $this->rights_class =
'resource';
57 $this->family =
"projects";
58 $this->module_position =
'20';
62 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
66 $this->
description =
"Manage resources (printers, cars, room, ...) you can then share into events";
68 $this->version =
'dolibarr';
71 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
77 $this->picto =
'resource';
82 $this->module_parts = array();
90 $this->config_page_url = array(
"resource.php");
94 $this->depends = array();
96 $this->requiredby = array(
'modPlace');
98 $this->phpmin = array(7, 0);
100 $this->langfiles = array(
"resource");
105 $this->
const = array();
137 $this->boxes = array();
149 $this->rights = array();
152 $this->rights[$r][0] = 63001;
153 $this->rights[$r][1] =
'Read resources';
154 $this->rights[$r][3] = 0;
155 $this->rights[$r][4] =
'read';
158 $this->rights[$r][0] = 63002;
159 $this->rights[$r][1] =
'Create/Modify resources';
160 $this->rights[$r][3] = 0;
161 $this->rights[$r][4] =
'write';
164 $this->rights[$r][0] = 63003;
165 $this->rights[$r][1] =
'Delete resources';
166 $this->rights[$r][3] = 0;
167 $this->rights[$r][4] =
'delete';
170 $this->rights[$r][0] = 63004;
171 $this->rights[$r][1] =
'Link resources to agenda events';
172 $this->rights[$r][3] = 0;
173 $this->rights[$r][4] =
'link';
183 $this->menu = array();
187 $this->menu[$r] = array(
188 'fk_menu'=>
'fk_mainmenu=agenda',
190 'titre'=>
'MenuResourceIndex',
191 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth em92"'),
192 'mainmenu'=>
'agenda',
193 'leftmenu'=>
'resource',
194 'url'=>
'/resource/list.php',
195 'langs'=>
'resource',
198 'perms'=>
'$user->rights->resource->read',
203 $this->menu[$r++] = array(
204 'fk_menu'=>
'fk_mainmenu=agenda,fk_leftmenu=resource',
206 'titre'=>
'MenuResourceAdd',
207 'mainmenu'=>
'agenda',
208 'leftmenu'=>
'resource_add',
209 'url'=>
'/resource/card.php?action=create',
210 'langs'=>
'resource',
213 'perms'=>
'$user->rights->resource->write',
218 $this->menu[$r++] = array(
219 'fk_menu'=>
'fk_mainmenu=agenda,fk_leftmenu=resource',
222 'mainmenu'=>
'agenda',
223 'leftmenu'=>
'resource_list',
224 'url'=>
'/resource/list.php',
225 'langs'=>
'resource',
228 'perms'=>
'$user->rights->resource->read',
239 $this->export_code[$r] = $this->rights_class.
'_'.$r;
240 $this->export_label[$r] =
"ResourceSingular";
241 $this->export_permission[$r] = array(array(
"resource",
"read"));
243 $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");
244 $this->export_TypeFields_array[$r] = array(
'r.rowid'=>
'List:resource:ref',
'r.ref'=>
'Text',
'r.asset_number'=>
'Text',
'r.description'=>
'Text',
'c.code'=>
'Text',
'c.label'=>
'List:c_type_resource:label',
'r.datec'=>
'Date',
'r.tms'=>
'Date',
'r.note_private'=>
'Text',
'r.note_public'=>
'Text');
245 $this->export_entities_array[$r] = array(
'r.rowid'=>
'resource',
'r.ref'=>
'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");
247 $keyforselect =
'resource';
248 $keyforelement =
'resource';
249 $keyforaliasextra =
'extra';
251 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
253 $this->export_dependencies_array[$r] = array(
'resource'=>array(
'r.rowid'));
254 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
255 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'resource as r';
256 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_type_resource as c ON c.code = r.fk_code_type_resource';
257 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'resource_extrafields as extra ON extra.fk_object = r.rowid';
258 $this->export_sql_end[$r] .=
' WHERE r.entity IN ('.getEntity(
'resource').
')';
268 $this->import_code[$r] = $this->rights_class.
'_'.$r;
269 $this->import_label[$r] =
'ImportDataset_resource_1';
270 $this->import_icon[$r] =
'resource';
271 $this->import_entities_array[$r] = array();
272 $this->import_tables_array[$r] = array(
'r'=>MAIN_DB_PREFIX.
'resource',
'extra'=>MAIN_DB_PREFIX.
'resource_extrafields');
273 $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');
275 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'resource' AND entity IN (0,".$conf->entity.
")";
276 $resql = $this->db->query($sql);
278 while ($obj = $this->db->fetch_object($resql)) {
279 $fieldname =
'extra.'.$obj->name;
280 $fieldlabel = ucfirst($obj->label);
281 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
285 $this->import_fieldshidden_array[$r] = array(
'r.fk_user_author'=>
'user->id',
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'resource');
286 $this->import_convertvalue_array[$r] = array(
287 'r.fk_code_type_resource'=>array(
'rule'=>
'fetchidfromcodeorlabel',
'classfile'=>
'/core/class/ctyperesource.class.php',
'class'=>
'Ctyperesource',
'method'=>
'fetch',
'dict'=>
'DictionaryResourceType'),
290 $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])?$');
291 $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");
292 $this->import_updatekeys_array[$r] = array(
'r.rf'=>
'ResourceFormLabel_ref');