Browse Source

SQL OK, ORM models OK, pages/admin links OK

master
Ghislain Loaec 5 years ago
parent
commit
66bc5d8c44

+ 12
- 12
admin/about.php View File

@@ -18,7 +18,7 @@
18 18
 
19 19
 /**
20 20
  * 	\file		admin/about.php
21
- * 	\ingroup	mymodule
21
+ * 	\ingroup	photocopies
22 22
  * 	\brief		This file is an example about page
23 23
  * 				Put some comments here
24 24
  */
@@ -31,14 +31,14 @@ if (! $res) {
31 31
 
32 32
 // Libraries
33 33
 require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
34
-require_once '../lib/mymodule.lib.php';
34
+require_once '../lib/photocopies.lib.php';
35 35
 
36
-dol_include_once('/mymodule/lib/php-markdown/markdown.php');
36
+dol_include_once('/photocopies/lib/php-markdown/markdown.php');
37 37
 
38 38
 
39 39
 //require_once "../class/myclass.class.php";
40 40
 // Translations
41
-$langs->load("mymodule@mymodule");
41
+$langs->load("photocopies@photocopies");
42 42
 
43 43
 // Access control
44 44
 if (! $user->admin) {
@@ -55,7 +55,7 @@ $action = GETPOST('action', 'alpha');
55 55
 /*
56 56
  * View
57 57
  */
58
-$page_name = "MyModuleAbout";
58
+$page_name = "PhotocopiesAbout";
59 59
 llxHeader('', $langs->trans($page_name));
60 60
 
61 61
 // Subheader
@@ -64,26 +64,26 @@ $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">'
64 64
 print_fiche_titre($langs->trans($page_name), $linkback);
65 65
 
66 66
 // Configuration header
67
-$head = mymoduleAdminPrepareHead();
67
+$head = photocopiesAdminPrepareHead();
68 68
 dol_fiche_head(
69 69
     $head,
70 70
     'about',
71
-    $langs->trans("Module10000Name"),
71
+    $langs->trans("Module6182Name"),
72 72
     0,
73
-    'mymodule@mymodule'
73
+    'photocopies@photocopies'
74 74
 );
75 75
 
76 76
 // About page goes here
77
-echo $langs->trans("MyModuleAboutPage");
77
+echo $langs->trans("PhotocopiesAboutPage");
78 78
 
79 79
 echo '<br>';
80 80
 
81
-$buffer = file_get_contents(dol_buildpath('/mymodule/README.md', 0));
81
+$buffer = file_get_contents(dol_buildpath('/photocopies/README.md', 0));
82 82
 echo Markdown($buffer);
83 83
 
84 84
 echo '<br>',
85
-'<a href="' . dol_buildpath('/mymodule/COPYING', 1) . '">',
86
-'<img src="' . dol_buildpath('/mymodule/img/gplv3.png', 1) . '"/>',
85
+'<a href="' . dol_buildpath('/photocopies/COPYING', 1) . '">',
86
+'<img src="' . dol_buildpath('/photocopies/img/gplv3.png', 1) . '"/>',
87 87
 '</a>';
88 88
 
89 89
 llxFooter();

admin/admin_mymodule.php → admin/admin_photocopies.php View File

@@ -17,8 +17,8 @@
17 17
  */
18 18
 
19 19
 /**
20
- * 	\file		admin/mymodule.php
21
- * 	\ingroup	mymodule
20
+ * 	\file		admin/photocopies.php
21
+ * 	\ingroup	photocopies
22 22
  * 	\brief		This file is an example module setup page
23 23
  * 				Put some comments here
24 24
  */
@@ -31,10 +31,10 @@ if (! $res) {
31 31
 
32 32
 // Libraries
33 33
 require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
34
-require_once '../lib/mymodule.lib.php';
34
+require_once '../lib/photocopies.lib.php';
35 35
 //require_once "../class/myclass.class.php";
36 36
 // Translations
37
-$langs->load("mymodule@mymodule");
37
+$langs->load("photocopies@photocopies");
38 38
 
39 39
 // Access control
40 40
 if (! $user->admin) {
@@ -51,7 +51,7 @@ $action = GETPOST('action', 'alpha');
51 51
 /*
52 52
  * View
53 53
  */
54
-$page_name = "MyModuleSetup";
54
+$page_name = "PhotocopiesSetup";
55 55
 llxHeader('', $langs->trans($page_name));
56 56
 
57 57
 // Subheader
@@ -60,17 +60,17 @@ $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">'
60 60
 print_fiche_titre($langs->trans($page_name), $linkback);
61 61
 
62 62
 // Configuration header
63
-$head = mymoduleAdminPrepareHead();
63
+$head = photocopiesAdminPrepareHead();
64 64
 dol_fiche_head(
65 65
     $head,
66 66
     'settings',
67
-    $langs->trans("Module10000Name"),
67
+    $langs->trans("Module6182Name"),
68 68
     0,
69
-    "mymodule@mymodule"
69
+    "photocopies@photocopies"
70 70
 );
71 71
 
72 72
 // Setup page goes here
73
-echo $langs->trans("MyModuleSetupPage");
73
+echo $langs->trans("PhotocopiesSetupPage");
74 74
 
75 75
 llxFooter();
76 76
 

+ 6
- 6
build/makepack-mymodule.conf View File

@@ -12,20 +12,20 @@ index.php
12 12
 mypage.php
13 13
 admin/mysetuppage.php
14 14
 class/myclass.class.php
15
-core/modules/modMyModule.class.php
15
+core/modules/modPhotocopies.class.php
16 16
 core/triggers/interface_99_modMyModule_Mytrigger.class.php
17 17
 css/mycss.css.php
18 18
 docs/index.php
19 19
 img/gplv3.png
20
-img/object_mymodule.png
20
+img/object_photocopies.png
21 21
 includes/boxes/mybox.php
22 22
 js/myjs.js
23
-langs/en_US/mymodule.lang
24
-langs/fr_FR/mymodule.lang
25
-lib/mymodule.lib.php
23
+langs/en_US/photocopies.lang
24
+langs/fr_FR/photocopies.lang
25
+lib/photocopies.lib.php
26 26
 scripts/myscript.php
27 27
 sql/data.sql
28 28
 sql/llx_mytable.key.sql
29 29
 sql/llx_mytable.sql
30 30
 themes/mytheme/index.php
31
-tpl/mytemplate.tpl.php
31
+tpl/mytemplate.tpl.php

+ 429
- 0
class/phcp.class.php View File

@@ -0,0 +1,429 @@
1
+<?php
2
+/* Copyright (C) 2007-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
3
+ * Copyright (C) ---Put here your own copyright and developer email---
4
+ *
5
+ * This program is free software; you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation; either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+/**
20
+ *  \file       dev/skeletons/phcp.class.php
21
+ *  \ingroup    mymodule othermodule1 othermodule2
22
+ *  \brief      This file is an example for a CRUD class file (Create/Read/Update/Delete)
23
+ *				Initialy built by build_class_from_table on 2013-09-12 16:46
24
+ */
25
+
26
+// Put here all includes required by your class file
27
+require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
28
+//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
29
+//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
30
+
31
+
32
+/**
33
+ *	Put here description of your class
34
+ */
35
+class Phcp extends CommonObject
36
+{
37
+	var $db;							//!< To store db handler
38
+	var $error;							//!< To return error code (or message)
39
+	var $errors=array();				//!< To return several error codes (or messages)
40
+	var $element='phcp';			//!< Id that identify managed objects
41
+	var $table_element='phcp';		//!< Name of table without prefix where object is stored
42
+
43
+    var $id;
44
+    
45
+	var $phcp_number;
46
+	var $entity;
47
+	var $nom;
48
+	var $ref_ext;
49
+	var $ref_int;
50
+	var $fk_phcp_type;
51
+
52
+    
53
+
54
+
55
+    /**
56
+     *  Constructor
57
+     *
58
+     *  @param	DoliDb		$db      Database handler
59
+     */
60
+    function __construct($db)
61
+    {
62
+        $this->db = $db;
63
+        return 1;
64
+    }
65
+
66
+
67
+    /**
68
+     *  Create object into database
69
+     *
70
+     *  @param	User	$user        User that creates
71
+     *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
72
+     *  @return int      		   	 <0 if KO, Id of created object if OK
73
+     */
74
+    function create($user, $notrigger=0)
75
+    {
76
+    	global $conf, $langs;
77
+		$error=0;
78
+
79
+		// Clean parameters
80
+        
81
+		if (isset($this->phcp_number)) $this->phcp_number=trim($this->phcp_number);
82
+		if (isset($this->entity)) $this->entity=trim($this->entity);
83
+		if (isset($this->nom)) $this->nom=trim($this->nom);
84
+		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
85
+		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
86
+		if (isset($this->fk_phcp_type)) $this->fk_phcp_type=trim($this->fk_phcp_type);
87
+
88
+        
89
+
90
+		// Check parameters
91
+		// Put here code to add control on parameters values
92
+
93
+        // Insert request
94
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."phcp(";
95
+		
96
+		$sql.= "phcp_number,";
97
+		$sql.= "entity,";
98
+		$sql.= "nom,";
99
+		$sql.= "ref_ext,";
100
+		$sql.= "ref_int,";
101
+		$sql.= "fk_phcp_type";
102
+
103
+		
104
+        $sql.= ") VALUES (";
105
+        
106
+		$sql.= " ".(! isset($this->phcp_number)?'NULL':"'".$this->db->escape($this->phcp_number)."'").",";
107
+		$sql.= " ".(! isset($this->entity)?'NULL':"'".$this->entity."'").",";
108
+		$sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").",";
109
+		$sql.= " ".(! isset($this->ref_ext)?'NULL':"'".$this->db->escape($this->ref_ext)."'").",";
110
+		$sql.= " ".(! isset($this->ref_int)?'NULL':"'".$this->db->escape($this->ref_int)."'").",";
111
+		$sql.= " ".(! isset($this->fk_phcp_type)?'NULL':"'".$this->fk_phcp_type."'")."";
112
+
113
+        
114
+		$sql.= ")";
115
+
116
+		$this->db->begin();
117
+
118
+	   	dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
119
+        $resql=$this->db->query($sql);
120
+    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
121
+
122
+		if (! $error)
123
+        {
124
+            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."phcp");
125
+
126
+			if (! $notrigger)
127
+			{
128
+	            // Uncomment this and change MYOBJECT to your own tag if you
129
+	            // want this action calls a trigger.
130
+
131
+	            //// Call triggers
132
+	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
133
+	            //$interface=new Interfaces($this->db);
134
+	            //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
135
+	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
136
+	            //// End call triggers
137
+			}
138
+        }
139
+
140
+        // Commit or rollback
141
+        if ($error)
142
+		{
143
+			foreach($this->errors as $errmsg)
144
+			{
145
+	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
146
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
147
+			}
148
+			$this->db->rollback();
149
+			return -1*$error;
150
+		}
151
+		else
152
+		{
153
+			$this->db->commit();
154
+            return $this->id;
155
+		}
156
+    }
157
+
158
+
159
+    /**
160
+     *  Load object in memory from the database
161
+     *
162
+     *  @param	int		$id    Id object
163
+     *  @return int          	<0 if KO, >0 if OK
164
+     */
165
+    function fetch($id)
166
+    {
167
+    	global $langs;
168
+        $sql = "SELECT";
169
+		$sql.= " t.rowid,";
170
+		
171
+		$sql.= " t.phcp_number,";
172
+		$sql.= " t.entity,";
173
+		$sql.= " t.nom,";
174
+		$sql.= " t.ref_ext,";
175
+		$sql.= " t.ref_int,";
176
+		$sql.= " t.fk_phcp_type";
177
+
178
+		
179
+        $sql.= " FROM ".MAIN_DB_PREFIX."phcp as t";
180
+        $sql.= " WHERE t.rowid = ".$id;
181
+
182
+    	dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
183
+        $resql=$this->db->query($sql);
184
+        if ($resql)
185
+        {
186
+            if ($this->db->num_rows($resql))
187
+            {
188
+                $obj = $this->db->fetch_object($resql);
189
+
190
+                $this->id    = $obj->rowid;
191
+                
192
+				$this->phcp_number = $obj->phcp_number;
193
+				$this->entity = $obj->entity;
194
+				$this->nom = $obj->nom;
195
+				$this->ref_ext = $obj->ref_ext;
196
+				$this->ref_int = $obj->ref_int;
197
+				$this->fk_phcp_type = $obj->fk_phcp_type;
198
+
199
+                
200
+            }
201
+            $this->db->free($resql);
202
+
203
+            return 1;
204
+        }
205
+        else
206
+        {
207
+      	    $this->error="Error ".$this->db->lasterror();
208
+            dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
209
+            return -1;
210
+        }
211
+    }
212
+
213
+
214
+    /**
215
+     *  Update object into database
216
+     *
217
+     *  @param	User	$user        User that modifies
218
+     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
219
+     *  @return int     		   	 <0 if KO, >0 if OK
220
+     */
221
+    function update($user=0, $notrigger=0)
222
+    {
223
+    	global $conf, $langs;
224
+		$error=0;
225
+
226
+		// Clean parameters
227
+        
228
+		if (isset($this->phcp_number)) $this->phcp_number=trim($this->phcp_number);
229
+		if (isset($this->entity)) $this->entity=trim($this->entity);
230
+		if (isset($this->nom)) $this->nom=trim($this->nom);
231
+		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
232
+		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
233
+		if (isset($this->fk_phcp_type)) $this->fk_phcp_type=trim($this->fk_phcp_type);
234
+
235
+        
236
+
237
+		// Check parameters
238
+		// Put here code to add a control on parameters values
239
+
240
+        // Update request
241
+        $sql = "UPDATE ".MAIN_DB_PREFIX."phcp SET";
242
+        
243
+		$sql.= " phcp_number=".(isset($this->phcp_number)?"'".$this->db->escape($this->phcp_number)."'":"null").",";
244
+		$sql.= " entity=".(isset($this->entity)?$this->entity:"null").",";
245
+		$sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").",";
246
+		$sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").",";
247
+		$sql.= " ref_int=".(isset($this->ref_int)?"'".$this->db->escape($this->ref_int)."'":"null").",";
248
+		$sql.= " fk_phcp_type=".(isset($this->fk_phcp_type)?$this->fk_phcp_type:"null")."";
249
+
250
+        
251
+        $sql.= " WHERE rowid=".$this->id;
252
+
253
+		$this->db->begin();
254
+
255
+		dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
256
+        $resql = $this->db->query($sql);
257
+    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
258
+
259
+		if (! $error)
260
+		{
261
+			if (! $notrigger)
262
+			{
263
+	            // Uncomment this and change MYOBJECT to your own tag if you
264
+	            // want this action calls a trigger.
265
+
266
+	            //// Call triggers
267
+	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
268
+	            //$interface=new Interfaces($this->db);
269
+	            //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
270
+	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
271
+	            //// End call triggers
272
+	    	}
273
+		}
274
+
275
+        // Commit or rollback
276
+		if ($error)
277
+		{
278
+			foreach($this->errors as $errmsg)
279
+			{
280
+	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
281
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
282
+			}
283
+			$this->db->rollback();
284
+			return -1*$error;
285
+		}
286
+		else
287
+		{
288
+			$this->db->commit();
289
+			return 1;
290
+		}
291
+    }
292
+
293
+
294
+ 	/**
295
+	 *  Delete object in database
296
+	 *
297
+     *	@param  User	$user        User that deletes
298
+     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
299
+	 *  @return	int					 <0 if KO, >0 if OK
300
+	 */
301
+	function delete($user, $notrigger=0)
302
+	{
303
+		global $conf, $langs;
304
+		$error=0;
305
+
306
+		$this->db->begin();
307
+
308
+		if (! $error)
309
+		{
310
+			if (! $notrigger)
311
+			{
312
+				// Uncomment this and change MYOBJECT to your own tag if you
313
+		        // want this action calls a trigger.
314
+
315
+		        //// Call triggers
316
+		        //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
317
+		        //$interface=new Interfaces($this->db);
318
+		        //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
319
+		        //if ($result < 0) { $error++; $this->errors=$interface->errors; }
320
+		        //// End call triggers
321
+			}
322
+		}
323
+
324
+		if (! $error)
325
+		{
326
+    		$sql = "DELETE FROM ".MAIN_DB_PREFIX."phcp";
327
+    		$sql.= " WHERE rowid=".$this->id;
328
+
329
+    		dol_syslog(get_class($this)."::delete sql=".$sql);
330
+    		$resql = $this->db->query($sql);
331
+        	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
332
+		}
333
+
334
+        // Commit or rollback
335
+		if ($error)
336
+		{
337
+			foreach($this->errors as $errmsg)
338
+			{
339
+	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
340
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
341
+			}
342
+			$this->db->rollback();
343
+			return -1*$error;
344
+		}
345
+		else
346
+		{
347
+			$this->db->commit();
348
+			return 1;
349
+		}
350
+	}
351
+
352
+
353
+
354
+	/**
355
+	 *	Load an object from its id and create a new one in database
356
+	 *
357
+	 *	@param	int		$fromid     Id of object to clone
358
+	 * 	@return	int					New id of clone
359
+	 */
360
+	function createFromClone($fromid)
361
+	{
362
+		global $user,$langs;
363
+
364
+		$error=0;
365
+
366
+		$object=new Phcp($this->db);
367
+
368
+		$this->db->begin();
369
+
370
+		// Load source object
371
+		$object->fetch($fromid);
372
+		$object->id=0;
373
+		$object->statut=0;
374
+
375
+		// Clear fields
376
+		// ...
377
+
378
+		// Create clone
379
+		$result=$object->create($user);
380
+
381
+		// Other options
382
+		if ($result < 0)
383
+		{
384
+			$this->error=$object->error;
385
+			$error++;
386
+		}
387
+
388
+		if (! $error)
389
+		{
390
+
391
+
392
+		}
393
+
394
+		// End
395
+		if (! $error)
396
+		{
397
+			$this->db->commit();
398
+			return $object->id;
399
+		}
400
+		else
401
+		{
402
+			$this->db->rollback();
403
+			return -1;
404
+		}
405
+	}
406
+
407
+
408
+	/**
409
+	 *	Initialise object with example values
410
+	 *	Id must be 0 if object instance is a specimen
411
+	 *
412
+	 *	@return	void
413
+	 */
414
+	function initAsSpecimen()
415
+	{
416
+		$this->id=0;
417
+		
418
+		$this->phcp_number='';
419
+		$this->entity='';
420
+		$this->nom='';
421
+		$this->ref_ext='';
422
+		$this->ref_int='';
423
+		$this->fk_phcp_type='';
424
+
425
+		
426
+	}
427
+
428
+}
429
+?>

+ 420
- 0
class/phcptype.class.php View File

@@ -0,0 +1,420 @@
1
+<?php
2
+/* Copyright (C) 2007-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
3
+ * Copyright (C) ---Put here your own copyright and developer email---
4
+ *
5
+ * This program is free software; you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation; either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+/**
20
+ *  \file       dev/skeletons/phcptype.class.php
21
+ *  \ingroup    mymodule othermodule1 othermodule2
22
+ *  \brief      This file is an example for a CRUD class file (Create/Read/Update/Delete)
23
+ *				Initialy built by build_class_from_table on 2013-09-12 16:46
24
+ */
25
+
26
+// Put here all includes required by your class file
27
+require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
28
+//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
29
+//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
30
+
31
+
32
+/**
33
+ *	Put here description of your class
34
+ */
35
+class Phcptype extends CommonObject
36
+{
37
+	var $db;							//!< To store db handler
38
+	var $error;							//!< To return error code (or message)
39
+	var $errors=array();				//!< To return several error codes (or messages)
40
+	var $element='phcptype';			//!< Id that identify managed objects
41
+	var $table_element='phcptype';		//!< Name of table without prefix where object is stored
42
+
43
+    var $id;
44
+    
45
+	var $phcp_type_number;
46
+	var $entity;
47
+	var $nom;
48
+	var $ref_ext;
49
+	var $ref_int;
50
+
51
+    
52
+
53
+
54
+    /**
55
+     *  Constructor
56
+     *
57
+     *  @param	DoliDb		$db      Database handler
58
+     */
59
+    function __construct($db)
60
+    {
61
+        $this->db = $db;
62
+        return 1;
63
+    }
64
+
65
+
66
+    /**
67
+     *  Create object into database
68
+     *
69
+     *  @param	User	$user        User that creates
70
+     *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
71
+     *  @return int      		   	 <0 if KO, Id of created object if OK
72
+     */
73
+    function create($user, $notrigger=0)
74
+    {
75
+    	global $conf, $langs;
76
+		$error=0;
77
+
78
+		// Clean parameters
79
+        
80
+		if (isset($this->phcp_type_number)) $this->phcp_type_number=trim($this->phcp_type_number);
81
+		if (isset($this->entity)) $this->entity=trim($this->entity);
82
+		if (isset($this->nom)) $this->nom=trim($this->nom);
83
+		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
84
+		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
85
+
86
+        
87
+
88
+		// Check parameters
89
+		// Put here code to add control on parameters values
90
+
91
+        // Insert request
92
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."phcp_type(";
93
+		
94
+		$sql.= "phcp_type_number,";
95
+		$sql.= "entity,";
96
+		$sql.= "nom,";
97
+		$sql.= "ref_ext,";
98
+		$sql.= "ref_int";
99
+
100
+		
101
+        $sql.= ") VALUES (";
102
+        
103
+		$sql.= " ".(! isset($this->phcp_type_number)?'NULL':"'".$this->db->escape($this->phcp_type_number)."'").",";
104
+		$sql.= " ".(! isset($this->entity)?'NULL':"'".$this->entity."'").",";
105
+		$sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").",";
106
+		$sql.= " ".(! isset($this->ref_ext)?'NULL':"'".$this->db->escape($this->ref_ext)."'").",";
107
+		$sql.= " ".(! isset($this->ref_int)?'NULL':"'".$this->db->escape($this->ref_int)."'")."";
108
+
109
+        
110
+		$sql.= ")";
111
+
112
+		$this->db->begin();
113
+
114
+	   	dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
115
+        $resql=$this->db->query($sql);
116
+    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
117
+
118
+		if (! $error)
119
+        {
120
+            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."phcp_type");
121
+
122
+			if (! $notrigger)
123
+			{
124
+	            // Uncomment this and change MYOBJECT to your own tag if you
125
+	            // want this action calls a trigger.
126
+
127
+	            //// Call triggers
128
+	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
129
+	            //$interface=new Interfaces($this->db);
130
+	            //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
131
+	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
132
+	            //// End call triggers
133
+			}
134
+        }
135
+
136
+        // Commit or rollback
137
+        if ($error)
138
+		{
139
+			foreach($this->errors as $errmsg)
140
+			{
141
+	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
142
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
143
+			}
144
+			$this->db->rollback();
145
+			return -1*$error;
146
+		}
147
+		else
148
+		{
149
+			$this->db->commit();
150
+            return $this->id;
151
+		}
152
+    }
153
+
154
+
155
+    /**
156
+     *  Load object in memory from the database
157
+     *
158
+     *  @param	int		$id    Id object
159
+     *  @return int          	<0 if KO, >0 if OK
160
+     */
161
+    function fetch($id)
162
+    {
163
+    	global $langs;
164
+        $sql = "SELECT";
165
+		$sql.= " t.rowid,";
166
+		
167
+		$sql.= " t.phcp_type_number,";
168
+		$sql.= " t.entity,";
169
+		$sql.= " t.nom,";
170
+		$sql.= " t.ref_ext,";
171
+		$sql.= " t.ref_int";
172
+
173
+		
174
+        $sql.= " FROM ".MAIN_DB_PREFIX."phcp_type as t";
175
+        $sql.= " WHERE t.rowid = ".$id;
176
+
177
+    	dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
178
+        $resql=$this->db->query($sql);
179
+        if ($resql)
180
+        {
181
+            if ($this->db->num_rows($resql))
182
+            {
183
+                $obj = $this->db->fetch_object($resql);
184
+
185
+                $this->id    = $obj->rowid;
186
+                
187
+				$this->phcp_type_number = $obj->phcp_type_number;
188
+				$this->entity = $obj->entity;
189
+				$this->nom = $obj->nom;
190
+				$this->ref_ext = $obj->ref_ext;
191
+				$this->ref_int = $obj->ref_int;
192
+
193
+                
194
+            }
195
+            $this->db->free($resql);
196
+
197
+            return 1;
198
+        }
199
+        else
200
+        {
201
+      	    $this->error="Error ".$this->db->lasterror();
202
+            dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
203
+            return -1;
204
+        }
205
+    }
206
+
207
+
208
+    /**
209
+     *  Update object into database
210
+     *
211
+     *  @param	User	$user        User that modifies
212
+     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
213
+     *  @return int     		   	 <0 if KO, >0 if OK
214
+     */
215
+    function update($user=0, $notrigger=0)
216
+    {
217
+    	global $conf, $langs;
218
+		$error=0;
219
+
220
+		// Clean parameters
221
+        
222
+		if (isset($this->phcp_type_number)) $this->phcp_type_number=trim($this->phcp_type_number);
223
+		if (isset($this->entity)) $this->entity=trim($this->entity);
224
+		if (isset($this->nom)) $this->nom=trim($this->nom);
225
+		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
226
+		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
227
+
228
+        
229
+
230
+		// Check parameters
231
+		// Put here code to add a control on parameters values
232
+
233
+        // Update request
234
+        $sql = "UPDATE ".MAIN_DB_PREFIX."phcp_type SET";
235
+        
236
+		$sql.= " phcp_type_number=".(isset($this->phcp_type_number)?"'".$this->db->escape($this->phcp_type_number)."'":"null").",";
237
+		$sql.= " entity=".(isset($this->entity)?$this->entity:"null").",";
238
+		$sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").",";
239
+		$sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").",";
240
+		$sql.= " ref_int=".(isset($this->ref_int)?"'".$this->db->escape($this->ref_int)."'":"null")."";
241
+
242
+        
243
+        $sql.= " WHERE rowid=".$this->id;
244
+
245
+		$this->db->begin();
246
+
247
+		dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
248
+        $resql = $this->db->query($sql);
249
+    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
250
+
251
+		if (! $error)
252
+		{
253
+			if (! $notrigger)
254
+			{
255
+	            // Uncomment this and change MYOBJECT to your own tag if you
256
+	            // want this action calls a trigger.
257
+
258
+	            //// Call triggers
259
+	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
260
+	            //$interface=new Interfaces($this->db);
261
+	            //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
262
+	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
263
+	            //// End call triggers
264
+	    	}
265
+		}
266
+
267
+        // Commit or rollback
268
+		if ($error)
269
+		{
270
+			foreach($this->errors as $errmsg)
271
+			{
272
+	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
273
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
274
+			}
275
+			$this->db->rollback();
276
+			return -1*$error;
277
+		}
278
+		else
279
+		{
280
+			$this->db->commit();
281
+			return 1;
282
+		}
283
+    }
284
+
285
+
286
+ 	/**
287
+	 *  Delete object in database
288
+	 *
289
+     *	@param  User	$user        User that deletes
290
+     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
291
+	 *  @return	int					 <0 if KO, >0 if OK
292
+	 */
293
+	function delete($user, $notrigger=0)
294
+	{
295
+		global $conf, $langs;
296
+		$error=0;
297
+
298
+		$this->db->begin();
299
+
300
+		if (! $error)
301
+		{
302
+			if (! $notrigger)
303
+			{
304
+				// Uncomment this and change MYOBJECT to your own tag if you
305
+		        // want this action calls a trigger.
306
+
307
+		        //// Call triggers
308
+		        //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
309
+		        //$interface=new Interfaces($this->db);
310
+		        //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
311
+		        //if ($result < 0) { $error++; $this->errors=$interface->errors; }
312
+		        //// End call triggers
313
+			}
314
+		}
315
+
316
+		if (! $error)
317
+		{
318
+    		$sql = "DELETE FROM ".MAIN_DB_PREFIX."phcp_type";
319
+    		$sql.= " WHERE rowid=".$this->id;
320
+
321
+    		dol_syslog(get_class($this)."::delete sql=".$sql);
322
+    		$resql = $this->db->query($sql);
323
+        	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
324
+		}
325
+
326
+        // Commit or rollback
327
+		if ($error)
328
+		{
329
+			foreach($this->errors as $errmsg)
330
+			{
331
+	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
332
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
333
+			}
334
+			$this->db->rollback();
335
+			return -1*$error;
336
+		}
337
+		else
338
+		{
339
+			$this->db->commit();
340
+			return 1;
341
+		}
342
+	}
343
+
344
+
345
+
346
+	/**
347
+	 *	Load an object from its id and create a new one in database
348
+	 *
349
+	 *	@param	int		$fromid     Id of object to clone
350
+	 * 	@return	int					New id of clone
351
+	 */
352
+	function createFromClone($fromid)
353
+	{
354
+		global $user,$langs;
355
+
356
+		$error=0;
357
+
358
+		$object=new Phcptype($this->db);
359
+
360
+		$this->db->begin();
361
+
362
+		// Load source object
363
+		$object->fetch($fromid);
364
+		$object->id=0;
365
+		$object->statut=0;
366
+
367
+		// Clear fields
368
+		// ...
369
+
370
+		// Create clone
371
+		$result=$object->create($user);
372
+
373
+		// Other options
374
+		if ($result < 0)
375
+		{
376
+			$this->error=$object->error;
377
+			$error++;
378
+		}
379
+
380
+		if (! $error)
381
+		{
382
+
383
+
384
+		}
385
+
386
+		// End
387
+		if (! $error)
388
+		{
389
+			$this->db->commit();
390
+			return $object->id;
391
+		}
392
+		else
393
+		{
394
+			$this->db->rollback();
395
+			return -1;
396
+		}
397
+	}
398
+
399
+
400
+	/**
401
+	 *	Initialise object with example values
402
+	 *	Id must be 0 if object instance is a specimen
403
+	 *
404
+	 *	@return	void
405
+	 */
406
+	function initAsSpecimen()
407
+	{
408
+		$this->id=0;
409
+		
410
+		$this->phcp_type_number='';
411
+		$this->entity='';
412
+		$this->nom='';
413
+		$this->ref_ext='';
414
+		$this->ref_int='';
415
+
416
+		
417
+	}
418
+
419
+}
420
+?>

+ 429
- 0
class/phcptypeproduct.class.php View File

@@ -0,0 +1,429 @@
1
+<?php
2
+/* Copyright (C) 2007-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
3
+ * Copyright (C) ---Put here your own copyright and developer email---
4
+ *
5
+ * This program is free software; you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation; either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+/**
20
+ *  \file       dev/skeletons/phcptypeproduct.class.php
21
+ *  \ingroup    mymodule othermodule1 othermodule2
22
+ *  \brief      This file is an example for a CRUD class file (Create/Read/Update/Delete)
23
+ *				Initialy built by build_class_from_table on 2013-09-12 16:47
24
+ */
25
+
26
+// Put here all includes required by your class file
27
+require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
28
+//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
29
+//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
30
+
31
+
32
+/**
33
+ *	Put here description of your class
34
+ */
35
+class Phcptypeproduct extends CommonObject
36
+{
37
+	var $db;							//!< To store db handler
38
+	var $error;							//!< To return error code (or message)
39
+	var $errors=array();				//!< To return several error codes (or messages)
40
+	var $element='phcptypeproduct';			//!< Id that identify managed objects
41
+	var $table_element='phcptypeproduct';		//!< Name of table without prefix where object is stored
42
+
43
+    var $id;
44
+    
45
+	var $phcp_type_product_number;
46
+	var $entity;
47
+	var $ref_ext;
48
+	var $ref_int;
49
+	var $fk_phcp_type;
50
+	var $fk_product;
51
+
52
+    
53
+
54
+
55
+    /**
56
+     *  Constructor
57
+     *
58
+     *  @param	DoliDb		$db      Database handler
59
+     */
60
+    function __construct($db)
61
+    {
62
+        $this->db = $db;
63
+        return 1;
64
+    }
65
+
66
+
67
+    /**
68
+     *  Create object into database
69
+     *
70
+     *  @param	User	$user        User that creates
71
+     *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
72
+     *  @return int      		   	 <0 if KO, Id of created object if OK
73
+     */
74
+    function create($user, $notrigger=0)
75
+    {
76
+    	global $conf, $langs;
77
+		$error=0;
78
+
79
+		// Clean parameters
80
+        
81
+		if (isset($this->phcp_type_product_number)) $this->phcp_type_product_number=trim($this->phcp_type_product_number);
82
+		if (isset($this->entity)) $this->entity=trim($this->entity);
83
+		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
84
+		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
85
+		if (isset($this->fk_phcp_type)) $this->fk_phcp_type=trim($this->fk_phcp_type);
86
+		if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
87
+
88
+        
89
+
90
+		// Check parameters
91
+		// Put here code to add control on parameters values
92
+
93
+        // Insert request
94
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."phcp_type_product(";
95
+		
96
+		$sql.= "phcp_type_product_number,";
97
+		$sql.= "entity,";
98
+		$sql.= "ref_ext,";
99
+		$sql.= "ref_int,";
100
+		$sql.= "fk_phcp_type,";
101
+		$sql.= "fk_product";
102
+
103
+		
104
+        $sql.= ") VALUES (";
105
+        
106
+		$sql.= " ".(! isset($this->phcp_type_product_number)?'NULL':"'".$this->db->escape($this->phcp_type_product_number)."'").",";
107
+		$sql.= " ".(! isset($this->entity)?'NULL':"'".$this->entity."'").",";
108
+		$sql.= " ".(! isset($this->ref_ext)?'NULL':"'".$this->db->escape($this->ref_ext)."'").",";
109
+		$sql.= " ".(! isset($this->ref_int)?'NULL':"'".$this->db->escape($this->ref_int)."'").",";
110
+		$sql.= " ".(! isset($this->fk_phcp_type)?'NULL':"'".$this->fk_phcp_type."'").",";
111
+		$sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->fk_product."'")."";
112
+
113
+        
114
+		$sql.= ")";
115
+
116
+		$this->db->begin();
117
+
118
+	   	dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
119
+        $resql=$this->db->query($sql);
120
+    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
121
+
122
+		if (! $error)
123
+        {
124
+            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."phcp_type_product");
125
+
126
+			if (! $notrigger)
127
+			{
128
+	            // Uncomment this and change MYOBJECT to your own tag if you
129
+	            // want this action calls a trigger.
130
+
131
+	            //// Call triggers
132
+	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
133
+	            //$interface=new Interfaces($this->db);
134
+	            //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
135
+	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
136
+	            //// End call triggers
137
+			}
138
+        }
139
+
140
+        // Commit or rollback
141
+        if ($error)
142
+		{
143
+			foreach($this->errors as $errmsg)
144
+			{
145
+	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
146
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
147
+			}
148
+			$this->db->rollback();
149
+			return -1*$error;
150
+		}
151
+		else
152
+		{
153
+			$this->db->commit();
154
+            return $this->id;
155
+		}
156
+    }
157
+
158
+
159
+    /**
160
+     *  Load object in memory from the database
161
+     *
162
+     *  @param	int		$id    Id object
163
+     *  @return int          	<0 if KO, >0 if OK
164
+     */
165
+    function fetch($id)
166
+    {
167
+    	global $langs;
168
+        $sql = "SELECT";
169
+		$sql.= " t.rowid,";
170
+		
171
+		$sql.= " t.phcp_type_product_number,";
172
+		$sql.= " t.entity,";
173
+		$sql.= " t.ref_ext,";
174
+		$sql.= " t.ref_int,";
175
+		$sql.= " t.fk_phcp_type,";
176
+		$sql.= " t.fk_product";
177
+
178
+		
179
+        $sql.= " FROM ".MAIN_DB_PREFIX."phcp_type_product as t";
180
+        $sql.= " WHERE t.rowid = ".$id;
181
+
182
+    	dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
183
+        $resql=$this->db->query($sql);
184
+        if ($resql)
185
+        {
186
+            if ($this->db->num_rows($resql))
187
+            {
188
+                $obj = $this->db->fetch_object($resql);
189
+
190
+                $this->id    = $obj->rowid;
191
+                
192
+				$this->phcp_type_product_number = $obj->phcp_type_product_number;
193
+				$this->entity = $obj->entity;
194
+				$this->ref_ext = $obj->ref_ext;
195
+				$this->ref_int = $obj->ref_int;
196
+				$this->fk_phcp_type = $obj->fk_phcp_type;
197
+				$this->fk_product = $obj->fk_product;
198
+
199
+                
200
+            }
201
+            $this->db->free($resql);
202
+
203
+            return 1;
204
+        }
205
+        else
206
+        {
207
+      	    $this->error="Error ".$this->db->lasterror();
208
+            dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
209
+            return -1;
210
+        }
211
+    }
212
+
213
+
214
+    /**
215
+     *  Update object into database
216
+     *
217
+     *  @param	User	$user        User that modifies
218
+     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
219
+     *  @return int     		   	 <0 if KO, >0 if OK
220
+     */
221
+    function update($user=0, $notrigger=0)
222
+    {
223
+    	global $conf, $langs;
224
+		$error=0;
225
+
226
+		// Clean parameters
227
+        
228
+		if (isset($this->phcp_type_product_number)) $this->phcp_type_product_number=trim($this->phcp_type_product_number);
229
+		if (isset($this->entity)) $this->entity=trim($this->entity);
230
+		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
231
+		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
232
+		if (isset($this->fk_phcp_type)) $this->fk_phcp_type=trim($this->fk_phcp_type);
233
+		if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
234
+
235
+        
236
+
237
+		// Check parameters
238
+		// Put here code to add a control on parameters values
239
+
240
+        // Update request
241
+        $sql = "UPDATE ".MAIN_DB_PREFIX."phcp_type_product SET";
242
+        
243
+		$sql.= " phcp_type_product_number=".(isset($this->phcp_type_product_number)?"'".$this->db->escape($this->phcp_type_product_number)."'":"null").",";
244
+		$sql.= " entity=".(isset($this->entity)?$this->entity:"null").",";
245
+		$sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").",";
246
+		$sql.= " ref_int=".(isset($this->ref_int)?"'".$this->db->escape($this->ref_int)."'":"null").",";
247
+		$sql.= " fk_phcp_type=".(isset($this->fk_phcp_type)?$this->fk_phcp_type:"null").",";
248
+		$sql.= " fk_product=".(isset($this->fk_product)?$this->fk_product:"null")."";
249
+
250
+        
251
+        $sql.= " WHERE rowid=".$this->id;
252
+
253
+		$this->db->begin();
254
+
255
+		dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
256
+        $resql = $this->db->query($sql);
257
+    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
258
+
259
+		if (! $error)
260
+		{
261
+			if (! $notrigger)
262
+			{
263
+	            // Uncomment this and change MYOBJECT to your own tag if you
264
+	            // want this action calls a trigger.
265
+
266
+	            //// Call triggers
267
+	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
268
+	            //$interface=new Interfaces($this->db);
269
+	            //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
270
+	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
271
+	            //// End call triggers
272
+	    	}
273
+		}
274
+
275
+        // Commit or rollback
276
+		if ($error)
277
+		{
278
+			foreach($this->errors as $errmsg)
279
+			{
280
+	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
281
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
282
+			}
283
+			$this->db->rollback();
284
+			return -1*$error;
285
+		}
286
+		else
287
+		{
288
+			$this->db->commit();
289
+			return 1;
290
+		}
291
+    }
292
+
293
+
294
+ 	/**
295
+	 *  Delete object in database
296
+	 *
297
+     *	@param  User	$user        User that deletes
298
+     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
299
+	 *  @return	int					 <0 if KO, >0 if OK
300
+	 */
301
+	function delete($user, $notrigger=0)
302
+	{
303
+		global $conf, $langs;
304
+		$error=0;
305
+
306
+		$this->db->begin();
307
+
308
+		if (! $error)
309
+		{
310
+			if (! $notrigger)
311
+			{
312
+				// Uncomment this and change MYOBJECT to your own tag if you
313
+		        // want this action calls a trigger.
314
+
315
+		        //// Call triggers
316
+		        //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
317
+		        //$interface=new Interfaces($this->db);
318
+		        //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
319
+		        //if ($result < 0) { $error++; $this->errors=$interface->errors; }
320
+		        //// End call triggers
321
+			}
322
+		}
323
+
324
+		if (! $error)
325
+		{
326
+    		$sql = "DELETE FROM ".MAIN_DB_PREFIX."phcp_type_product";
327
+    		$sql.= " WHERE rowid=".$this->id;
328
+
329
+    		dol_syslog(get_class($this)."::delete sql=".$sql);
330
+    		$resql = $this->db->query($sql);
331
+        	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
332
+		}
333
+
334
+        // Commit or rollback
335
+		if ($error)
336
+		{
337
+			foreach($this->errors as $errmsg)
338
+			{
339
+	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
340
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
341
+			}
342
+			$this->db->rollback();
343
+			return -1*$error;
344
+		}
345
+		else
346
+		{
347
+			$this->db->commit();
348
+			return 1;
349
+		}
350
+	}
351
+
352
+
353
+
354
+	/**
355
+	 *	Load an object from its id and create a new one in database
356
+	 *
357
+	 *	@param	int		$fromid     Id of object to clone
358
+	 * 	@return	int					New id of clone
359
+	 */
360
+	function createFromClone($fromid)
361
+	{
362
+		global $user,$langs;
363
+
364
+		$error=0;
365
+
366
+		$object=new Phcptypeproduct($this->db);
367
+
368
+		$this->db->begin();
369
+
370
+		// Load source object
371
+		$object->fetch($fromid);
372
+		$object->id=0;
373
+		$object->statut=0;
374
+
375
+		// Clear fields
376
+		// ...
377
+
378
+		// Create clone
379
+		$result=$object->create($user);
380
+
381
+		// Other options
382
+		if ($result < 0)
383
+		{
384
+			$this->error=$object->error;
385
+			$error++;
386
+		}
387
+
388
+		if (! $error)
389
+		{
390
+
391
+
392
+		}
393
+
394
+		// End
395
+		if (! $error)
396
+		{
397
+			$this->db->commit();
398
+			return $object->id;
399
+		}
400
+		else
401
+		{
402
+			$this->db->rollback();
403
+			return -1;
404
+		}
405
+	}
406
+
407
+
408
+	/**
409
+	 *	Initialise object with example values
410
+	 *	Id must be 0 if object instance is a specimen
411
+	 *
412
+	 *	@return	void
413
+	 */
414
+	function initAsSpecimen()
415
+	{
416
+		$this->id=0;
417
+		
418
+		$this->phcp_type_product_number='';
419
+		$this->entity='';
420
+		$this->ref_ext='';
421
+		$this->ref_int='';
422
+		$this->fk_phcp_type='';
423
+		$this->fk_product='';
424
+
425
+		
426
+	}
427
+
428
+}
429
+?>

