Browse Source

CRUD for photocopieurs (phcp) + Vues OK

master
Ghislain Loaec 6 years ago
parent
commit
ee885fe76d

+ 13
- 80
README.md View File

@@ -1,88 +1,21 @@
1
-My Module
2
-=========
3 1
 
4
-This is a full featured module template for Dolibarr
2
+Sitemap
3
+=======
5 4
 
6
-Licence
7
--------
8
-GPLv3 or (at your option) any later version.
5
+- Photocopieurs
6
+  - List ressources
7
+    - Edit ressource (Assign to societe)
8
+  - New Ressource
9 9
 
10
-See COPYING for more information.
10
+- Photocopieur types
11
+  - List Photocopieurs Types
12
+    - Edit Photocopieur type (Associate to products for prices)
13
+  - New Photocopieur type
11 14
 
12
-INSTALL
13
--------
15
+- Compteurs
16
+  - List Societies
17
+    - Fill compteurs
14 18
 
15
-To install this module, Dolibarr (v >= 3.3) have to be already installed and configured on your server.
16 19
 
17
-- In your Dolibarr installation directory: edit the htdocs/conf/conf.php file
18
-- Find the following lines:
19 20
 
20
-	\#$=dolibarr_main_url_root_alt ...
21 21
 
22
-	\#$=dolibarr_main_document_root_alt ...
23
-
24
-	or
25
-
26
-	//$=dolibarr_main_url_root_alt ...
27
-
28
-	//$=dolibarr_main_document_root_alt ...
29
-
30
-- Delete the first "#" (or "//") of these lines and assign a value consistent with your Dolibarr installation
31
-
32
-	$dolibarr_main_url_root = ...
33
-
34
-	and
35
-
36
-	$dolibarr_main_document_root = ...
37
-
38
-for example on UNIX systems:
39
-
40
-	$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
41
-
42
-	$dolibarr_main_document_root = '/var/www/Dolibarr/htdocs';
43
-
44
-	$dolibarr_main_url_root_alt = 'http://localhost/Dolibarr/htdocs/custom';
45
-
46
-	$dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom';
47
-
48
-for example on a Windows system:
49
-
50
-	$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
51
-
52
-	$dolibarr_main_document_root = 'C:/My Web Sites/Dolibarr/htdocs';
53
-
54
-	$dolibarr_main_url_root_alt = 'http://localhost/Dolibarr/htdocs/custom';
55
-
56
-	$dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom';
57
-
58
-For more information about the conf.php file take a look at the conf.php.example file.
59
-
60
-- Clone the repsitory in $dolibarr_main_document_root_alt/mymodule
61
-
62
-(You may have to create the custom directory first if it doesn't exist yet.)
63
-
64
-```
65
-git clone --recursive git@github.com:rdoursenaud/dolibarr-module-template.git mymodule
66
-```
67
-
68
-- The template now uses a git submodule to fetch the PHP Markdown library. If your git version is less than 1.6.5, the --recursive parameter won't work. Please use this to fetch the latest version:
69
-```
70
-git clone git@github.com:rdoursenaud/dolibarr-module-template.git mymodule
71
-cd mymodule
72
-git submodule update --init
73
-```
74
-
75
-for example on UNIX systems: /var/www/Dolibarr/htdocs/custom
76
-
77
-for example on a Windows system: C:/My Web Sites/Dolibarr/htdocs/custom
78
-
79
-From your browser:
80
-- log in as a Dolibarr administrator
81
-- under "Setup" -> "Other setup", set "MAIN_FEATURES_LEVEL" to "2"
82
-- go to "Setup" -> "Modules"
83
-- the module is under one of the tabs
84
-- you should now be able to enable the new module
85
-
86
-Other Licences
87
---------------
88
-Uses Michel Fortin's PHP Markdown Licensed under BSD to display this README.

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

@@ -42,8 +42,6 @@ class Phcp extends CommonObject
42 42
 
43 43
     var $id;
44 44
     
45
-	var $phcp_number;
46
-	var $entity;
47 45
 	var $nom;
48 46
 	var $ref_ext;
49 47
 	var $ref_int;
@@ -78,8 +76,6 @@ class Phcp extends CommonObject
78 76
 
79 77
 		// Clean parameters
80 78
         
81
-		if (isset($this->phcp_number)) $this->phcp_number=trim($this->phcp_number);
82
-		if (isset($this->entity)) $this->entity=trim($this->entity);
83 79
 		if (isset($this->nom)) $this->nom=trim($this->nom);
84 80
 		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
85 81
 		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
@@ -93,8 +89,6 @@ class Phcp extends CommonObject
93 89
         // Insert request
94 90
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."phcp(";
95 91
 		
96
-		$sql.= "phcp_number,";
97
-		$sql.= "entity,";
98 92
 		$sql.= "nom,";
99 93
 		$sql.= "ref_ext,";
100 94
 		$sql.= "ref_int,";
@@ -103,8 +97,6 @@ class Phcp extends CommonObject
103 97
 		
104 98
         $sql.= ") VALUES (";
105 99
         
106
-		$sql.= " ".(! isset($this->phcp_number)?'NULL':"'".$this->db->escape($this->phcp_number)."'").",";
107
-		$sql.= " ".(! isset($this->entity)?'NULL':"'".$this->entity."'").",";
108 100
 		$sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").",";
109 101
 		$sql.= " ".(! isset($this->ref_ext)?'NULL':"'".$this->db->escape($this->ref_ext)."'").",";
110 102
 		$sql.= " ".(! isset($this->ref_int)?'NULL':"'".$this->db->escape($this->ref_int)."'").",";
@@ -168,8 +160,6 @@ class Phcp extends CommonObject
168 160
         $sql = "SELECT";
169 161
 		$sql.= " t.rowid,";
170 162
 		
171
-		$sql.= " t.phcp_number,";
172
-		$sql.= " t.entity,";
173 163
 		$sql.= " t.nom,";
174 164
 		$sql.= " t.ref_ext,";
175 165
 		$sql.= " t.ref_int,";
@@ -189,8 +179,6 @@ class Phcp extends CommonObject
189 179
 
190 180
                 $this->id    = $obj->rowid;
191 181
                 
192
-				$this->phcp_number = $obj->phcp_number;
193
-				$this->entity = $obj->entity;
194 182
 				$this->nom = $obj->nom;
195 183
 				$this->ref_ext = $obj->ref_ext;
196 184
 				$this->ref_int = $obj->ref_int;
@@ -225,8 +213,6 @@ class Phcp extends CommonObject
225 213
 
226 214
 		// Clean parameters
227 215
         
228
-		if (isset($this->phcp_number)) $this->phcp_number=trim($this->phcp_number);
229
-		if (isset($this->entity)) $this->entity=trim($this->entity);
230 216
 		if (isset($this->nom)) $this->nom=trim($this->nom);
231 217
 		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
232 218
 		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
@@ -240,8 +226,6 @@ class Phcp extends CommonObject
240 226
         // Update request
241 227
         $sql = "UPDATE ".MAIN_DB_PREFIX."phcp SET";
242 228
         
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 229
 		$sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").",";
246 230
 		$sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").",";
247 231
 		$sql.= " ref_int=".(isset($this->ref_int)?"'".$this->db->escape($this->ref_int)."'":"null").",";
@@ -414,9 +398,6 @@ class Phcp extends CommonObject
414 398
 	function initAsSpecimen()
415 399
 	{
416 400
 		$this->id=0;
417
-		
418
-		$this->phcp_number='';
419
-		$this->entity='';
420 401
 		$this->nom='';
421 402
 		$this->ref_ext='';
422 403
 		$this->ref_int='';

+ 211
- 0
core/menus/standard/photocopiesmenu.php View File

@@ -0,0 +1,211 @@
1
+<?php
2
+/* Copyright (C) 2005-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
3
+ * Copyright (C) 2007-2009 Regis Houssin        <regis.houssin@capnetworks.com>
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       htdocs/core/menus/standard/eldy_menu.php
21
+ *	\brief      Menu eldy manager
22
+ */
23
+
24
+
25
+/**
26
+ *	Class to manage menu Eldy
27
+ */
28
+class MenuManager
29
+{
30
+	var $db;
31
+	var $type_user;									// Put 0 for internal users, 1 for external users
32
+	var $atarget="";                                // To store default target to use onto links
33
+	var $name="eldy";
34
+
35
+    var $menu_array;
36
+    var $menu_array_after;
37
+
38
+    var $tabMenu;
39
+
40
+
41
+    /**
42
+     *  Constructor
43
+     *
44
+	 *  @param	DoliDB		$db     	Database handler
45
+     *  @param	int			$type_user	Type of user
46
+     */
47
+    function __construct($db, $type_user)
48
+    {
49
+    	$this->type_user=$type_user;
50
+        $this->db=$db;
51
+    }
52
+
53
+
54
+    /**
55
+     * Load this->tabMenu
56
+     *
57
+   	 * @param	string	$forcemainmenu		To force mainmenu to load
58
+   	 * @param	string	$forceleftmenu		To force leftmenu to load
59
+     * @return	void
60
+     */
61
+    function loadMenu($forcemainmenu='',$forceleftmenu='')
62
+    {
63
+		// On sauve en session le menu principal choisi
64
+		if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"];
65
+		if (isset($_GET["idmenu"]))   $_SESSION["idmenu"]=$_GET["idmenu"];
66
+
67
+		// Read mainmenu and leftmenu that define which menu to show
68
+        if (isset($_GET["mainmenu"]))
69
+        {
70
+        	// On sauve en session le menu principal choisi
71
+        	$mainmenu=$_GET["mainmenu"];
72
+        	$_SESSION["mainmenu"]=$mainmenu;
73
+        	$_SESSION["leftmenuopened"]="";
74
+        }
75
+        else
76
+       {
77
+        	// On va le chercher en session si non defini par le lien
78
+        	$mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:'';
79
+        }
80
+        if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu;
81
+
82
+        if (isset($_GET["leftmenu"]))
83
+        {
84
+        	// On sauve en session le menu principal choisi
85
+        	$leftmenu=$_GET["leftmenu"];
86
+        	$_SESSION["leftmenu"]=$leftmenu;
87
+
88
+        	if ($_SESSION["leftmenuopened"]==$leftmenu)	// To collapse
89
+        	{
90
+        		//$leftmenu="";
91
+        		$_SESSION["leftmenuopened"]="";
92
+        	}
93
+        	else
94
+        	{
95
+        		$_SESSION["leftmenuopened"]=$leftmenu;
96
+        	}
97
+        } else {
98
+        	// On va le chercher en session si non defini par le lien
99
+        	$leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:'';
100
+        }
101
+        if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu;
102
+
103
+        require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
104
+        $tabMenu=array();
105
+        $menuArbo = new Menubase($this->db,'eldy');
106
+        $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'eldy', $tabMenu);
107
+        $this->tabMenu=$tabMenu;
108
+    }
109
+
110
+
111
+    /**
112
+     *  Show menu
113
+     *
114
+     *	@param	string	$mode			'top', 'left', 'jmobile'
115
+     *  @return int     				Number of menu entries shown
116
+     */
117
+    function showmenu($mode)
118
+    {
119
+    	global $conf, $langs, $user;
120
+
121
+        require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php';
122
+
123
+        if ($this->type_user == 1)
124
+        {
125
+        	$conf->global->MAIN_SEARCHFORM_SOCIETE=0;
126
+        	$conf->global->MAIN_SEARCHFORM_CONTACT=0;
127
+        }
128
+
129
+        $res='ErrorBadParameterForMode';
130
+
131
+		require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php';
132
+        $this->menu=new Menu();
133
+
134
+        if ($mode == 'top')  $res=print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0);
135
+        if ($mode == 'left') $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0);
136
+        if ($mode == 'jmobile')
137
+        {
138
+        	$res=print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1);
139
+
140
+        	print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n";
141
+        	foreach($this->menu->liste as $key => $val)		// $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
142
+        	{
143
+        		print '<ul class="ulmenu" data-role="listview" data-inset="true">';
144
+        		print '<li data-role="list-divider">';
145
+        		if ($val['enabled'] == 1)
146
+        		{
147
+					$relurl=dol_buildpath($val['url'],1);
148
+					$relurl=preg_replace('/__LOGIN__/',$user->login,$relurl);
149
+					$relurl=preg_replace('/__USERID__/',$user->id,$relurl);
150
+
151
+        			print '<a href="#">'.$val['titre'].'</a>'."\n";
152
+        			// Search submenu fot this entry
153
+        			$tmpmainmenu=$val['mainmenu'];
154
+        			$tmpleftmenu='all';
155
+        			$submenu=new Menu();
156
+	        		$res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu);
157
+        			$nexturl=dol_buildpath($submenu->liste[0]['url'],1);
158
+
159
+        			$canonrelurl=preg_replace('/\?.*$/','',$relurl);
160
+        			$canonnexturl=preg_replace('/\?.*$/','',$nexturl);
161
+        			//var_dump($canonrelurl);
162
+        			//var_dump($canonnexturl);
163
+        			print '<ul>'."\n";
164
+        			if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools')))
165
+        				|| (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/index.php') !== false))
166
+					{
167
+        				// We add sub entry
168
+        				print str_pad('',1).'<li data-role="list-divider" class="lilevel1 ui-btn-icon-right ui-btn">';	 // ui-btn to highlight on clic
169
+        				print '<a href="'.$relurl.'">';
170
+        				print str_pad('',12,'&nbsp;');
171
+        				print $langs->trans(ucfirst($val['mainmenu'])."Dashboard");
172
+        				print '</a>';
173
+        				print '</li>'."\n";
174
+        			}
175
+       				foreach($submenu->liste as $key2 => $val2)		// $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
176
+       				{
177
+        				$relurl2=dol_buildpath($val2['url'],1);
178
+	        			$relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2);
179
+    	    			$relurl2=preg_replace('/__USERID__/',$user->id,$relurl2);
180
+        				$canonurl2=preg_replace('/\?.*$/','',$val2['url']);
181
+        				//var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']);
182
+        				if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2='';
183
+        				if ($val2['level']==0) print str_pad('',$val2['level']+1).'<li'.($val2['level']==0?' data-role="list-divider"':'').' class="lilevel'.($val2['level']+1).' ui-btn-icon-right ui-btn">';	 // ui-btn to highlight on clic
184
+        				else print str_pad('',$val2['level']+1).'<li class="lilevel'.($val2['level']+1).'">';	 // ui-btn to highlight on clic
185
+        				if ($relurl2) print '<a href="'.$relurl2.'">';
186
+						print str_pad('',($val2['level']+1)*12,'&nbsp;');
187
+        				print $val2['titre'];
188
+        				if ($relurl2) print '</a>';
189
+        				print '</li>'."\n";
190
+       				}
191
+        			//var_dump($submenu);
192
+        			print '</ul>';
193
+        		}
194
+        		if ($val['enabled'] == 2)
195
+        		{
196
+        			print '<font class="vsmenudisabled">'.$val['titre'].'</font>';
197
+        		}
198
+        		print '</li>';
199
+        		print '</ul>'."\n";
200
+        	}
201
+        }
202
+
203
+        unset($this->menu);
204
+
205
+        //print 'xx'.$mode;
206
+        return $res;
207
+    }
208
+
209
+}
210
+
211
+?>

