dolibarr 21.0.0-alpha
modPartnership.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2018-2019 Nicolas ZABOURI <info@inovea-conseil.com>
4 * Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2021 Dorian Laurent <i.merraha@sofimedmaroc.com>
6 * Copyright (C) 2021 NextGestion <contact@nextgestion.com>
7 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
31include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
32
39{
45 public function __construct($db)
46 {
47 global $langs, $conf;
48 $this->db = $db;
49
50 // Id for module (must be unique).
51 // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
52 $this->numero = 58000;
53
54 // Key text used to identify module (for permissions, menus, etc...)
55 $this->rights_class = 'partnership';
56
57 // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
58 // It is used to group modules by family in module setup page
59 $this->family = "crm";
60
61 // Module position in the family on 2 digits ('01', '10', '20', ...)
62 $this->module_position = '90';
63
64 // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
65 //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
66 // Module label (no space allowed), used if translation string 'ModulePartnershipName' not found (Partnership is name of module).
67 $this->name = preg_replace('/^mod/i', '', get_class($this));
68
69 // Module description, used if translation string 'ModulePartnershipDesc' not found (Partnership is name of module).
70 $this->description = "PartnershipDescription";
71 // Used only if file README.md and README-LL.md not found.
72 $this->descriptionlong = "PartnershipDescriptionLong";
73
74 // // Author
75 // $this->editor_name = 'Editor name';
76 // $this->editor_url = 'https://www.example.com';
77
78 // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
79 $this->version = 'dolibarr';
80 // Url to the file with your last numberversion of this module
81 //$this->url_last_version = 'http://www.example.com/versionmodule.txt';
82
83 // Key used in llx_const table to save module status enabled/disabled (where PARTNERSHIP is value of property name of module in uppercase)
84 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
85
86 // Name of image file used for this module.
87 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
88 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
89 // To use a supported fa-xxx css style of font awesome, use this->picto='xxx'
90 $this->picto = 'partnership';
91
92 // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
93 $this->module_parts = array(
94 // Set this to 1 if module has its own trigger directory (core/triggers)
95 'triggers' => 0,
96 // Set this to 1 if module has its own login method file (core/login)
97 'login' => 0,
98 // Set this to 1 if module has its own substitution function file (core/substitutions)
99 'substitutions' => 0,
100 // Set this to 1 if module has its own menus handler directory (core/menus)
101 'menus' => 0,
102 // Set this to 1 if module overwrite template dir (core/tpl)
103 'tpl' => 0,
104 // Set this to 1 if module has its own barcode directory (core/modules/barcode)
105 'barcode' => 0,
106 // Set this to 1 if module has its own models directory (core/modules/xxx)
107 'models' => 1,
108 // Set this to 1 if module has its own printing directory (core/modules/printing)
109 'printing' => 0,
110 // Set this to 1 if module has its own theme directory (theme)
111 'theme' => 0,
112 // Set this to relative path of css file if module has its own css file
113 'css' => array(
114 // '/partnership/css/partnership.css.php',
115 ),
116 // Set this to relative path of js file if module must load a js on all pages
117 'js' => array(
118 // '/partnership/js/partnership.js.php',
119 ),
120 // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
121 'hooks' => array(
122 // 'data' => array(
123 // 'hookcontext1',
124 // 'hookcontext2',
125 // ),
126 // 'entity' => '0',
127 ),
128 // Set this to 1 if features of module are opened to external users
129 'moduleforexternal' => 0,
130 );
131
132 // Data directories to create when module is enabled.
133 // Example: this->dirs = array("/partnership/temp","/partnership/subdir");
134 $this->dirs = array("/partnership/temp");
135
136 // Config pages. Put here list of php page, stored into partnership/admin directory, to use to setup module.
137 $this->config_page_url = array("setup.php@partnership");
138
139 // Dependencies
140 // A condition to hide module
141 $this->hidden = false;
142 // List of module class names as string that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR'...))
143 $this->depends = array();
144 $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
145 $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
146
147 // The language file dedicated to your module
148 $this->langfiles = array("partnership");
149
150 // Prerequisites
151 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
152 $this->need_dolibarr_version = array(11, -3); // Minimum version of Dolibarr required by module
153
154 // Messages at activation
155 $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
156 $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
157 //$this->automatic_activation = array('FR'=>'PartnershipWasAutomaticallyActivatedBecauseOfYourCountryChoice');
158 //$this->always_enabled = true; // If true, can't be disabled
159
160 // Constants
161 // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
162 // Example: $this->const=array(1 => array('PARTNERSHIP_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
163 // 2 => array('PARTNERSHIP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
164 // );
165 $this->const = array();
166
167 // Some keys to add into the overwriting translation tables
168 /*$this->overwrite_translation = array(
169 'en_US:ParentCompany'=>'Parent company or reseller',
170 'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
171 )*/
172
173 if (!isset($conf->partnership) || !isset($conf->partnership->enabled)) {
174 $conf->partnership = new stdClass();
175 $conf->partnership->enabled = 0;
176 }
177
178 // Array to add new pages in new tabs
179 $this->tabs = array();
180
181 $tabtoadd = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty');
182 if ($tabtoadd == 'member') {
183 $fk_mainmenu = "members";
184 } else {
185 $fk_mainmenu = "companies";
186 }
187
188 // Example:
189 // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@partnership:$user->rights->partnership->read:/partnership/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
190 // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@partnership:$user->rights->othermodule->read:/partnership/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
191 // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
192 //
193 // Where objecttype can be
194 // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
195 // 'contact' to add a tab in contact view
196 // 'contract' to add a tab in contract view
197 // 'group' to add a tab in group view
198 // 'intervention' to add a tab in intervention view
199 // 'invoice' to add a tab in customer invoice view
200 // 'invoice_supplier' to add a tab in supplier invoice view
201 // 'member' to add a tab in foundation member view
202 // 'opensurveypoll' to add a tab in opensurvey poll view
203 // 'order' to add a tab in sales order view
204 // 'order_supplier' to add a tab in supplier order view
205 // 'payment' to add a tab in payment view
206 // 'payment_supplier' to add a tab in supplier payment view
207 // 'product' to add a tab in product view
208 // 'propal' to add a tab in propal view
209 // 'project' to add a tab in project view
210 // 'stock' to add a tab in stock view
211 // 'thirdparty' to add a tab in third party view
212 // 'user' to add a tab in user view
213
214 // Dictionaries
215 $this->dictionaries = array(
216 'langs' => 'partnership',
217 // List of tables we want to see into dictionary editor
218 'tabname' => array("c_partnership_type"),
219 // Label of tables
220 'tablib' => array("PartnershipType"),
221 // Request to select fields
222 'tabsql' => array('SELECT f.rowid as rowid, f.code, f.label, f.keyword, f.active FROM '.MAIN_DB_PREFIX.'c_partnership_type as f WHERE f.entity = '.((int) $conf->entity)),
223 // Sort order
224 'tabsqlsort' => array("label ASC"),
225 // List of fields (result of select to show dictionary)
226 'tabfield' => array("code,label,keyword"),
227 // List of fields (list of fields to edit a record)
228 'tabfieldvalue' => array("code,label,keyword"),
229 // List of fields (list of fields for insert)
230 'tabfieldinsert' => array("code,label,keyword"),
231 // Name of columns with primary key (try to always name it 'rowid')
232 'tabrowid' => array("rowid"),
233 // Condition to show each dictionary
234 'tabcond' => array($conf->partnership->enabled),
235 // Help tooltip for each fields of the dictionary
236 'tabhelp' => array(array('keyword' => $langs->trans('KeywordToCheckInWebsite')))
237 );
238
239 // Boxes/Widgets
240 // Add here list of php file(s) stored in partnership/core/boxes that contains a class to show a widget.
241 $this->boxes = array(
242 // 0 => array(
243 // 'file' => 'partnershipwidget1.php@partnership',
244 // 'note' => 'Widget provided by Partnership',
245 // 'enabledbydefaulton' => 'Home',
246 // ),
247 // ...
248 );
249
250 // Cronjobs (List of cron jobs entries to add when module is enabled)
251 // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
252
253 $arraydate = dol_getdate(dol_now());
254 $datestart = dol_mktime(21, 15, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
255
256 $this->cronjobs = array(
257 0 => array(
258 'priority' => 60,
259 'label' => 'CancelPartnershipForExpiredMembers',
260 'jobtype' => 'method',
261 'class' => '/partnership/class/partnershiputils.class.php',
262 'objectname' => 'PartnershipUtils',
263 'method' => 'doCancelStatusOfMemberPartnership',
264 'parameters' => '',
265 'comment' => 'Cancel status of partnership when subscription is expired + x days.',
266 'frequency' => 1,
267 'unitfrequency' => 86400,
268 'status' => 1,
269 'test' => 'isModEnabled("partnership")',
270 'datestart' => $datestart
271 ),
272 1 => array(
273 'priority' => 61,
274 'label' => 'PartnershipCheckBacklink',
275 'jobtype' => 'method',
276 'class' => '/partnership/class/partnershiputils.class.php',
277 'objectname' => 'PartnershipUtils',
278 'method' => 'doWarningOfPartnershipIfDolibarrBacklinkNotfound',
279 'parameters' => '',
280 'comment' => 'Add a warning on partnership record if the backlink keyword is not found on the partner website.',
281 'frequency' => 1,
282 'unitfrequency' => 86400,
283 'status' => 0,
284 'test' => 'isModEnabled("partnership")',
285 'datestart' => $datestart
286 ),
287 );
288
289 // Permissions provided by this module
290 $this->rights = array();
291 $r = 0;
292 // Add here entries to declare new permissions
293 /* BEGIN MODULEBUILDER PERMISSIONS */
294 $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
295 $this->rights[$r][1] = 'Read objects of Partnership'; // Permission label
296 $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->partnership->level1->level2)
297 $r++;
298 $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
299 $this->rights[$r][1] = 'Create/Update objects of Partnership'; // Permission label
300 $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->partnership->level1->level2)
301 $r++;
302 $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
303 $this->rights[$r][1] = 'Delete objects of Partnership'; // Permission label
304 $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->partnership->level1->level2)
305 $r++;
306 /* END MODULEBUILDER PERMISSIONS */
307
308 // Main menu entries to add
309 $this->menu = array();
310 $r = 0;
311 // Add here entries to declare new menus
312 /* BEGIN MODULEBUILDER TOPMENU */
313 // $this->menu[$r++]=array(
314 // // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
315 // 'fk_menu'=>'fk_mainmenu=partnership',
316 // // This is a Left menu entry
317 // 'type'=>'left',
318 // 'titre'=>'List Partnership',
319 // 'mainmenu'=>'partnership',
320 // 'leftmenu'=>'partnership',
321 // 'url'=>'/partnership/partnership_list.php',
322 // // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
323 // 'langs'=>'partnership',
324 // 'position'=>1100+$r,
325 // // Define condition to show or hide menu entry. Use '$conf->partnership->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
326 // 'enabled'=>'$conf->partnership->enabled',
327 // // Use 'perms'=>'$user->rights->partnership->level1->level2' if you want your menu with a permission rules
328 // 'perms'=>'1',
329 // 'target'=>'',
330 // // 0=Menu for internal users, 1=external users, 2=both
331 // 'user'=>2,
332 // );
333 $this->menu[$r++] = array(
334 'fk_menu' => 'fk_mainmenu='.$fk_mainmenu, // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
335 'type' => 'left', // This is a Top menu entry
336 'titre' => 'Partnership',
337 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
338 'mainmenu' => $fk_mainmenu,
339 'leftmenu' => 'partnership',
340 'url' => '/partnership/partnership_list.php',
341 'langs' => 'partnership', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
342 'position' => 1100 + $r,
343 'enabled' => '$conf->partnership->enabled', // Define condition to show or hide menu entry. Use '$conf->partnership->enabled' if entry must be visible if module is enabled.
344 'perms' => '$user->rights->partnership->read', // Use 'perms'=>'$user->rights->partnership->level1->level2' if you want your menu with a permission rules
345 'target' => '',
346 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
347 );
348 $this->menu[$r++] = array(
349 'fk_menu' => 'fk_mainmenu='.$fk_mainmenu.',fk_leftmenu=partnership', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
350 'type' => 'left', // This is a Left menu entry
351 'titre' => 'NewPartnership',
352 'mainmenu' => $fk_mainmenu,
353 'leftmenu' => 'partnership_new',
354 'url' => '/partnership/partnership_card.php?action=create',
355 'langs' => 'partnership', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
356 'position' => 1100 + $r,
357 'enabled' => '$conf->partnership->enabled', // Define condition to show or hide menu entry. Use '$conf->partnership->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
358 'perms' => '$user->rights->partnership->write', // Use 'perms'=>'$user->rights->partnership->level1->level2' if you want your menu with a permission rules
359 'target' => '',
360 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
361 );
362 $this->menu[$r++] = array(
363 'fk_menu' => 'fk_mainmenu='.$fk_mainmenu.',fk_leftmenu=partnership', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
364 'type' => 'left', // This is a Left menu entry
365 'titre' => 'ListOfPartnerships',
366 'mainmenu' => $fk_mainmenu,
367 'leftmenu' => 'partnership_list',
368 'url' => '/partnership/partnership_list.php',
369 'langs' => 'partnership', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
370 'position' => 1100 + $r,
371 'enabled' => '$conf->partnership->enabled', // Define condition to show or hide menu entry. Use '$conf->partnership->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
372 'perms' => '$user->rights->partnership->read', // Use 'perms'=>'$user->rights->partnership->level1->level2' if you want your menu with a permission rules
373 'target' => '',
374 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
375 );
376 /* END MODULEBUILDER LEFTMENU PARTNERSHIP */
377 // Exports profiles provided by this module
378 $r = 1;
379 /* BEGIN MODULEBUILDER EXPORT PARTNERSHIP */
380 /*
381 $langs->load("partnership");
382 $this->export_code[$r]=$this->rights_class.'_'.$r;
383 $this->export_label[$r]='PartnershipLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
384 $this->export_icon[$r]='partnership';
385 // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
386 $keyforclass = 'Partnership'; $keyforclassfile='/partnership/class/partnership.class.php'; $keyforelement='partnership';
387 include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
388 //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
389 //unset($this->export_fields_array[$r]['t.fieldtoremove']);
390 //$keyforclass = 'PartnershipLine'; $keyforclassfile='/partnership/class/partnership.class.php'; $keyforelement='partnershipline@partnership'; $keyforalias='tl';
391 //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
392 $keyforselect='partnership'; $keyforaliasextra='extra'; $keyforelement='partnership';
393 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
394 //$keyforselect='partnershipline'; $keyforaliasextra='extraline'; $keyforelement='partnershipline@partnership';
395 //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
396 //$this->export_dependencies_array[$r] = array('partnershipline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
397 //$this->export_special_array[$r] = array('t.field'=>'...');
398 //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
399 //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
400 $this->export_sql_start[$r]='SELECT DISTINCT ';
401 $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'partnership as t';
402 //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'partnership_line as tl ON tl.fk_partnership = t.rowid';
403 $this->export_sql_end[$r] .=' WHERE 1 = 1';
404 $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('partnership').')';
405 $r++; */
406 /* END MODULEBUILDER EXPORT PARTNERSHIP */
407
408 // Imports profiles provided by this module
409 $r = 1;
410 /* BEGIN MODULEBUILDER IMPORT PARTNERSHIP */
411 /*
412 $langs->load("partnership");
413 $this->export_code[$r]=$this->rights_class.'_'.$r;
414 $this->export_label[$r]='PartnershipLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
415 $this->export_icon[$r]='partnership';
416 $keyforclass = 'Partnership'; $keyforclassfile='/partnership/class/partnership.class.php'; $keyforelement='partnership';
417 include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
418 $keyforselect='partnership'; $keyforaliasextra='extra'; $keyforelement='partnership';
419 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
420 //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
421 $this->export_sql_start[$r]='SELECT DISTINCT ';
422 $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'partnership as t';
423 $this->export_sql_end[$r] .=' WHERE 1 = 1';
424 $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('partnership').')';
425 $r++; */
426 /* END MODULEBUILDER IMPORT PARTNERSHIP */
427 }
428
437 public function init($options = '')
438 {
439 global $conf, $langs;
440
441 $result = $this->_load_tables('/install/mysql/', 'partnership');
442 if ($result < 0) {
443 return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
444 }
445
446 // Create extrafields during init
447 //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
448 //$extrafields = new ExtraFields($this->db);
449 //$result1=$extrafields->addExtraField('partnership_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'partnership', '$conf->partnership->enabled');
450 //$result2=$extrafields->addExtraField('partnership_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'partnership', '$conf->partnership->enabled');
451 //$result3=$extrafields->addExtraField('partnership_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'partnership', '$conf->partnership->enabled');
452 //$result4=$extrafields->addExtraField('partnership_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'partnership', '$conf->partnership->enabled');
453 //$result5=$extrafields->addExtraField('partnership_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'partnership', '$conf->partnership->enabled');
454
455 // Permissions
456 $this->remove($options);
457
458 $sql = array();
459
460 // Document templates
461 $moduledir = dol_sanitizeFileName('partnership');
462 $myTmpObjects = array();
463 $myTmpObjects['Partnership'] = array('includerefgeneration' => 0, 'includedocgeneration' => 0);
464
465 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
466 if ($myTmpObjectArray['includerefgeneration']) {
467 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_partnerships.odt';
468 $dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir;
469 $dest = $dirodt.'/template_partnerships.odt';
470
471 if (file_exists($src) && !file_exists($dest)) {
472 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
473 dol_mkdir($dirodt);
474 $result = dol_copy($src, $dest, '0', 0);
475 if ($result < 0) {
476 $langs->load("errors");
477 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
478 return 0;
479 }
480 }
481
482 $sql = array_merge($sql, array(
483 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".((int) $conf->entity),
484 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".strtolower($myTmpObjectKey)."',".((int) $conf->entity).")",
485 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".((int) $conf->entity),
486 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".strtolower($myTmpObjectKey)."', ".((int) $conf->entity).")"
487 ));
488 }
489 }
490
491 return $this->_init($sql, $options);
492 }
493
502 public function remove($options = '')
503 {
504 $sql = array();
505 return $this->_remove($sql, $options);
506 }
507}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Description and activation class for module Partnership This module is base on this specification : h...
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_now($mode='auto')
Return date for now.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140