+ 429
- 0
class/societephcp.class.php View File

@@ -0,0 +1,429 @@
1
+<?php
2
+/* Copyright (C) 2007-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
3
+ * Copyright (C) ---Put here your own copyright and developer email---
4
+ *
5
+ * This program is free software; you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation; either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+/**
20
+ *  \file       dev/skeletons/societephcp.class.php
21
+ *  \ingroup    mymodule othermodule1 othermodule2
22
+ *  \brief      This file is an example for a CRUD class file (Create/Read/Update/Delete)
23
+ *				Initialy built by build_class_from_table on 2013-09-12 16:47
24
+ */
25
+
26
+// Put here all includes required by your class file
27
+require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
28
+//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
29
+//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
30
+
31
+
32
+/**
33
+ *	Put here description of your class
34
+ */
35
+class Societephcp extends CommonObject
36
+{
37
+	var $db;							//!< To store db handler
38
+	var $error;							//!< To return error code (or message)
39
+	var $errors=array();				//!< To return several error codes (or messages)
40
+	var $element='societephcp';			//!< Id that identify managed objects
41
+	var $table_element='societephcp';		//!< Name of table without prefix where object is stored
42
+
43
+    var $id;
44
+    
45
+	var $societe_phcp_number;
46
+	var $entity;
47
+	var $ref_ext;
48
+	var $ref_int;
49
+	var $fk_phcp;
50
+	var $fk_societe;
51
+
52
+    
53
+
54
+
55
+    /**
56
+     *  Constructor
57
+     *
58
+     *  @param	DoliDb		$db      Database handler
59
+     */
60
+    function __construct($db)
61
+    {
62
+        $this->db = $db;
63
+        return 1;
64
+    }
65
+
66
+
67
+    /**
68
+     *  Create object into database
69
+     *
70
+     *  @param	User	$user        User that creates
71
+     *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
72
+     *  @return int      		   	 <0 if KO, Id of created object if OK
73
+     */
74
+    function create($user, $notrigger=0)
75
+    {
76
+    	global $conf, $langs;
77
+		$error=0;
78
+
79
+		// Clean parameters
80
+        
81
+		if (isset($this->societe_phcp_number)) $this->societe_phcp_number=trim($this->societe_phcp_number);
82
+		if (isset($this->entity)) $this->entity=trim($this->entity);
83
+		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
84
+		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
85
+		if (isset($this->fk_phcp)) $this->fk_phcp=trim($this->fk_phcp);
86
+		if (isset($this->fk_societe)) $this->fk_societe=trim($this->fk_societe);
87
+
88
+        
89
+
90
+		// Check parameters
91
+		// Put here code to add control on parameters values
92
+
93
+        // Insert request
94
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_phcp(";
95
+		
96
+		$sql.= "societe_phcp_number,";
97
+		$sql.= "entity,";
98
+		$sql.= "ref_ext,";
99
+		$sql.= "ref_int,";
100
+		$sql.= "fk_phcp,";
101
+		$sql.= "fk_societe";
102
+
103
+		
104
+        $sql.= ") VALUES (";
105
+        
106
+		$sql.= " ".(! isset($this->societe_phcp_number)?'NULL':"'".$this->db->escape($this->societe_phcp_number)."'").",";
107
+		$sql.= " ".(! isset($this->entity)?'NULL':"'".$this->entity."'").",";
108
+		$sql.= " ".(! isset($this->ref_ext)?'NULL':"'".$this->db->escape($this->ref_ext)."'").",";
109
+		$sql.= " ".(! isset($this->ref_int)?'NULL':"'".$this->db->escape($this->ref_int)."'").",";
110
+		$sql.= " ".(! isset($this->fk_phcp)?'NULL':"'".$this->fk_phcp."'").",";
111
+		$sql.= " ".(! isset($this->fk_societe)?'NULL':"'".$this->fk_societe."'")."";
112
+
113
+        
114
+		$sql.= ")";
115
+
116
+		$this->db->begin();
117
+
118
+	   	dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
119
+        $resql=$this->db->query($sql);
120
+    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
121
+
122
+		if (! $error)
123
+        {
124
+            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_phcp");
125
+
126
+			if (! $notrigger)
127
+			{
128
+	            // Uncomment this and change MYOBJECT to your own tag if you
129
+	            // want this action calls a trigger.
130
+
131
+	            //// Call triggers
132
+	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
133
+	            //$interface=new Interfaces($this->db);
134
+	            //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
135
+	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
136
+	            //// End call triggers
137
+			}
138
+        }
139
+
140
+        // Commit or rollback
141
+        if ($error)
142
+		{
143
+			foreach($this->errors as $errmsg)
144
+			{
145
+	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
146
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
147
+			}
148
+			$this->db->rollback();
149
+			return -1*$error;
150
+		}
151
+		else
152
+		{
153
+			$this->db->commit();
154
+            return $this->id;
155
+		}
156
+    }
157
+
158
+
159
+    /**
160
+     *  Load object in memory from the database
161
+     *
162
+     *  @param	int		$id    Id object
163
+     *  @return int          	<0 if KO, >0 if OK
164
+     */
165
+    function fetch($id)
166
+    {
167
+    	global $langs;
168
+        $sql = "SELECT";
169
+		$sql.= " t.rowid,";
170
+		
171
+		$sql.= " t.societe_phcp_number,";
172
+		$sql.= " t.entity,";
173
+		$sql.= " t.ref_ext,";
174
+		$sql.= " t.ref_int,";
175
+		$sql.= " t.fk_phcp,";
176
+		$sql.= " t.fk_societe";
177
+
178
+		
179
+        $sql.= " FROM ".MAIN_DB_PREFIX."societe_phcp as t";
180
+        $sql.= " WHERE t.rowid = ".$id;
181
+
182
+    	dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
183
+        $resql=$this->db->query($sql);
184
+        if ($resql)
185
+        {
186
+            if ($this->db->num_rows($resql))
187
+            {
188
+                $obj = $this->db->fetch_object($resql);
189
+
190
+                $this->id    = $obj->rowid;
191
+                
192
+				$this->societe_phcp_number = $obj->societe_phcp_number;
193
+				$this->entity = $obj->entity;
194
+				$this->ref_ext = $obj->ref_ext;
195
+				$this->ref_int = $obj->ref_int;
196
+				$this->fk_phcp = $obj->fk_phcp;
197
+				$this->fk_societe = $obj->fk_societe;
198
+
199
+                
200
+            }
201
+            $this->db->free($resql);
202
+
203
+            return 1;
204
+        }
205
+        else
206
+        {
207
+      	    $this->error="Error ".$this->db->lasterror();
208
+            dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
209
+            return -1;
210
+        }
211
+    }
212
+
213
+
214
+    /**
215
+     *  Update object into database
216
+     *
217
+     *  @param	User	$user        User that modifies
218
+     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
219
+     *  @return int     		   	 <0 if KO, >0 if OK
220
+     */
221
+    function update($user=0, $notrigger=0)
222
+    {
223
+    	global $conf, $langs;
224
+		$error=0;
225
+
226
+		// Clean parameters
227
+        
228
+		if (isset($this->societe_phcp_number)) $this->societe_phcp_number=trim($this->societe_phcp_number);
229
+		if (isset($this->entity)) $this->entity=trim($this->entity);
230
+		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
231
+		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
232
+		if (isset($this->fk_phcp)) $this->fk_phcp=trim($this->fk_phcp);
233
+		if (isset($this->fk_societe)) $this->fk_societe=trim($this->fk_societe);
234
+
235
+        
236
+
237
+		// Check parameters
238
+		// Put here code to add a control on parameters values
239
+
240
+        // Update request
241
+        $sql = "UPDATE ".MAIN_DB_PREFIX."societe_phcp SET";
242
+        
243
+		$sql.= " societe_phcp_number=".(isset($this->societe_phcp_number)?"'".$this->db->escape($this->societe_phcp_number)."'":"null").",";
244
+		$sql.= " entity=".(isset($this->entity)?$this->entity:"null").",";
245
+		$sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").",";
246
+		$sql.= " ref_int=".(isset($this->ref_int)?"'".$this->db->escape($this->ref_int)."'":"null").",";
247
+		$sql.= " fk_phcp=".(isset($this->fk_phcp)?$this->fk_phcp:"null").",";
248
+		$sql.= " fk_societe=".(isset($this->fk_societe)?$this->fk_societe:"null")."";
249
+
250
+        
251
+        $sql.= " WHERE rowid=".$this->id;
252
+
253
+		$this->db->begin();
254
+
255
+		dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
256
+        $resql = $this->db->query($sql);
257
+    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
258
+
259
+		if (! $error)
260
+		{
261
+			if (! $notrigger)
262
+			{
263
+	            // Uncomment this and change MYOBJECT to your own tag if you
264
+	            // want this action calls a trigger.
265
+
266
+	            //// Call triggers
267
+	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
268
+	            //$interface=new Interfaces($this->db);
269
+	            //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
270
+	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
271
+	            //// End call triggers
272
+	    	}
273
+		}
274
+
275
+        // Commit or rollback
276
+		if ($error)
277
+		{
278
+			foreach($this->errors as $errmsg)
279
+			{
280
+	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
281
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
282
+			}
283
+			$this->db->rollback();
284
+			return -1*$error;
285
+		}
286
+		else
287
+		{
288
+			$this->db->commit();
289
+			return 1;
290
+		}
291
+    }
292
+
293
+
294
+ 	/**
295
+	 *  Delete object in database
296
+	 *
297
+     *	@param  User	$user        User that deletes
298
+     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
299
+	 *  @return	int					 <0 if KO, >0 if OK
300
+	 */
301
+	function delete($user, $notrigger=0)
302
+	{
303
+		global $conf, $langs;
304
+		$error=0;
305
+
306
+		$this->db->begin();
307
+
308
+		if (! $error)
309
+		{
310
+			if (! $notrigger)
311
+			{
312
+				// Uncomment this and change MYOBJECT to your own tag if you
313
+		        // want this action calls a trigger.
314
+
315
+		        //// Call triggers
316
+		        //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
317
+		        //$interface=new Interfaces($this->db);
318
+		        //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
319
+		        //if ($result < 0) { $error++; $this->errors=$interface->errors; }
320
+		        //// End call triggers
321
+			}
322
+		}
323
+
324
+		if (! $error)
325
+		{
326
+    		$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_phcp";
327
+    		$sql.= " WHERE rowid=".$this->id;
328
+
329
+    		dol_syslog(get_class($this)."::delete sql=".$sql);
330
+    		$resql = $this->db->query($sql);
331
+        	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
332
+		}
333
+
334
+        // Commit or rollback
335
+		if ($error)
336
+		{
337
+			foreach($this->errors as $errmsg)
338
+			{
339
+	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
340
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
341
+			}
342
+			$this->db->rollback();
343
+			return -1*$error;
344
+		}
345
+		else
346
+		{
347
+			$this->db->commit();
348
+			return 1;
349
+		}
350
+	}
351
+
352
+
353
+
354
+	/**
355
+	 *	Load an object from its id and create a new one in database
356
+	 *
357
+	 *	@param	int		$fromid     Id of object to clone
358
+	 * 	@return	int					New id of clone
359
+	 */
360
+	function createFromClone($fromid)
361
+	{
362
+		global $user,$langs;
363
+
364
+		$error=0;
365
+
366
+		$object=new Societephcp($this->db);
367
+
368
+		$this->db->begin();
369
+
370
+		// Load source object
371
+		$object->fetch($fromid);
372
+		$object->id=0;
373
+		$object->statut=0;
374
+
375
+		// Clear fields
376
+		// ...
377
+
378
+		// Create clone
379
+		$result=$object->create($user);
380
+
381
+		// Other options
382
+		if ($result < 0)
383
+		{
384
+			$this->error=$object->error;
385
+			$error++;
386
+		}
387
+
388
+		if (! $error)
389
+		{
390
+
391
+
392
+		}
393
+
394
+		// End
395
+		if (! $error)
396
+		{
397
+			$this->db->commit();
398
+			return $object->id;
399
+		}
400
+		else
401
+		{
402
+			$this->db->rollback();
403
+			return -1;
404
+		}
405
+	}
406
+
407
+
408
+	/**
409
+	 *	Initialise object with example values
410
+	 *	Id must be 0 if object instance is a specimen
411
+	 *
412
+	 *	@return	void
413
+	 */
414
+	function initAsSpecimen()
415
+	{
416
+		$this->id=0;
417
+		
418
+		$this->societe_phcp_number='';
419
+		$this->entity='';
420
+		$this->ref_ext='';
421
+		$this->ref_int='';
422
+		$this->fk_phcp='';
423
+		$this->fk_societe='';
424
+
425
+		
426
+	}
427
+
428
+}
429
+?>

+ 438
- 0
class/societephcpproduct.class.php View File

@@ -0,0 +1,438 @@
1
+<?php
2
+/* Copyright (C) 2007-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
3
+ * Copyright (C) ---Put here your own copyright and developer email---
4
+ *
5
+ * This program is free software; you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation; either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+/**
20
+ *  \file       dev/skeletons/societephcpproduct.class.php
21
+ *  \ingroup    mymodule othermodule1 othermodule2
22
+ *  \brief      This file is an example for a CRUD class file (Create/Read/Update/Delete)
23
+ *				Initialy built by build_class_from_table on 2013-09-12 16:47
24
+ */
25
+
26
+// Put here all includes required by your class file
27
+require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
28
+//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
29
+//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
30
+
31
+
32
+/**
33
+ *	Put here description of your class
34
+ */
35
+class Societephcpproduct extends CommonObject
36
+{
37
+	var $db;							//!< To store db handler
38
+	var $error;							//!< To return error code (or message)
39
+	var $errors=array();				//!< To return several error codes (or messages)
40
+	var $element='societephcpproduct';			//!< Id that identify managed objects
41
+	var $table_element='societephcpproduct';		//!< Name of table without prefix where object is stored
42
+
43
+    var $id;
44
+    
45
+	var $societe_phcp_product_number;
46
+	var $entity;
47
+	var $ref_ext;
48
+	var $ref_int;
49
+	var $fk_phcp;
50
+	var $fk_societe;
51
+	var $fk_product;
52
+
53
+    
54
+
55
+
56
+    /**
57
+     *  Constructor
58
+     *
59
+     *  @param	DoliDb		$db      Database handler
60
+     */
61
+    function __construct($db)
62
+    {
63
+        $this->db = $db;
64
+        return 1;
65
+    }
66
+
67
+
68
+    /**
69
+     *  Create object into database
70
+     *
71
+     *  @param	User	$user        User that creates
72
+     *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
73
+     *  @return int      		   	 <0 if KO, Id of created object if OK
74
+     */
75
+    function create($user, $notrigger=0)
76
+    {
77
+    	global $conf, $langs;
78
+		$error=0;
79
+
80
+		// Clean parameters
81
+        
82
+		if (isset($this->societe_phcp_product_number)) $this->societe_phcp_product_number=trim($this->societe_phcp_product_number);
83
+		if (isset($this->entity)) $this->entity=trim($this->entity);
84
+		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
85
+		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
86
+		if (isset($this->fk_phcp)) $this->fk_phcp=trim($this->fk_phcp);
87
+		if (isset($this->fk_societe)) $this->fk_societe=trim($this->fk_societe);
88
+		if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
89
+
90
+        
91
+
92
+		// Check parameters
93
+		// Put here code to add control on parameters values
94
+
95
+        // Insert request
96
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_phcp_product(";
97
+		
98
+		$sql.= "societe_phcp_product_number,";
99
+		$sql.= "entity,";
100
+		$sql.= "ref_ext,";
101
+		$sql.= "ref_int,";
102
+		$sql.= "fk_phcp,";
103
+		$sql.= "fk_societe,";
104
+		$sql.= "fk_product";
105
+
106
+		
107
+        $sql.= ") VALUES (";
108
+        
109
+		$sql.= " ".(! isset($this->societe_phcp_product_number)?'NULL':"'".$this->db->escape($this->societe_phcp_product_number)."'").",";
110
+		$sql.= " ".(! isset($this->entity)?'NULL':"'".$this->entity."'").",";
111
+		$sql.= " ".(! isset($this->ref_ext)?'NULL':"'".$this->db->escape($this->ref_ext)."'").",";
112
+		$sql.= " ".(! isset($this->ref_int)?'NULL':"'".$this->db->escape($this->ref_int)."'").",";
113
+		$sql.= " ".(! isset($this->fk_phcp)?'NULL':"'".$this->fk_phcp."'").",";
114
+		$sql.= " ".(! isset($this->fk_societe)?'NULL':"'".$this->fk_societe."'").",";
115
+		$sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->fk_product."'")."";
116
+
117
+        
118
+		$sql.= ")";
119
+
120
+		$this->db->begin();
121
+
122
+	   	dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
123
+        $resql=$this->db->query($sql);
124
+    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
125
+
126
+		if (! $error)
127
+        {
128
+            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_phcp_product");
129
+
130
+			if (! $notrigger)
131
+			{
132
+	            // Uncomment this and change MYOBJECT to your own tag if you
133
+	            // want this action calls a trigger.
134
+
135
+	            //// Call triggers
136
+	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
137
+	            //$interface=new Interfaces($this->db);
138
+	            //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
139
+	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
140
+	            //// End call triggers
141
+			}
142
+        }
143
+
144
+        // Commit or rollback
145
+        if ($error)
146
+		{
147
+			foreach($this->errors as $errmsg)
148
+			{
149
+	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
150
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
151
+			}
152
+			$this->db->rollback();
153
+			return -1*$error;
154
+		}
155
+		else
156
+		{
157
+			$this->db->commit();
158
+            return $this->id;
159
+		}
160
+    }
161
+
162
+
163
+    /**
164
+     *  Load object in memory from the database
165
+     *
166
+     *  @param	int		$id    Id object
167
+     *  @return int          	<0 if KO, >0 if OK
168
+     */
169
+    function fetch($id)
170
+    {
171
+    	global $langs;
172
+        $sql = "SELECT";
173
+		$sql.= " t.rowid,";
174
+		
175
+		$sql.= " t.societe_phcp_product_number,";
176
+		$sql.= " t.entity,";
177
+		$sql.= " t.ref_ext,";
178
+		$sql.= " t.ref_int,";
179
+		$sql.= " t.fk_phcp,";
180
+		$sql.= " t.fk_societe,";
181
+		$sql.= " t.fk_product";
182
+
183
+		
184
+        $sql.= " FROM ".MAIN_DB_PREFIX."societe_phcp_product as t";
185
+        $sql.= " WHERE t.rowid = ".$id;
186
+
187
+    	dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
188
+        $resql=$this->db->query($sql);
189
+        if ($resql)
190
+        {
191
+            if ($this->db->num_rows($resql))
192
+            {
193
+                $obj = $this->db->fetch_object($resql);
194
+
195
+                $this->id    = $obj->rowid;
196
+                
197
+				$this->societe_phcp_product_number = $obj->societe_phcp_product_number;
198
+				$this->entity = $obj->entity;
199
+				$this->ref_ext = $obj->ref_ext;
200
+				$this->ref_int = $obj->ref_int;
201
+				$this->fk_phcp = $obj->fk_phcp;
202
+				$this->fk_societe = $obj->fk_societe;
203
+				$this->fk_product = $obj->fk_product;
204
+
205
+                
206
+            }
207
+            $this->db->free($resql);
208
+
209
+            return 1;
210
+        }
211
+        else
212
+        {
213
+      	    $this->error="Error ".$this->db->lasterror();
214
+            dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
215
+            return -1;
216
+        }
217
+    }
218
+
219
+
220
+    /**
221
+     *  Update object into database
222
+     *
223
+     *  @param	User	$user        User that modifies
224
+     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
225
+     *  @return int     		   	 <0 if KO, >0 if OK
226
+     */
227
+    function update($user=0, $notrigger=0)
228
+    {
229
+    	global $conf, $langs;
230
+		$error=0;
231
+
232
+		// Clean parameters
233
+        
234
+		if (isset($this->societe_phcp_product_number)) $this->societe_phcp_product_number=trim($this->societe_phcp_product_number);
235
+		if (isset($this->entity)) $this->entity=trim($this->entity);
236
+		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
237
+		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
238
+		if (isset($this->fk_phcp)) $this->fk_phcp=trim($this->fk_phcp);
239
+		if (isset($this->fk_societe)) $this->fk_societe=trim($this->fk_societe);
240
+		if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
241
+
242
+        
243
+
244
+		// Check parameters
245
+		// Put here code to add a control on parameters values
246
+
247
+        // Update request
248
+        $sql = "UPDATE ".MAIN_DB_PREFIX."societe_phcp_product SET";
249
+        
250
+		$sql.= " societe_phcp_product_number=".(isset($this->societe_phcp_product_number)?"'".$this->db->escape($this->societe_phcp_product_number)."'":"null").",";
251
+		$sql.= " entity=".(isset($this->entity)?$this->entity:"null").",";
252
+		$sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").",";
253
+		$sql.= " ref_int=".(isset($this->ref_int)?"'".$this->db->escape($this->ref_int)."'":"null").",";
254
+		$sql.= " fk_phcp=".(isset($this->fk_phcp)?$this->fk_phcp:"null").",";
255
+		$sql.= " fk_societe=".(isset($this->fk_societe)?$this->fk_societe:"null").",";
256
+		$sql.= " fk_product=".(isset($this->fk_product)?$this->fk_product:"null")."";
257
+
258
+        
259
+        $sql.= " WHERE rowid=".$this->id;
260
+
261
+		$this->db->begin();
262
+
263
+		dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
264
+        $resql = $this->db->query($sql);
265
+    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
266
+
267
+		if (! $error)
268
+		{
269
+			if (! $notrigger)
270
+			{
271
+	            // Uncomment this and change MYOBJECT to your own tag if you
272
+	            // want this action calls a trigger.
273
+
274
+	            //// Call triggers
275
+	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
276
+	            //$interface=new Interfaces($this->db);
277
+	            //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
278
+	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
279
+	            //// End call triggers
280
+	    	}
281
+		}
282
+
283
+        // Commit or rollback
284
+		if ($error)
285
+		{
286
+			foreach($this->errors as $errmsg)
287
+			{
288
+	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
289
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
290
+			}
291
+			$this->db->rollback();
292
+			return -1*$error;
293
+		}
294
+		else
295
+		{
296
+			$this->db->commit();
297
+			return 1;
298
+		}
299
+    }
300
+
301
+
302
+ 	/**
303
+	 *  Delete object in database
304
+	 *
305
+     *	@param  User	$user        User that deletes
306
+     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
307
+	 *  @return	int					 <0 if KO, >0 if OK
308
+	 */
309
+	function delete($user, $notrigger=0)
310
+	{
311
+		global $conf, $langs;
312
+		$error=0;
313
+
314
+		$this->db->begin();
315
+
316
+		if (! $error)
317
+		{
318
+			if (! $notrigger)
319
+			{
320
+				// Uncomment this and change MYOBJECT to your own tag if you
321
+		        // want this action calls a trigger.
322
+
323
+		        //// Call triggers
324
+		        //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
325
+		        //$interface=new Interfaces($this->db);
326
+		        //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
327
+		        //if ($result < 0) { $error++; $this->errors=$interface->errors; }
328
+		        //// End call triggers
329
+			}
330
+		}
331
+
332
+		if (! $error)
333
+		{
334
+    		$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_phcp_product";
335
+    		$sql.= " WHERE rowid=".$this->id;
336
+
337
+    		dol_syslog(get_class($this)."::delete sql=".$sql);
338
+    		$resql = $this->db->query($sql);
339
+        	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
340
+		}
341
+
342
+        // Commit or rollback
343
+		if ($error)
344
+		{
345
+			foreach($this->errors as $errmsg)
346
+			{
347
+	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
348
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
349
+			}
350
+			$this->db->rollback();
351
+			return -1*$error;
352
+		}
353
+		else
354
+		{
355
+			$this->db->commit();
356
+			return 1;
357
+		}
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 *	Load an object from its id and create a new one in database
364
+	 *
365
+	 *	@param	int		$fromid     Id of object to clone
366
+	 * 	@return	int					New id of clone
367
+	 */
368
+	function createFromClone($fromid)
369
+	{
370
+		global $user,$langs;
371
+
372
+		$error=0;
373
+
374
+		$object=new Societephcpproduct($this->db);
375
+
376
+		$this->db->begin();
377
+
378
+		// Load source object
379
+		$object->fetch($fromid);
380
+		$object->id=0;
381
+		$object->statut=0;
382
+
383
+		// Clear fields
384
+		// ...
385
+
386
+		// Create clone
387
+		$result=$object->create($user);
388
+
389
+		// Other options
390
+		if ($result < 0)
391
+		{
392
+			$this->error=$object->error;
393
+			$error++;
394
+		}
395
+
396
+		if (! $error)
397
+		{
398
+
399
+
400
+		}
401
+
402
+		// End
403
+		if (! $error)
404
+		{
405
+			$this->db->commit();
406
+			return $object->id;
407
+		}
408
+		else
409
+		{
410
+			$this->db->rollback();
411
+			return -1;
412
+		}
413
+	}
414
+
415
+
416
+	/**
417
+	 *	Initialise object with example values
418
+	 *	Id must be 0 if object instance is a specimen
419
+	 *
420
+	 *	@return	void
421
+	 */
422
+	function initAsSpecimen()
423
+	{
424
+		$this->id=0;
425
+		
426
+		$this->societe_phcp_product_number='';
427
+		$this->entity='';
428
+		$this->ref_ext='';
429
+		$this->ref_int='';
430
+		$this->fk_phcp='';
431
+		$this->fk_societe='';
432
+		$this->fk_product='';
433
+
434
+		
435
+	}
436
+
437
+}
438
+?>

+ 4
- 4
core/boxes/mybox.php View File

@@ -18,7 +18,7 @@
18 18
 
19 19
 /**
20 20
  * 	\file		core/boxes/mybox.php
21
- * 	\ingroup	mymodule
21
+ * 	\ingroup	photocopies
22 22
  * 	\brief		This file is a sample box definition file
23 23
  * 				Put some comments here
24 24
  */
@@ -31,9 +31,9 @@ class mybox extends ModeleBoxes
31 31
 {
32 32
 
33 33
     public $boxcode = "mybox";
34
-    public $boximg = "mymodule@mymodule";
34
+    public $boximg = "photocopies@photocopies";
35 35
     public $boxlabel;
36
-    public $depends = array("mymodule");
36
+    public $depends = array("photocopies");
37 37
     public $db;
38 38
     public $param;
39 39
     public $info_box_head = array();
@@ -62,7 +62,7 @@ class mybox extends ModeleBoxes
62 62
 
63 63
         $this->max = $max;
64 64
 
65
-        //include_once DOL_DOCUMENT_ROOT . "/mymodule/class/mymodule.class.php";
65
+        //include_once DOL_DOCUMENT_ROOT . "/photocopies/class/photocopies.class.php";
66 66
 
67 67
         $text = $langs->trans("MyBoxDescription", $max);
68 68
         $this->info_box_head = array(

core/modules/modMyModule.class.php → core/modules/modPhotocopies.class.php View File

@@ -1,6 +1,7 @@
1 1
 <?php
2 2
 /* <one line to give the program's name and a brief idea of what it does.>
3
- * Copyright (C) <year>  <name of author>
3
+ * dolibarr_photocopies - Plugin for photocopies buisiness management
4
+ * Copyright (C) 2013 Ghislain Loaec
4 5
  *
5 6
  * This program is free software: you can redistribute it and/or modify
6 7
  * it under the terms of the GNU General Public License as published by
@@ -17,18 +18,18 @@
17 18
  */
18 19
 
19 20
 /**
20
- * 	\defgroup	mymodule	MyModule module
21
- * 	\brief		MyModule module descriptor.
22
- * 	\file		core/modules/modMyModule.class.php
23
- * 	\ingroup	mymodule
24
- * 	\brief		Description and activation file for module MyModule
21
+ * 	\defgroup	photocopies	Photocopies module
22
+ * 	\brief		Photocopies module descriptor.
23
+ * 	\file		core/modules/modPhotocopies.class.php
24
+ * 	\ingroup	photocopies
25
+ * 	\brief		Description and activation file for module Photocopies
25 26
  */
26 27
 include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
27 28
 
28 29
 /**
29 30
  * Description and activation class for module MyModule
30 31
  */
31
-class modMyModule extends DolibarrModules
32
+class modPhotocopies extends DolibarrModules
32 33
 {
33 34
 
34 35
     /**
@@ -45,9 +46,9 @@ class modMyModule extends DolibarrModules
45 46
         // Id for module (must be unique).
46 47
         // Use a free id here
47 48
         // (See in Home -> System information -> Dolibarr for list of used modules id).
48
-        $this->numero = 10000;
49
+        $this->numero = 6182;
49 50
         // Key text used to identify module (for permissions, menus, etc...)
50
-        $this->rights_class = 'mymodule';
51
+        $this->rights_class = 'photocopies';
51 52
 
52 53
         // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
53 54
         // It is used to group modules in module setup page
@@ -59,7 +60,7 @@ class modMyModule extends DolibarrModules
59 60
         // Module description
60 61
         // used if translation string 'ModuleXXXDesc' not found
61 62
         // (where XXX is value of numeric property 'numero' of module)
62
-        $this->description = "Description of module MyModule";
63
+        $this->description = "Description of module Photocopies";
63 64
         // Possible values for version are: 'development', 'experimental' or version
64 65
         $this->version = 'development';
65 66
         // Key used in llx_const table to save module status enabled/disabled
@@ -73,11 +74,11 @@ class modMyModule extends DolibarrModules
73 74
         // use this->picto='pictovalue'
74 75
         // If file is in module/img directory under name object_pictovalue.png
75 76
         // use this->picto='pictovalue@module'
76
-        $this->picto = 'mymodule@mymodule'; // mypicto@mymodule
77
+        $this->picto = 'photocopies@photocopies'; // mypicto@photocopies
77 78
         // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
78
-        // for default path (eg: /mymodule/core/xxxxx) (0=disable, 1=enable)
79
-        // for specific path of parts (eg: /mymodule/core/modules/barcode)
80
-        // for specific css file (eg: /mymodule/css/mymodule.css.php)
79
+        // for default path (eg: /photocopies/core/xxxxx) (0=disable, 1=enable)
80
+        // for specific path of parts (eg: /photocopies/core/modules/barcode)
81
+        // for specific css file (eg: /photocopies/css/photocopies.css.php)
81 82
         $this->module_parts = array(
82 83
             // Set this to 1 if module has its own trigger directory
83 84
             'triggers' => 1,
@@ -92,7 +93,7 @@ class modMyModule extends DolibarrModules
92 93
             // Set this to 1 if module has its own models directory
93 94
             //'models' => 0,
94 95
             // Set this to relative path of css if module has its own css file
95
-            'css' => '/mymodule/css/mycss.css.php',
96
+            'css' => '/photocopies/css/mycss.css.php',
96 97
             // Set here all hooks context managed by module
97 98
             //'hooks' => array('hookcontext1','hookcontext2')
98 99
             // Set here all workflow context managed by module
@@ -100,12 +101,12 @@ class modMyModule extends DolibarrModules
100 101
         );
101 102
 
102 103
         // Data directories to create when module is enabled.
103
-        // Example: this->dirs = array("/mymodule/temp");
104
+        // Example: this->dirs = array("/photocopies/temp");
104 105
         $this->dirs = array();
105 106
 
106 107
         // Config pages. Put here list of php pages
107
-        // stored into mymodule/admin directory, used to setup module.
108
-        $this->config_page_url = array("admin_mymodule.php@mymodule");
108
+        // stored into photocopies/admin directory, used to setup module.
109
+        $this->config_page_url = array("admin_photocopies.php@photocopies");
109 110
 
110 111
         // Dependencies
111 112
         // List of modules id that must be enabled if this module is enabled
@@ -116,7 +117,7 @@ class modMyModule extends DolibarrModules
116 117
         $this->phpmin = array(5, 3);
117 118
         // Minimum version of Dolibarr required by module
118 119
         $this->need_dolibarr_version = array(3, 2);
119
-        $this->langfiles = array("mymodule@mymodule"); // langfiles@mymodule
120
+        $this->langfiles = array("photocopies@photocopies"); // langfiles@photocopies
120 121
         // Constants
121 122
         // List of particular constants to add when module is enabled
122 123
         // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
@@ -142,9 +143,9 @@ class modMyModule extends DolibarrModules
142 143
         // Example:
143 144
         $this->tabs = array(
144 145
             //	// To add a new tab identified by code tabname1
145
-            //	'objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__',
146
+            //	'objecttype:+tabname1:Title1:langfile@photocopies:$user->rights->photocopies->read:/photocopies/mynewtab1.php?id=__ID__',
146 147
             //	// To add another new tab identified by code tabname2
147
-            //	'objecttype:+tabname2:Title2:langfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__',
148
+            //	'objecttype:+tabname2:Title2:langfile@photocopies:$user->rights->othermodule->read:/photocopies/mynewtab2.php?id=__ID__',
148 149
             //	// To remove an existing tab identified by code tabname
149 150
             //	'objecttype:-tabname'
150 151
         );
@@ -166,16 +167,16 @@ class modMyModule extends DolibarrModules
166 167
         // 'categories_x'		to add a tab in category view
167 168
         // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
168 169
         // Dictionnaries
169
-        if (! isset($conf->mymodule->enabled)) {
170
-            $conf->mymodule=new stdClass();
171
-            $conf->mymodule->enabled = 0;
170
+        if (! isset($conf->photocopies->enabled)) {
171
+            $conf->photocopies=new stdClass();
172
+            $conf->photocopies->enabled = 0;
172 173
         }
173 174
         $this->dictionnaries = array();
174 175
         /* Example:
175 176
           // This is to avoid warnings
176
-          if (! isset($conf->mymodule->enabled)) $conf->mymodule->enabled=0;
177
+          if (! isset($conf->photocopies->enabled)) $conf->photocopies->enabled=0;
177 178
           $this->dictionnaries=array(
178
-          'langs'=>'mymodule@mymodule',
179
+          'langs'=>'photocopies@photocopies',
179 180
           // List of tables we want to see into dictonnary editor
180 181
           'tabname'=>array(
181 182
           MAIN_DB_PREFIX."table1",
@@ -205,9 +206,9 @@ class modMyModule extends DolibarrModules
205 206
           'tabrowid'=>array("rowid","rowid","rowid"),
206 207
           // Condition to show each dictionnary
207 208
           'tabcond'=>array(
208
-          $conf->mymodule->enabled,
209
-          $conf->mymodule->enabled,
210
-          $conf->mymodule->enabled
209
+          $conf->photocopies->enabled,
210
+          $conf->photocopies->enabled,
211
+          $conf->photocopies->enabled
211 212
           )
212 213
           );
213 214
          */
@@ -218,7 +219,7 @@ class modMyModule extends DolibarrModules
218 219
         $r = 0;
219 220
         // Example:
220 221
 
221
-        $this->boxes[$r][1] = "MyBox@mymodule";
222
+        $this->boxes[$r][1] = "MyBox@photocopies";
222 223
         $r ++;
223 224
         /*
224 225
           $this->boxes[$r][1] = "myboxb.php";
@@ -252,30 +253,30 @@ class modMyModule extends DolibarrModules
252 253
         // Add here entries to declare new menus
253 254
         //
254 255
         // Example to declare a new Top Menu entry and its Left menu entry:
255
-        //$this->menu[$r]=array(
256
-        //	// Put 0 if this is a top menu
257
-        //	'fk_menu'=>0,
258
-        //	// This is a Top menu entry
259
-        //	'type'=>'top',
260
-        //	'titre'=>'MyModule top menu',
261
-        //	'mainmenu'=>'mymodule',
262
-        //	'leftmenu'=>'mymodule',
263
-        //	'url'=>'/mymodule/pagetop.php',
264
-        //	// Lang file to use (without .lang) by module.
265
-        //	// File must be in langs/code_CODE/ directory.
266
-        //	'langs'=>'mylangfile',
267
-        //	'position'=>100,
268
-        //	// Define condition to show or hide menu entry.
269
-        //	// Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
270
-        //	'enabled'=>'$conf->mymodule->enabled',
271
-        //	// Use 'perms'=>'$user->rights->mymodule->level1->level2'
272
-        //	// if you want your menu with a permission rules
273
-        //	'perms'=>'1',
274
-        //	'target'=>'',
275
-        //	// 0=Menu for internal users, 1=external users, 2=both
276
-        //	'user'=>2
277
-        //);
278
-        //$r++;
256
+        $this->menu[$r]=array(
257
+        	// Put 0 if this is a top menu
258
+        	'fk_menu'=>0,
259
+        	// This is a Top menu entry
260
+        	'type'=>'top',
261
+        	'titre'=>'Compteurs',
262
+        	'mainmenu'=>'photocopies',
263
+        	'leftmenu'=>'photocopies',
264
+        	'url'=>'/photocopies/mypage.php',
265
+        	// Lang file to use (without .lang) by module.
266
+        	// File must be in langs/code_CODE/ directory.
267
+        	'langs'=>'photocopies',
268
+        	'position'=>100,
269
+        	// Define condition to show or hide menu entry.
270
+        	// Use '$conf->photocopies->enabled' if entry must be visible if module is enabled.
271
+        	'enabled'=>'$conf->photocopies->enabled',
272
+        	// Use 'perms'=>'$user->rights->photocopies->level1->level2'
273
+        	// if you want your menu with a permission rules
274
+        	'perms'=>'1',
275
+        	'target'=>'',
276
+        	// 0=Menu for internal users, 1=external users, 2=both
277
+        	'user'=>2
278
+        );
279
+        $r++;
279 280
         //$this->menu[$r]=array(
280 281
         //	// Use r=value where r is index key used for the parent menu entry
281 282
         //	// (higher parent must be a top menu entry)
@@ -283,17 +284,17 @@ class modMyModule extends DolibarrModules
283 284
         //	// This is a Left menu entry
284 285
         //	'type'=>'left',
285 286
         //	'titre'=>'MyModule left menu',
286
-        //	'mainmenu'=>'mymodule',
287
-        //	'leftmenu'=>'mymodule',
288
-        //	'url'=>'/mymodule/pagelevel1.php',
287
+        //	'mainmenu'=>'photocopies',
288
+        //	'leftmenu'=>'photocopies',
289
+        //	'url'=>'/photocopies/pagelevel1.php',
289 290
         //	// Lang file to use (without .lang) by module.
290 291
         //	// File must be in langs/code_CODE/ directory.
291 292
         //	'langs'=>'mylangfile',
292 293
         //	'position'=>100,
293 294
         //	// Define condition to show or hide menu entry.
294
-        //	// Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
295
-        //	'enabled'=>'$conf->mymodule->enabled',
296
-        //	// Use 'perms'=>'$user->rights->mymodule->level1->level2'
295
+        //	// Use '$conf->photocopies->enabled' if entry must be visible if module is enabled.
296
+        //	'enabled'=>'$conf->photocopies->enabled',
297
+        //	// Use 'perms'=>'$user->rights->photocopies->level1->level2'
297 298