+ 178
- 53
core/modules/modPhotocopies.class.php View File

@@ -258,10 +258,35 @@ class modPhotocopies extends DolibarrModules
258 258
         	'fk_menu'=>0,
259 259
         	// This is a Top menu entry
260 260
         	'type'=>'top',
261
-        	'titre'=>'Compteurs',
261
+        	'titre'=>'Photocopies',
262 262
         	'mainmenu'=>'photocopies',
263
-        	'leftmenu'=>'photocopies',
264
-        	'url'=>'/photocopies/mypage.php',
263
+        	'leftmenu'=>'photocopieurs',
264
+        	'url'=>'/photocopies/index.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++;
280
+        $this->menu[$r]=array(
281
+        	// Use r=value where r is index key used for the parent menu entry
282
+        	// (higher parent must be a top menu entry)
283
+        	'fk_menu'=>'r=0',
284
+        	// This is a Left menu entry
285
+        	'type'=>'left',
286
+        	'titre'=>'Photocopieurs',
287
+        	'mainmenu'=>'photocopies',
288
+        	'leftmenu'=>'photocopieurs',
289
+        	'url'=>'/photocopies/phcp.php?action=list',
265 290
         	// Lang file to use (without .lang) by module.
266 291
         	// File must be in langs/code_CODE/ directory.
267 292
         	'langs'=>'photocopies',
@@ -277,58 +302,158 @@ class modPhotocopies extends DolibarrModules
277 302
         	'user'=>2
278 303
         );
279 304
         $r++;
280
-        //$this->menu[$r]=array(
281
-        //	// Use r=value where r is index key used for the parent menu entry
282
-        //	// (higher parent must be a top menu entry)
283
-        //	'fk_menu'=>'r=0',
284
-        //	// This is a Left menu entry
285
-        //	'type'=>'left',
286
-        //	'titre'=>'MyModule left menu',
287
-        //	'mainmenu'=>'photocopies',
288
-        //	'leftmenu'=>'photocopies',
289
-        //	'url'=>'/photocopies/pagelevel1.php',
290
-        //	// Lang file to use (without .lang) by module.
291
-        //	// File must be in langs/code_CODE/ directory.
292
-        //	'langs'=>'mylangfile',
293
-        //	'position'=>100,
294
-        //	// Define condition to show or hide menu entry.
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'
298
-        //	// if you want your menu with a permission rules
299
-        //	'perms'=>'1',
300
-        //	'target'=>'',
301
-        //	// 0=Menu for internal users, 1=external users, 2=both
302
-        //	'user'=>2
303
-        //);
304
-        //$r++;
305 305
         //
306 306
         // Example to declare a Left Menu entry into an existing Top menu entry:
307
-        //$this->menu[$r]=array(
308
-        //	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
309
-        //	'fk_menu'=>'fk_mainmenu=mainmenucode',
310
-        //	// This is a Left menu entry
311
-        //	'type'=>'left',
312
-        //	'titre'=>'MyModule left menu',
313
-        //	'mainmenu'=>'mainmenucode',
314
-        //	'leftmenu'=>'photocopies',
315
-        //	'url'=>'/photocopies/pagelevel2.php',
316
-        //	// Lang file to use (without .lang) by module.
317
-        //	// File must be in langs/code_CODE/ directory.
318
-        //	'langs'=>'mylangfile',
319
-        //	'position'=>100,
320
-        //	// Define condition to show or hide menu entry.
321
-        //	// Use '$conf->photocopies->enabled' if entry must be visible if module is enabled.
322
-        //	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
323
-        //	'enabled'=>'$conf->photocopies->enabled',
324
-        //	// Use 'perms'=>'$user->rights->photocopies->level1->level2'
325
-        //	// if you want your menu with a permission rules
326
-        //	'perms'=>'1',
327
-        //	'target'=>'',
328
-        //	// 0=Menu for internal users, 1=external users, 2=both
329
-        //	'user'=>2
330
-        //);
331
-        //$r++;
307
+        $this->menu[$r]=array(
308
+        	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
309
+        	'fk_menu'=>'fk_mainmenu=photocopies,fk_leftmenu=photocopieurs',
310
+        	// This is a Left menu entry
311
+        	'type'=>'left',
312
+        	'titre'=>'New Photocopieur',
313
+        	'mainmenu'=>'photocopies',
314
+        	'leftmenu'=>'new_phcp',
315
+        	'url'=>'/photocopies/phcp.php?action=new',
316
+        	// Lang file to use (without .lang) by module.
317
+        	// File must be in langs/code_CODE/ directory.
318
+        	'langs'=>'photocopies',
319
+        	'position'=>100,
320
+        	// Define condition to show or hide menu entry.
321
+        	// Use '$conf->photocopies->enabled' if entry must be visible if module is enabled.
322
+        	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
323
+        	'enabled'=>'$conf->photocopies->enabled',
324
+        	// Use 'perms'=>'$user->rights->photocopies->level1->level2'
325
+        	// if you want your menu with a permission rules
326
+        	'perms'=>'1',
327
+        	'target'=>'',
328
+        	// 0=Menu for internal users, 1=external users, 2=both
329
+        	'user'=>2
330
+        );
331
+        $r++;
332
+        $this->menu[$r]=array(
333
+        	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
334
+        	'fk_menu'=>'fk_mainmenu=photocopies,fk_leftmenu=photocopieurs',
335
+        	// This is a Left menu entry
336
+        	'type'=>'left',
337
+        	'titre'=>'List',
338
+        	'mainmenu'=>'photocopies',
339
+        	'leftmenu'=>'list_phcp',
340
+        	'url'=>'/photocopies/phcp.php?action=list',
341
+        	// Lang file to use (without .lang) by module.
342
+        	// File must be in langs/code_CODE/ directory.
343
+        	'langs'=>'photocopies',
344
+        	'position'=>100,
345
+        	// Define condition to show or hide menu entry.
346
+        	// Use '$conf->photocopies->enabled' if entry must be visible if module is enabled.
347
+        	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
348
+        	'enabled'=>'$conf->photocopies->enabled',
349
+        	// Use 'perms'=>'$user->rights->photocopies->level1->level2'
350
+        	// if you want your menu with a permission rules
351
+        	'perms'=>'1',
352
+        	'target'=>'',
353
+        	// 0=Menu for internal users, 1=external users, 2=both
354
+        	'user'=>2
355
+        );
356
+        $r++;
357
+        $this->menu[$r]=array(
358
+        	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
359
+        	'fk_menu'=>'r=0',
360
+        	// This is a Left menu entry
361
+        	'type'=>'left',
362
+        	'titre'=>'Photocopieur Types',
363
+        	'mainmenu'=>'photocopies',
364
+        	'leftmenu'=>'photocopieur_types',
365
+        	'url'=>'/photocopies/list_phcp_types.php',
366
+        	// Lang file to use (without .lang) by module.
367
+        	// File must be in langs/code_CODE/ directory.
368
+        	'langs'=>'photocopies',
369
+        	'position'=>100,
370
+        	// Define condition to show or hide menu entry.
371
+        	// Use '$conf->photocopies->enabled' if entry must be visible if module is enabled.
372
+        	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
373
+        	'enabled'=>'$conf->photocopies->enabled',
374
+        	// Use 'perms'=>'$user->rights->photocopies->level1->level2'
375
+        	// if you want your menu with a permission rules
376
+        	'perms'=>'1',
377
+        	'target'=>'',
378
+        	// 0=Menu for internal users, 1=external users, 2=both
379
+        	'user'=>2
380
+        );
381
+        $r++;
382
+        $this->menu[$r]=array(
383
+        	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
384
+        	'fk_menu'=>'fk_mainmenu=photocopies,fk_leftmenu=photocopieur_types',
385
+        	// This is a Left menu entry
386
+        	'type'=>'left',
387
+        	'titre'=>'New Photocopieur Type',
388
+        	'mainmenu'=>'photocopies',
389
+        	'leftmenu'=>'new_phcp_type',
390
+        	'url'=>'/photocopies/new_phcp_type.php',
391
+        	// Lang file to use (without .lang) by module.
392
+        	// File must be in langs/code_CODE/ directory.
393
+        	'langs'=>'photocopies',
394
+        	'position'=>100,
395
+        	// Define condition to show or hide menu entry.
396
+        	// Use '$conf->photocopies->enabled' if entry must be visible if module is enabled.
397
+        	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
398
+        	'enabled'=>'$conf->photocopies->enabled',
399
+        	// Use 'perms'=>'$user->rights->photocopies->level1->level2'
400
+        	// if you want your menu with a permission rules
401
+        	'perms'=>'1',
402
+        	'target'=>'',
403
+        	// 0=Menu for internal users, 1=external users, 2=both
404
+        	'user'=>2
405
+        );
406
+        $r++;
407
+        $this->menu[$r]=array(
408
+        	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
409
+        	'fk_menu'=>'fk_mainmenu=photocopies,fk_leftmenu=photocopieur_types',
410
+        	// This is a Left menu entry
411
+        	'type'=>'left',
412
+        	'titre'=>'List',
413
+        	'mainmenu'=>'photocopies',
414
+        	'leftmenu'=>'list_phcp_type',
415
+        	'url'=>'/photocopies/list_phcp_type.php',
416
+        	// Lang file to use (without .lang) by module.
417
+        	// File must be in langs/code_CODE/ directory.
418
+        	'langs'=>'photocopies',
419
+        	'position'=>100,
420
+        	// Define condition to show or hide menu entry.
421
+        	// Use '$conf->photocopies->enabled' if entry must be visible if module is enabled.
422
+        	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
423
+        	'enabled'=>'$conf->photocopies->enabled',
424
+        	// Use 'perms'=>'$user->rights->photocopies->level1->level2'
425
+        	// if you want your menu with a permission rules
426
+        	'perms'=>'1',
427
+        	'target'=>'',
428
+        	// 0=Menu for internal users, 1=external users, 2=both
429
+        	'user'=>2
430
+  );
431
+        $r++;
432
+        $this->menu[$r]=array(
433
+        	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
434
+        	'fk_menu'=>'r=0',
435
+        	// This is a Left menu entry
436
+        	'type'=>'left',
437
+        	'titre'=>'Compteurs',
438
+        	'mainmenu'=>'photocopies',
439
+        	'leftmenu'=>'compteurs',
440
+        	'url'=>'/photocopies/compteurs.php',
441
+        	// Lang file to use (without .lang) by module.
442
+        	// File must be in langs/code_CODE/ directory.
443
+        	'langs'=>'photocopies',
444
+        	'position'=>100,
445
+        	// Define condition to show or hide menu entry.
446
+        	// Use '$conf->photocopies->enabled' if entry must be visible if module is enabled.
447
+        	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
448
+        	'enabled'=>'$conf->photocopies->enabled',
449
+        	// Use 'perms'=>'$user->rights->photocopies->level1->level2'
450
+        	// if you want your menu with a permission rules
451
+        	'perms'=>'1',
452
+        	'target'=>'',
453
+        	// 0=Menu for internal users, 1=external users, 2=both
454
+        	'user'=>2
455
+        );
456
+        $r++;
332 457
         // Exports
333 458
         $r = 1;
334 459
 

+ 36
- 0
index.php View File

@@ -15,3 +15,39 @@
15 15
  * You should have received a copy of the GNU General Public License
16 16
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
  */
18
+$res=0;
19
+if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php';
20
+if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php';
21
+if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php';
22
+if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php';     // Used on dev env only
23
+if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php';   // Used on dev env only
24
+if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php';   // Used on dev env only
25
+if (! $res) die("Include of main fails");
26
+// Change this following line to use the correct relative path from htdocs
27
+dol_include_once('/module/class/phcp.class.php');
28
+
29
+// Load traductions files requiredby by page
30
+$langs->load("companies");
31
+$langs->load("other");
32
+
33
+// Get parameters
34
+$id			= GETPOST('id','int');
35
+$action		= GETPOST('action','alpha');
36
+$myparam	= GETPOST('myparam','alpha');
37
+
38
+// Protection if external user
39
+if ($user->societe_id > 0)
40
+{
41
+	//accessforbidden();
42
+}
43
+
44
+
45
+
46
+llxHeader('','Liste des Photocopieurs','');
47
+
48
+
49
+
50
+// End of page
51
+llxFooter();
52
+$db->close();
53
+?>

+ 136
- 0
list_phcp.php View File

@@ -0,0 +1,136 @@
1
+<?php
2
+$res=0;
3
+if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php';
4
+if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php';
5
+if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php';
6
+if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php';     // Used on dev env only
7
+if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php';   // Used on dev env only
8
+if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php';   // Used on dev env only
9
+if (! $res) die("Include of main fails");
10
+// Change this following line to use the correct relative path from htdocs
11
+dol_include_once('/module/class/phcp.class.php');
12
+
13
+// Load traductions files requiredby by page
14
+$langs->load("companies");
15
+$langs->load("other");
16
+
17
+// Get parameters
18
+$id			= GETPOST('id','int');
19
+$action		= GETPOST('action','alpha');
20
+$myparam	= GETPOST('myparam','alpha');
21
+
22
+// Protection if external user
23
+if ($user->societe_id > 0)
24
+{
25
+	//accessforbidden();
26
+}
27
+
28
+
29
+
30
+/*******************************************************************
31
+* ACTIONS
32
+*
33
+* Put here all code to do according to value of "action" parameter
34
+********************************************************************/
35
+
36
+/***************************************************
37
+* VIEW
38
+*
39
+* Put here all code to build page
40
+****************************************************/
41
+
42
+llxHeader('','Liste des Photocopieurs','');
43
+
44
+?>
45
+
46
+<div class="fiche"> <!-- begin div class="fiche" -->
47
+
48
+  <table width="100%" border="0" style="margin-bottom: 2px;" class="notopnoleftnoright" summary="">
49
+    <tbody>
50
+      <tr>
51
+         <td width="40" valign="middle" align="left" class="nobordernopadding hideonsmartphone">
52
+          <img border="0" id="pictotitle" title="" alt="" src="/dolibarr/theme/auguria/img/title.png">
53
+        </td>
54
+        <td valign="middle" class="nobordernopadding">
55
+          <div class="titre">Liste des photocopieurs</div>
56
+        </td>
57
+      </tr>
58
+    </tbody>
59
+  </table>
60
+  <div class="fichecenter">
61
+    <div class="fichethirdleft">
62
+
63
+<?php
64
+
65
+$form=new Form($db);
66
+
67
+
68
+    $sql = "SELECT";
69
+    $sql.= " p.rowid,";
70
+    
71
+		$sql.= " p.phcp_number,";
72
+		$sql.= " p.entity,";
73
+		$sql.= " p.nom,";
74
+		$sql.= " p.ref_ext,";
75
+		$sql.= " p.ref_int,";
76
+		$sql.= " pt.nom as phcp_type";
77
+
78
+    
79
+    $sql.= " FROM ".MAIN_DB_PREFIX."phcp as p, ";
80
+    $sql.= MAIN_DB_PREFIX."phcp_type as pt";
81
+    $sql.= " WHERE pt.rowid = p.fk_phcp_type";
82
+
83
+    print '<table class="noborder" width="100%">'."\n";
84
+    print '<tr class="liste_titre">';
85
+    print_liste_field_titre($langs->trans('rowid'),$_SERVER['PHP_SELF'],'p.rowid','',$param,'',$sortfield,$sortorder);
86
+    print_liste_field_titre($langs->trans('nom'),$_SERVER['PHP_SELF'],'p.nom','',$param,'',$sortfield,$sortorder);
87
+    print_liste_field_titre($langs->trans('phcp_type'),$_SERVER['PHP_SELF'],'pt.nom','',$param,'',$sortfield,$sortorder);
88
+    print '</tr>';
89
+
90
+    dol_syslog($script_file." sql=".$sql, LOG_DEBUG);
91
+    $resql=$db->query($sql);
92
+    if ($resql)
93
+    {
94
+        $num = $db->num_rows($resql);
95
+        $i = 0;
96
+        $url = DOL_URL_ROOT."/photocopies/phcp.php?id=";
97
+        if ($num)
98
+        {
99
+            while ($i < $num)
100
+            {
101
+                $obj = $db->fetch_object($resql);
102
+                if ($obj)
103
+                {
104
+                    // You can use here results
105
+                    print '<tr><td>';
106
+                    print $obj->rowid;
107
+                    print '</td><td><a href="'.$url.$obj->rowid.'">';
108
+                    print $obj->nom;
109
+                    print '</a></td><td>';
110
+                    print $obj->phcp_type;
111
+                    print '</td></tr>';
112
+                }
113
+                $i++;
114
+            }
115
+        }
116
+    }
117
+    else
118
+    {
119
+        $error++;
120
+        dol_print_error($db);
121
+    }
122
+
123
+    print '</table>'."\n";
124
+
125
+
126
+
127
+// End of page
128
+llxFooter();
129
+$db->close();
130
+?>
131
+
132
+
133
+
134
+    </div>
135
+  </div>
136
+</div>

+ 3
- 3
mypage.php View File

@@ -63,7 +63,7 @@ if (! $res) {
63 63
 }
64 64
 // Change this following line to use the correct relative path from htdocs
65 65
 // (do not remove DOL_DOCUMENT_ROOT)
66
-require_once DOL_DOCUMENT_ROOT . "photocopies/class/myclass.class.php";
66
+require_once DOL_DOCUMENT_ROOT . "/photocopies/class/myclass.class.php";
67 67
 
68 68
 // Load translation files required by the page
69 69
 $langs->load("photocopies@photocopies");
@@ -104,7 +104,7 @@ if ($action == 'add') {
104 104
  * Put here all code to build page
105 105
  */
106 106
 
107
-llxHeader('', 'MyPageName', '');
107
+llxHeader('', 'Photocopies', '');
108 108
 
109 109
 $form = new Form($db);
110 110
 
@@ -112,7 +112,7 @@ $form = new Form($db);
112 112
 // Example 1 : Adding jquery code
113 113
 echo '<script type="text/javascript" language="javascript">
114 114
 jQuery(document).ready(function() {
115
-    public function init_myfunc()
115
+    function init_myfunc()
116 116
     {
117 117
         jQuery("#myid").removeAttr(\'disabled\');
118 118
         jQuery("#myid").attr(\'disabled\',\'disabled\');

+ 268
- 0
phcp.php View File

@@ -0,0 +1,268 @@
1
+<?php
2
+$res=0;
3
+if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php';
4
+if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php';
5
+if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php';
6
+if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php';     // Used on dev env only
7
+if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php';   // Used on dev env only
8
+if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php';   // Used on dev env only
9
+if (! $res) die("Include of main fails");
10
+// Change this following line to use the correct relative path from htdocs
11
+dol_include_once('/photocopies/class/phcp.class.php');
12
+
13
+// Load traductions files requiredby by page
14
+$langs->load("companies");
15
+$langs->load("other");
16
+
17
+// Get parameters
18
+$id			  = GETPOST('id','int');
19
+$action		= GETPOST('action','alpha');
20
+$myparam	= GETPOST('myparam','alpha');
21
+$url      = DOL_URL_ROOT."/photocopies/phcp.php";
22
+$phcp     = null;
23
+$title    = null;
24
+
25
+if($id){
26
+// Replace with class :
27
+// $phcp = new Phcp($db);
28
+// $phcp->fetch($id);
29
+// echo "<pre>".var_dump($phcp)."</pre>";
30
+  $sql = "SELECT";
31
+  $sql.= " p.rowid,";
32
+	$sql.= " p.nom,";
33
+	$sql.= " p.fk_phcp_type,";
34
+	$sql.= " pt.nom as phcp_type";
35
+  $sql.= " FROM ".MAIN_DB_PREFIX."phcp as p, ";
36
+  $sql.= MAIN_DB_PREFIX."phcp_type as pt";
37
+  $sql.= " WHERE p.rowid = ".$id; 
38
+  $sql.= " AND pt.rowid = p.fk_phcp_type";
39
+  $resql=$db->query($sql);
40
+  if($resql){
41
+    $num = $db->num_rows($resql);
42
+    $i = 0;
43
+    if ($num){
44
+      while ($i < $num){
45
+        $obj = $db->fetch_object($resql);
46
+        if ($obj){ $phcp = $obj; }
47
+        $i++;
48
+      }
49
+    }
50
+  }
51
+}
52
+
53
+
54
+/*******************************************************************
55
+* ACTIONS
56
+*
57
+* Put here all code to do according to value of "action" parameter
58
+********************************************************************/
59
+
60
+//------------------------------------------------------------------------------
61
+if ($action == 'create') {
62
+	$phcp = new Phcp($db);
63
+	$phcp->nom=$_POST["nom"];
64
+	$phcp->fk_phcp_type=$_POST["fk_phcp_type"];
65
+	$result = $phcp->create($user);
66
+	if ($result > 0)
67
+	{
68
+    // Creation OK
69
+    $action = 'show';
70
+  } 
71
+	{
72
+		// Creation KO
73
+    $action = 'edit';
74
+	}
75
+}
76
+//------------------------------------------------------------------------------
77
+elseif ($action == 'update'){
78
+  $phcp = new Phcp($db);
79
+  $phcp->fetch($id);
80
+	$phcp->nom=$_POST["nom"];
81
+	$phcp->fk_phcp_type=$_POST["fk_phcp_type"];
82
+	$result = $phcp->update($user);
83
+	if ($result > 0)
84
+	{
85
+    // Creation OK
86
+    $action = 'show';
87
+  } 
88
+	{
89
+		// Creation KO
90
+    $action = 'edit';
91
+	}
92
+}
93
+
94
+$phcp_types = "";
95
+
96
+if($action == 'new' || $action == 'edit'){
97
+  $sql = "SELECT pt.rowid, pt.nom ";
98
+  $sql.= "FROM ".MAIN_DB_PREFIX."phcp_type as pt";
99
+  $resql=$db->query($sql);
100
+  if($resql){
101
+    $num = $db->num_rows($resql);
102
+    $i = 0;
103
+    if ($num){
104
+      while ($i < $num){
105
+        $obj = $db->fetch_object($resql);
106
+        if ($obj){
107
+          $extra = "";
108
+          if($phcp && $phcp->fk_phcp_type == $obj->rowid){ $extra = 'selected="selected"'; }
109
+          $phcp_types.= '<option value="'.$obj->rowid.'" '.$extra.'>'.$obj->nom.'</option>'."\n";
110
+        }
111
+        $i++;
112
+      }
113
+    }
114
+  }
115
+}
116
+
117
+switch($action){
118
+  case 'new': $title = "Nouveau Photocopieur"; llxHeader('',$title,''); break;
119
+  case 'edit': $title = "Modifier Photocopieur"; llxHeader('',$title,''); break;
120
+  case 'list': $title = "Liste des Photocopieurs"; llxHeader('',$title,''); break;
121
+  case 'show': $title = "Photocopieur : ".$phcp->nom; llxHeader('',$title,''); break;
122
+}
123
+
124
+//===============================[TEMPLATE]=====================================
125
+if($phcp && $phcp->error){
126
+?>
127
+<script type="text/javascript">
128
+  $(document).ready(function(){
129
+    $.jnotify("<?= $phcp->error ?>", "error");
130
+  })
131
+</script>
132
+<?php } ?>
133
+
134
+<div class="fiche">
135
+  <table width="100%" border="0" style="margin-bottom: 2px;" class="notopnoleftnoright" summary="">
136
+    <tbody>
137
+      <tr>
138
+        <td width="40" valign="middle" align="left" class="nobordernopadding hideonsmartphone">
139
+          <img border="0" id="pictotitle" title="" alt="" src="/dolibarr/theme/auguria/img/title.png">
140
+        </td>
141
+        <td valign="middle" class="nobordernopadding">
142
+          <div class="titre"><?= $title ?></div>
143
+        </td>
144
+      </tr>
145
+    </tbody>
146
+  </table>
147
+
148
+  <div class="fichecenter">
149
+    <div class="fichethirdleft">
150
+
151
+<?php
152
+//------------------------------------------------------------------------------
153
+if ($action == 'new') {       
154
+?>
155
+  <form action="<?= $url."?action=create" ?>" method="POST">
156
+    <label for="phcp_nom">Nom du photocopieur</label>
157
+    <input name="nom" id="phcp_nom" type="text" placeholder="Nom du photocopieur" /><br />
158
+    <label for="phcp_type">Type de photocopieur</label>
159
+    <select name="fk_phcp_type" id="phcp_type" placeholder="Type de photocopieur">
160
+      <?= $phcp_types ?>
161
+    </select><br />
162
+    <div class="tabsAction">
163
+      <div class="inline-block divButAction">
164
+        <input type="submit" class="butAction" value="Créer" />
165
+      </div>
166
+    </div>
167
+  </form>
168
+<?php
169
+}        
170
+//------------------------------------------------------------------------------
171
+elseif ($action == 'edit') {
172
+?>
173
+  <form action="<?= $url."?action=update" ?>" method="POST">
174
+    <input type="hidden" name="id" value="<?= $id ?>" />
175
+    <label for="phcp_nom">Nom du photocopieur</label>
176
+    <input name="nom" id="phcp_nom" type="text" placeholder="Nom du photocopieur" value="<?= $phcp->nom ?>" /><br />
177
+    <label for="phcp_type">Type de photocopieur</label>
178
+    <select name="fk_phcp_type" id="phcp_type" placeholder="Type de photocopieur">
179
+      <?= $phcp_types ?>
180
+    </select><br />
181
+    <div class="tabsAction">
182
+      <div class="inline-block divButAction">
183
+        <input type="submit" class="butAction" value="Modifier" />
184
+      </div>
185
+    </div>
186
+  </form>
187
+<?php
188
+        
189
+} 
190
+//------------------------------------------------------------------------------
191
+elseif ($action == 'show') { 
192
+?>
193
+  <strong>Nom : </strong><?= $phcp->nom ?><br />
194
+  <strong>Phococopieur Type : </strong><?= $phcp->phcp_type ?><br />
195
+  <div class="tabsAction">
196
+    <div class="inline-block divButAction">
197
+      <a href="<?= $url."?id=".$phcp->rowid."&action=edit" ?>" class="butAction">
198
+        Modifier
199
+      </a>
200
+    </div>
201
+    <div class="inline-block divButAction">
202
+      <span class="butActionDelete" id="action-delete">Delete</span>
203
+    </div>
204
+  </div>
205
+<?php 
206
+}
207
+//------------------------------------------------------------------------------
208
+else {
209
+
210
+  $form=new Form($db);
211
+  $sql = "SELECT";
212
+  $sql.= " p.rowid,";
213
+	$sql.= " p.nom,";
214
+	$sql.= " pt.nom as phcp_type";
215
+  $sql.= " FROM ".MAIN_DB_PREFIX."phcp as p, ";
216
+  $sql.= MAIN_DB_PREFIX."phcp_type as pt";
217
+  $sql.= " WHERE pt.rowid = p.fk_phcp_type";
218
+
219
+  print '<table class="noborder" width="100%">'."\n";
220
+  print '<tr class="liste_titre">';
221
+  print_liste_field_titre($langs->trans('rowid'),$_SERVER['PHP_SELF'],'p.rowid','',$param,'',$sortfield,$sortorder);
222
+  print_liste_field_titre($langs->trans('nom'),$_SERVER['PHP_SELF'],'p.nom','',$param,'',$sortfield,$sortorder);
223
+  print_liste_field_titre($langs->trans('phcp_type'),$_SERVER['PHP_SELF'],'pt.nom','',$param,'',$sortfield,$sortorder);
224
+  print '</tr>';
225
+
226
+  dol_syslog($script_file." sql=".$sql, LOG_DEBUG);
227
+  $resql=$db->query($sql);
228
+  if ($resql)
229
+  {
230
+      $num = $db->num_rows($resql);
231
+      $i = 0;
232
+      if ($num)
233
+      {
234
+          while ($i < $num)
235
+          {
236
+              $obj = $db->fetch_object($resql);
237
+              if ($obj)
238
+              {
239
+                  // You can use here results
240
+                  print '<tr><td>';
241
+                  print $obj->rowid;
242
+                  print '</td><td><a href="'.$url.'?id='.$obj->rowid.'&action=show">';
243
+                  print $obj->nom;
244
+                  print '</a></td><td>';
245
+                  print $obj->phcp_type;
246
+                  print '</td></tr>';
247
+              }
248
+              $i++;
249
+          }
250
+      }
251
+  }
252
+  else
253
+  {
254
+      $error++;
255
+      dol_print_error($db);
256
+  }
257
+  print '</table>'."\n";
258
+}
259
+?>
260
+    </div>
261
+  </div>
262
+</div> 
263
+
264
+<?php
265
+  // End of page
266
+  llxFooter();
267
+  $db->close();
268
+?>

+ 0
- 188
phcp_page.php View File

@@ -1,188 +0,0 @@
1
-<?php
2
-/* Copyright (C) 2007-2010 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/Phcps/Phcp_page.php
21
- *		\ingroup    mymodule othermodule1 othermodule2
22
- *		\brief      This file is an example of a php page
23
- *					Initialy built by build_class_from_table on 2013-09-12 16:46
24
- */
25
-
26
-//if (! defined('NOREQUIREUSER'))  define('NOREQUIREUSER','1');
27
-//if (! defined('NOREQUIREDB'))    define('NOREQUIREDB','1');
28
-//if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
29
-//if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
30
-//if (! defined('NOCSRFCHECK'))    define('NOCSRFCHECK','1');			// Do not check anti CSRF attack test
31
-//if (! defined('NOSTYLECHECK'))   define('NOSTYLECHECK','1');			// Do not check style html tag into posted data
32
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');		// Do not check anti POST attack test
33
-//if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');			// If there is no need to load and show top and left menu
34
-//if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');			// If we don't need to load the html.form.class.php
35
-//if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
36
-//if (! defined("NOLOGIN"))        define("NOLOGIN",'1');				// If this page is public (can be called outside logged session)
37
-
38
-// Change this following line to use the correct relative path (../, ../../, etc)
39
-$res=0;
40
-if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php';
41
-if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php';
42
-if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php';
43
-if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php';     // Used on dev env only
44
-if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php';   // Used on dev env only
45
-if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php';   // Used on dev env only
46
-if (! $res) die("Include of main fails");
47
-// Change this following line to use the correct relative path from htdocs
48
-dol_include_once('/module/class/phcp.class.php');
49
-
50
-// Load traductions files requiredby by page
51
-$langs->load("companies");
52
-$langs->load("other");
53
-
54
-// Get parameters
55
-$id			= GETPOST('id','int');
56
-$action		= GETPOST('action','alpha');
57
-$myparam	= GETPOST('myparam','alpha');
58
-
59
-// Protection if external user
60
-if ($user->societe_id > 0)
61
-{
62
-	//accessforbidden();
63
-}
64
-
65
-
66
-
67
-/*******************************************************************
68
-* ACTIONS
69
-*
70
-* Put here all code to do according to value of "action" parameter
71
-********************************************************************/
72
-
73
-if ($action == 'add')
74
-{
75
-	$object=new Phcp($db);
76
-	$object->prop1=$_POST["field1"];
77
-	$object->prop2=$_POST["field2"];
78
-	$result=$object->create($user);
79
-	if ($result > 0)
80
-	{
81
-		// Creation OK
82
-	}
83
-	{
84
-		// Creation KO
85
-		$mesg=$object->error;
86
-	}
87
-}
88
-
89
-
90
-
91
-
92
-
93
-/***************************************************
94
-* VIEW
95
-*
96
-* Put here all code to build page
97
-****************************************************/
98
-
99
-llxHeader('','MyPageName','');
100
-
101
-$form=new Form($db);
102
-
103
-
104
-// Put here content of your page
105
-
106
-// Example 1 : Adding jquery code
107
-print '<script type="text/javascript" language="javascript">
108
-jQuery(document).ready(function() {
109
-	function init_myfunc()
110
-	{
111
-		jQuery("#myid").removeAttr(\'disabled\');
112
-		jQuery("#myid").attr(\'disabled\',\'disabled\');
113
-	}
114
-	init_myfunc();
115
-	jQuery("#mybutton").click(function() {
116
-		init_needroot();
117
-	});
118
-});
119
-</script>';
120
-
121
-
122
-// Example 2 : Adding links to objects
123
-// The class must extends CommonObject class to have this method available
124
-//$somethingshown=$object->showLinkedObjectBlock();
125
-
126
-
127
-// Example 3 : List of data
128
-if ($action == 'list')
129
-{
130
-    $sql = "SELECT";
131
-    $sql.= " t.rowid,";
132
-    
133
-		$sql.= " t.phcp_number,";
134
-		$sql.= " t.entity,";
135
-		$sql.= " t.nom,";
136
-		$sql.= " t.ref_ext,";
137
-		$sql.= " t.ref_int,";
138
-		$sql.= " t.fk_phcp_type";
139
-
140
-    
141
-    $sql.= " FROM ".MAIN_DB_PREFIX."phcp as t";
142
-    $sql.= " WHERE field3 = 'xxx'";
143
-    $sql.= " ORDER BY field1 ASC";
144
-
145
-    print '<table class="noborder">'."\n";
146
-    print '<tr class="liste_titre">';
147
-    print_liste_field_titre($langs->trans('field1'),$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
148
-    print_liste_field_titre($langs->trans('field2'),$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
149
-    print '</tr>';
150
-
151
-    dol_syslog($script_file." sql=".$sql, LOG_DEBUG);
152
-    $resql=$db->query($sql);
153
-    if ($resql)
154
-    {
155
-        $num = $db->num_rows($resql);
156
-        $i = 0;
157
-        if ($num)
158
-        {
159
-            while ($i < $num)
160
-            {
161
-                $obj = $db->fetch_object($resql);
162
-                if ($obj)
163
-                {
164
-                    // You can use here results
165
-                    print '<tr><td>';
166
-                    print $obj->field1;
167
-                    print $obj->field2;
168
-                    print '</td></tr>';
169
-                }
170
-                $i++;
171
-            }
172
-        }
173
-    }
174
-    else
175
-    {
176
-        $error++;
177
-        dol_print_error($db);
178
-    }
179
-
180
-    print '</table>'."\n";
181
-}
182
-
183
-
184
-
185
-// End of page
186
-llxFooter();
187
-$db->close();
188
-?>

+ 0
- 189
societephcpproduct_page.php View File

@@ -1,189 +0,0 @@
1
-<?php
2
-/* Copyright (C) 2007-2010 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/Societephcpproducts/Societephcpproduct_page.php
21
- *		\ingroup    mymodule othermodule1 othermodule2
22
- *		\brief      This file is an example of a php page
23
- *					Initialy built by build_class_from_table on 2013-09-12 16:47
24
- */
25
-
26
-//if (! defined('NOREQUIREUSER'))  define('NOREQUIREUSER','1');
27
-//if (! defined('NOREQUIREDB'))    define('NOREQUIREDB','1');
28
-//if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
29
-//if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
30
-//if (! defined('NOCSRFCHECK'))    define('NOCSRFCHECK','1');			// Do not check anti CSRF attack test
31
-//if (! defined('NOSTYLECHECK'))   define('NOSTYLECHECK','1');			// Do not check style html tag into posted data
32
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');		// Do not check anti POST attack test
33
-//if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');			// If there is no need to load and show top and left menu
34
-//if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');			// If we don't need to load the html.form.class.php
35
-//if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
36
-//if (! defined("NOLOGIN"))        define("NOLOGIN",'1');				// If this page is public (can be called outside logged session)
37
-
38
-// Change this following line to use the correct relative path (../, ../../, etc)
39
-$res=0;
40
-if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php';
41
-if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php';
42
-if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php';
43
-if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php';     // Used on dev env only
44
-if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php';   // Used on dev env only
45
-if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php';   // Used on dev env only
46
-if (! $res) die("Include of main fails");
47
-// Change this following line to use the correct relative path from htdocs
48
-dol_include_once('/module/class/societephcpproduct.class.php');
49
-
50
-// Load traductions files requiredby by page
51
-$langs->load("companies");
52
-$langs->load("other");
53
-
54
-// Get parameters
55
-$id			= GETPOST('id','int');
56
-$action		= GETPOST('action','alpha');
57
-$myparam	= GETPOST('myparam','alpha');
58
-
59
-// Protection if external user
60
-if ($user->societe_id > 0)
61
-{
62
-	//accessforbidden();
63
-}
64
-
65
-
66
-
67
-/*******************************************************************
68
-* ACTIONS
69
-*
70
-* Put here all code to do according to value of "action" parameter
71
-********************************************************************/
72
-
73
-if ($action == 'add')
74
-{
75
-	$object=new Societephcpproduct($db);
76
-	$object->prop1=$_POST["field1"];
77
-	$object->prop2=$_POST["field2"];
78
-	$result=$object->create($user);
79
-	if ($result > 0)
80
-	{
81
-		// Creation OK
82
-	}
83
-	{
84
-		// Creation KO
85
-		$mesg=$object->error;
86
-	}
87
-}
88
-
89
-
90
-
91
-
92
-
93
-/***************************************************
94
-* VIEW
95
-*
96
-* Put here all code to build page
97
-****************************************************/
98
-
99
-llxHeader('','MyPageName','');
100
-
101
-$form=new Form($db);
102
-
103
-
104
-// Put here content of your page
105
-
106
-// Example 1 : Adding jquery code
107
-print '<script type="text/javascript" language="javascript">
108
-jQuery(document).ready(function() {
109
-	function init_myfunc()
110
-	{
111
-		jQuery("#myid").removeAttr(\'disabled\');
112
-		jQuery("#myid").attr(\'disabled\',\'disabled\');
113
-	}
114
-	init_myfunc();
115
-	jQuery("#mybutton").click(function() {
116
-		init_needroot();
117
-	});
118
-});
119
-</script>';
120
-
121
-
122
-// Example 2 : Adding links to objects
123
-// The class must extends CommonObject class to have this method available
124
-//$somethingshown=$object->showLinkedObjectBlock();
125
-
126
-
127
-// Example 3 : List of data
128
-if ($action == 'list')
129
-{
130
-    $sql = "SELECT";
131
-    $sql.= " t.rowid,";
132
-    
133
-		$sql.= " t.societe_phcp_product_number,";
134
-		$sql.= " t.entity,";
135
-		$sql.= " t.ref_ext,";
136
-		$sql.= " t.ref_int,";
137
-		$sql.= " t.fk_phcp,";
138
-		$sql.= " t.fk_societe,";
139
-		$sql.= " t.fk_product";
140
-
141
-    
142
-    $sql.= " FROM ".MAIN_DB_PREFIX."societe_phcp_product as t";
143
-    $sql.= " WHERE field3 = 'xxx'";
144
-    $sql.= " ORDER BY field1 ASC";
145
-
146
-    print '<table class="noborder">'."\n";
147
-    print '<tr class="liste_titre">';
148
-    print_liste_field_titre($langs->trans('field1'),$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
149
-    print_liste_field_titre($langs->trans('field2'),$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
150
-    print '</tr>';
151
-
152
-    dol_syslog($script_file." sql=".$sql, LOG_DEBUG);
153
-    $resql=$db->query($sql);
154
-    if ($resql)
155
-    {
156
-        $num = $db->num_rows($resql);
157
-        $i = 0;
158
-        if ($num)
159
-        {
160
-            while ($i < $num)
161
-            {
162
-                $obj = $db->fetch_object($resql);
163
-                if ($obj)
164
-                {
165
-                    // You can use here results
166
-                    print '<tr><td>';
167
-                    print $obj->field1;
168
-                    print $obj->field2;
169
-                    print '</td></tr>';
170
-                }
171
-                $i++;
172
-            }
173
-        }
174
-    }
175
-    else
176
-    {
177
-        $error++;
178
-        dol_print_error($db);
179
-    }
180
-
181
-    print '</table>'."\n";
182
-}
183
-
184
-
185
-
186
-// End of page
187
-llxFooter();
188
-$db->close();
189
-?>

+ 64
- 0
sql/data.sql View File

@@ -13,3 +13,67 @@
13 13
 --
14 14
 -- You should have received a copy of the GNU General Public License
15 15
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
+
17
+-- Types de photocopieurs
18
+insert into llx_phcp_type(rowid, nom)
19
+values (1, "Photocopieur Type A") on duplicate key update nom=values(nom);
20
+insert into llx_phcp_type(rowid, nom)
21
+values (2, "Photocopieur Type B") on duplicate key update nom=values(nom);
22
+
23
+-- Ressources Photocopieur
24
+insert into llx_phcp (rowid, nom, fk_phcp_type, fk_societe) 
25
+values (1, "Photocopieur Type A n1", 1, 1) on duplicate key update nom=values(nom), fk_phcp_type=values(fk_phcp_type), fk_societe=values(fk_societe);
26
+insert into llx_phcp (rowid, nom, fk_phcp_type, fk_societe) 
27
+values (2, "Photocopieur Type A n2", 1, 2) on duplicate key update nom=values(nom), fk_phcp_type=values(fk_phcp_type), fk_societe=values(fk_societe);
28
+insert into llx_phcp (rowid, nom, fk_phcp_type, fk_societe) 
29
+values (3, "Photocopieur Type A n3", 1, 3) on duplicate key update nom=values(nom), fk_phcp_type=values(fk_phcp_type), fk_societe=values(fk_societe);
30
+insert into llx_phcp (rowid, nom, fk_phcp_type, fk_societe) 
31
+values (4, "Photocopieur Type B n1", 2, 4) on duplicate key update nom=values(nom), fk_phcp_type=values(fk_phcp_type), fk_societe=values(fk_societe);
32
+insert into llx_phcp (rowid, nom, fk_phcp_type, fk_societe) 
33
+values (5, "Photocopieur Type B n2", 2, 1) on duplicate key update nom=values(nom), fk_phcp_type=values(fk_phcp_type), fk_societe=values(fk_societe);
34
+
35
+-- Type de photocopieurs avec leur tarifs
36
+insert into llx_phcp_type_product(rowid, fk_phcp_type, fk_product)
37
+values (1, 1, 2) on duplicate key update fk_phcp_type=values(fk_phcp_type), fk_product=values(fk_product);
38
+insert into llx_phcp_type_product(rowid, fk_phcp_type, fk_product)
39
+values (2, 1, 3) on duplicate key update fk_phcp_type=values(fk_phcp_type), fk_product=values(fk_product);
40
+insert into llx_phcp_type_product(rowid, fk_phcp_type, fk_product)
41
+values (3, 2, 1) on duplicate key update fk_phcp_type=values(fk_phcp_type), fk_product=values(fk_product);
42
+insert into llx_phcp_type_product(rowid, fk_phcp_type, fk_product)
43
+values (4, 2, 2) on duplicate key update fk_phcp_type=values(fk_phcp_type), fk_product=values(fk_product);
44
+insert into llx_phcp_type_product(rowid, fk_phcp_type, fk_product)
45
+values (5, 2, 3) on duplicate key update fk_phcp_type=values(fk_phcp_type), fk_product=values(fk_product);
46
+insert into llx_phcp_type_product(rowid, fk_phcp_type, fk_product)
47
+values (6, 2, 4) on duplicate key update fk_phcp_type=values(fk_phcp_type), fk_product=values(fk_product);
48
+
49
+-- Photocopieurs et leur compteurs
50
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
51
+values (1, 1, 2, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
52
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
53
+values (2, 1, 3, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
54
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
55
+values (3, 2, 2, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
56
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
57
+values (4, 2, 3, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
58
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
59
+values (5, 3, 2, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
60
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
61
+values (6, 3, 3, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
62
+
63
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
64
+values (7, 4, 1, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
65
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
66
+values (8, 4, 2, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
67
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
68
+values (9, 4, 3, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
69
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
70
+values (10, 4, 4, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
71
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
72
+values (11, 5, 1, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
73
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
74
+values (12, 5, 2, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
75
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
76
+values (13, 5, 3, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
77
+insert into llx_phcp_product(rowid, fk_phcp, fk_product, last_compteur, compteur)
78
+values (14, 5, 4, 0, 0) on duplicate key update fk_phcp=values(fk_phcp), fk_product=values(fk_product), last_compteur=values(last_compteur), compteur=values(compteur);
79
+

+ 4
- 2
sql/llx_phcp.key.sql View File

@@ -14,8 +14,10 @@
14 14
 -- You should have received a copy of the GNU General Public License
15 15
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16
 
17
-ALTER TABLE llx_phcp ADD UNIQUE INDEX idx_phcp_uk_phcp_number (phcp_number, entity);
17
+--ALTER TABLE llx_phcp ADD UNIQUE INDEX idx_phcp_uk_phcp_number (phcp_number, entity);
18 18
 
19 19
 ALTER TABLE llx_phcp ADD INDEX idx_phcp_fk_phcp_type (fk_phcp_type);
20
+ALTER TABLE llx_phcp ADD INDEX idx_phcp_fk_societe (fk_societe);
20 21
 
21
-ALTER TABLE llx_phcp ADD CONSTRAINT fk_phcp_fk_phcpr_type FOREIGN KEY (fk_phcp_type) REFERENCES llx_phcp_type (rowid);
22
+ALTER TABLE llx_phcp ADD CONSTRAINT fk_phcp_fk_phcp_type FOREIGN KEY (fk_phcp_type) REFERENCES llx_phcp_type (rowid);
23
+ALTER TABLE llx_phcp ADD CONSTRAINT fk_phcp_fk_societe FOREIGN KEY (fk_societe) REFERENCES llx_societe (rowid);

+ 2
- 4
sql/llx_phcp.sql View File

@@ -18,14 +18,12 @@ create table llx_phcp
18 18
 (
19 19
   rowid					            integer AUTO_INCREMENT PRIMARY KEY,
20 20
 
21
-  phcp_number				varchar(30)        NOT NULL,			-- photocopieur reference number
22
-  entity			            	integer  DEFAULT 1 NOT NULL,			-- multi company id
23
-
24 21
   nom                       varchar(255),                     -- nom à donner à la ressource
25 22
 
26 23
   ref_ext				            varchar(255),							        -- reference into an external system (not used by dolibarr)
27 24
   ref_int				            varchar(255),							        -- reference into an internal system (used by dolibarr)
28 25
 
29
-  fk_phcp_type      integer     						          -- type de photocopieur
26
+  fk_phcp_type              integer,     						          -- type de photocopieur
27
+  fk_societe                integer                           -- societe louant le photocopieur
30 28
 
31 29
 )ENGINE=innodb;

sql/llx_societe_phcp.key.sql → sql/llx_phcp_product.key.sql View File

@@ -14,10 +14,10 @@
14 14
 -- You should have received a copy of the GNU General Public License
15 15
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16
 
17
-ALTER TABLE llx_societe_phcp ADD UNIQUE INDEX idx_societe_phcp_uk_societe_phcp_number (societe_phcp_number, entity);
17
+--ALTER TABLE llx_phcp_product ADD UNIQUE INDEX idx_phcp_product_uk_phcp_product_number (phcp_product_number, entity);
18 18
 
19
-ALTER TABLE llx_societe_phcp ADD INDEX idx_societe_phcp_fk_societe (fk_societe);
20
-ALTER TABLE llx_societe_phcp ADD INDEX idx_societe_phcp_fk_phcp (fk_phcp);
19
+ALTER TABLE llx_phcp_product ADD INDEX idx_phcp_product_fk_phcp (fk_phcp);
20
+ALTER TABLE llx_phcp_product ADD INDEX idx_phcp_product_fk_product (fk_product);
21 21
 
22
-ALTER TABLE llx_societe_phcp ADD CONSTRAINT fk_societe_phcp_fk_societe            FOREIGN KEY (fk_societe) REFERENCES llx_societe (rowid);
23
-ALTER TABLE llx_societe_phcp ADD CONSTRAINT fk_societe_phcp_fk_phcp       FOREIGN KEY (fk_phcp) REFERENCES llx_phcp (rowid);
22
+ALTER TABLE llx_phcp_product ADD CONSTRAINT fk_phcp_product_fk_phcp       FOREIGN KEY (fk_phcp) REFERENCES llx_phcp (rowid);
23
+ALTER TABLE llx_phcp_product ADD CONSTRAINT fk_phcp_product_fk_product       FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);

sql/llx_societe_phcp_product.sql → sql/llx_phcp_product.sql View File

@@ -14,18 +14,18 @@
14 14
 -- You should have received a copy of the GNU General Public License
15 15
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16
 
17
-create table llx_societe_phcp_product
17
+create table llx_phcp_product
18 18
 (
19 19
   rowid					                            integer AUTO_INCREMENT PRIMARY KEY,
20 20
 
21
-  societe_phcp_product_number				varchar(30)        NOT NULL,			-- unique id reference number
22
-  entity				                            integer  DEFAULT 1 NOT NULL,			-- multi company id
23
-
24 21
   ref_ext				                            varchar(255),							-- reference into an external system (not used by dolibarr)
25 22
   ref_int				                            varchar(255),							-- reference into an internal system (used by dolibarr)
26 23
 
24
+  last_modification                         date,
25
+  compteur                                  integer,
26
+  last_compteur                             integer,
27
+
27 28
   fk_phcp                           integer,								-- reference phcp
28
-  fk_societe                                integer,                -- reference societe
29 29
   fk_product                                integer                 -- reference produuit
30 30
 
31 31
 )ENGINE=innodb;

+ 1
- 1
sql/llx_phcp_type.key.sql View File

@@ -14,4 +14,4 @@
14 14
 -- You should have received a copy of the GNU General Public License
15 15
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16
 
17
-ALTER TABLE llx_phcp_type ADD UNIQUE INDEX idx_phcp_type_uk_phcp_type_number (phcp_type_number, entity);
17
+--ALTER TABLE llx_phcp_type ADD UNIQUE INDEX idx_phcp_type_uk_phcp_type_number (phcp_type_number, entity);

+ 0
- 3
sql/llx_phcp_type.sql View File

@@ -18,9 +18,6 @@ create table llx_phcp_type
18 18
 (
19 19
   rowid					                  integer AUTO_INCREMENT PRIMARY KEY,
20 20
 
21
-  phcp_type_number				varchar(30)        NOT NULL,			-- phcp type reference number
22
-  entity			                  	integer  DEFAULT 1 NOT NULL,			-- multi company id
23
-
24 21
   nom                             varchar(255),             -- nom du type de phocotocopieur
25 22
 
26 23
   ref_ext			                   	varchar(255),							-- reference into an external system (not used by dolibarr)

+ 1
- 1
sql/llx_phcp_type_product.key.sql View File

@@ -15,7 +15,7 @@
15 15
 -- You should have received a copy of the GNU General Public License
16 16
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
 
18
-ALTER TABLE llx_phcp_type_product ADD UNIQUE INDEX idx_phcp_type_product_uk_phcp_type_product_number (phcp_type_product_number, entity);
18
+--ALTER TABLE llx_phcp_type_product ADD UNIQUE INDEX idx_phcp_type_product_uk_phcp_type_product_number (phcp_type_product_number, entity);
19 19
 
20 20
 ALTER TABLE llx_phcp_type_product ADD INDEX idx_phcp_type_product_fk_phcp_type (fk_phcp_type);
21 21
 ALTER TABLE llx_phcp_type_product ADD INDEX idx_phcp_type_product_fk_product (fk_product);

+ 0
- 3
sql/llx_phcp_type_product.sql View File

@@ -18,9 +18,6 @@ create table llx_phcp_type_product
18 18
 (
19 19
   rowid					                          integer AUTO_INCREMENT PRIMARY KEY,
20 20
 
21
-  phcp_type_product_number				varchar(30)        NOT NULL,			-- unique id reference number
22
-  entity				                          integer  DEFAULT 1 NOT NULL,			-- multi company id
23
-
24 21
   ref_ext		          	                	varchar(255),							-- reference into an external system (not used by dolibarr)
25 22
   ref_int		          	                	varchar(255),							-- reference into an internal system (used by dolibarr)
26 23
 

+ 0
- 18
sql/llx_societe_phcp.sql View File

@@ -1,30 +0,0 @@
1
---
2
---
3
---
4
-
5
-create table llx_societe_phcp
6
-(
7
-  rowid					                    integer AUTO_INCREMENT PRIMARY KEY,
8
-
9
-  societe_phcp_number				varchar(30)        NOT NULL,			-- unique id reference number
10
-  entity				                    integer  DEFAULT 1 NOT NULL,			-- multi company id
11
-
12
-  ref_ext				                    varchar(255),							-- reference into an external system (not used by dolibarr)
13
-  ref_int				                    varchar(255),							-- reference into an internal system (used by dolibarr)
14
-
15
-  fk_phcp                   integer,								-- reference phcp
16
-  fk_societe                        integer                 -- reference societe
17
-
18
-)ENGINE=innodb;

+ 0
- 13
sql/llx_societe_phcp_product.key.sql View File

@@ -1,25 +0,0 @@
1
---
2
---
3
---
4
-
5
-ALTER TABLE llx_societe_phcp_product ADD UNIQUE INDEX idx_societe_phcp_product_uk_societe_phcp_product_number (societe_phcp_product_number, entity);
6
-
7
-ALTER TABLE llx_societe_phcp_product ADD INDEX idx_societe_phcp_product_fk_societe (fk_societe);
8
-ALTER TABLE llx_societe_phcp_product ADD INDEX idx_societe_phcp_product_fk_phcp (fk_phcp);
9
-ALTER TABLE llx_societe_phcp_product ADD INDEX idx_societe_phcp_product_fk_product (fk_product);
10
-
11
-ALTER TABLE llx_societe_phcp_product ADD CONSTRAINT fk_societe_phcp_product_fk_societe            FOREIGN KEY (fk_societe) REFERENCES llx_societe (rowid);
12
-ALTER TABLE llx_societe_phcp_product ADD CONSTRAINT fk_societe_phcp_product_fk_phcp       FOREIGN KEY (fk_phcp) REFERENCES llx_phcp (rowid);
13
-ALTER TABLE llx_societe_phcp_product ADD CONSTRAINT fk_societe_phcp_product_fk_product       FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);

Loading…
Cancel
Save