Browse Source

Design Review

master
Ghislain Loaec 6 years ago
parent
commit
2191ac8904

+ 66
- 25
class/phcp.class.php View File

@@ -43,11 +43,11 @@ class Phcp extends CommonObject
43 43
     var $id;
44 44
     
45 45
 	var $nom;
46
-	var $ref_ext;
47
-	var $ref_int;
46
+	var $ref;
48 47
 	var $fk_phcp_type;
48
+	var $fk_societe;
49 49
   var $phcp_type;
50
-    
50
+  var $societe;
51 51
 
52 52
 
53 53
     /**
@@ -62,6 +62,33 @@ class Phcp extends CommonObject
62 62
     }
63 63
 
64 64
 
65
+    function all(){
66
+      global $conf, $langs;
67
+      $sql = "SELECT";
68
+		  $sql.= " t.rowid";
69
+      $sql.= " FROM ".MAIN_DB_PREFIX."phcp as t";
70
+
71
+      $list = array();
72
+
73
+    	dol_syslog(get_class($this)."::all sql=".$sql, LOG_DEBUG);
74
+      $resql=$this->db->query($sql);
75
+      if ($resql){
76
+        if ($num = $this->db->num_rows($resql)){
77
+          $i = 0;
78
+          while ($i < $num){
79
+            $obj = $this->db->fetch_object($resql);
80
+            if ($obj){
81
+              $phcp = new Phcp($this->db);
82
+              $phcp->fetch($obj->rowid);
83
+              $list[]= $phcp;
84
+            }
85
+            $i++;
86
+          }
87
+        }
88
+      }
89
+      return $list;
90
+    }
91
+
65 92
     /**
66 93
      *  Create object into database
67 94
      *
@@ -77,13 +104,17 @@ class Phcp extends CommonObject
77 104
 		// Clean parameters
78 105
         
79 106
 		if (isset($this->nom)) $this->nom=trim($this->nom);
80
-		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
81
-		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
107
+		if (isset($this->ref)) $this->ref=trim($this->ref);
82 108
     if (isset($this->fk_phcp_type)){
83 109
       $this->fk_phcp_type=trim($this->fk_phcp_type);
84 110
       $this->phcp_type=new PhcpType($this->db);
85 111
       $this->phcp_type->fetch($this->fk_phcp_type);
86 112
     }
113
+    if (isset($this->fk_societe)){
114
+      $this->fk_societe=trim($this->fk_societe);
115
+      $this->societe=new Societe($this->db);
116
+      $this->societe->fetch($this->fk_societe);
117
+    }
87 118
         
88 119
 
89 120
 		// Check parameters
@@ -93,21 +124,21 @@ class Phcp extends CommonObject
93 124
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."phcp(";
94 125
 		
95 126
 		$sql.= "nom,";
96
-		$sql.= "ref_ext,";
97
-		$sql.= "ref_int,";
98
-		$sql.= "fk_phcp_type";
127
+		$sql.= "ref,";
128
+		$sql.= "fk_phcp_type,";
129
+		$sql.= "fk_societe";
99 130
 
100 131
 		
101 132
         $sql.= ") VALUES (";
102 133
         
103 134
 		$sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").",";
104
-		$sql.= " ".(! isset($this->ref_ext)?'NULL':"'".$this->db->escape($this->ref_ext)."'").",";
105
-		$sql.= " ".(! isset($this->ref_int)?'NULL':"'".$this->db->escape($this->ref_int)."'").",";
106
-		$sql.= " ".(! isset($this->fk_phcp_type)?'NULL':"'".$this->fk_phcp_type."'")."";
135
+		$sql.= " ".(! isset($this->ref)?'NULL':"'".$this->db->escape($this->ref)."'").",";
136
+		$sql.= " ".(! isset($this->fk_phcp_type)?'NULL':"'".$this->fk_phcp_type."'").",";
137
+		$sql.= " ".(! isset($this->fk_societe)?'NULL':"'".$this->fk_societe."'")."";
107 138
 
108 139
         
109 140
 		$sql.= ")";
110
-
141
+ echo $sql;
111 142
 		$this->db->begin();
112 143
 
113 144
 	   	dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
@@ -164,9 +195,9 @@ class Phcp extends CommonObject
164 195
 		$sql.= " t.rowid,";
165 196
 		
166 197
 		$sql.= " t.nom,";
167
-		$sql.= " t.ref_ext,";
168
-		$sql.= " t.ref_int,";
169
-		$sql.= " t.fk_phcp_type";
198
+		$sql.= " t.ref,";
199
+		$sql.= " t.fk_phcp_type,";
200
+		$sql.= " t.fk_societe";
170 201
 
171 202
 		
172 203
         $sql.= " FROM ".MAIN_DB_PREFIX."phcp as t";
@@ -183,13 +214,18 @@ class Phcp extends CommonObject
183 214
                 $this->id    = $obj->rowid;
184 215
                 
185 216
 				$this->nom = $obj->nom;
186
-				$this->ref_ext = $obj->ref_ext;
187
-				$this->ref_int = $obj->ref_int;
217
+				$this->ref = $obj->ref;
188 218
 				$this->fk_phcp_type = $obj->fk_phcp_type;
219
+				$this->fk_societe = $obj->fk_societe;
189 220
         if (isset($this->fk_phcp_type)){
190 221
           $this->phcp_type=new PhcpType($this->db);
191 222
           $this->phcp_type->fetch($this->fk_phcp_type);
192 223
         }
224
+				$this->fk_societe = $obj->fk_societe;
225
+        if (isset($this->fk_societe)){
226
+          $this->societe=new Societe($this->db);
227
+          $this->societe->fetch($this->fk_societe);
228
+        }
193 229
 
194 230
                 
195 231
             }
@@ -221,13 +257,17 @@ class Phcp extends CommonObject
221 257
 		// Clean parameters
222 258
         
223 259
 		if (isset($this->nom)) $this->nom=trim($this->nom);
224
-		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
225
-		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
260
+		if (isset($this->ref)) $this->ref=trim($this->ref);
226 261
     if (isset($this->fk_phcp_type)){
227 262
       $this->fk_phcp_type=trim($this->fk_phcp_type);
228 263
       $this->phcp_type=new PhcpType($this->db);
229 264
       $this->phcp_type->fetch($this->fk_phcp_type);
230
-    }
265
+    } else $this->phcp_type = null;
266
+    if (isset($this->fk_societe)){
267
+      $this->fk_societe=trim($this->fk_societe);
268
+      $this->societe=new Societe($this->db);
269
+      $this->societe->fetch($this->fk_societe);
270
+    } else $this->societe = null;
231 271
         
232 272
 
233 273
 		// Check parameters
@@ -237,9 +277,9 @@ class Phcp extends CommonObject
237 277
         $sql = "UPDATE ".MAIN_DB_PREFIX."phcp SET";
238 278
         
239 279
 		$sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").",";
240
-		$sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").",";
241
-		$sql.= " ref_int=".(isset($this->ref_int)?"'".$this->db->escape($this->ref_int)."'":"null").",";
242
-		$sql.= " fk_phcp_type=".(isset($this->fk_phcp_type)?$this->fk_phcp_type:"null")."";
280
+		$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
281
+		$sql.= " fk_phcp_type=".(isset($this->fk_phcp_type)?$this->fk_phcp_type:"null").",";
282
+		$sql.= " fk_societe=".(isset($this->fk_societe)?$this->fk_societe:"null")."";
243 283
 
244 284
         
245 285
         $sql.= " WHERE rowid=".$this->id;
@@ -409,10 +449,11 @@ class Phcp extends CommonObject
409 449
 	{
410 450
 		$this->id=0;
411 451
 		$this->nom='';
412
-		$this->ref_ext='';
413
-		$this->ref_int='';
452
+		$this->ref='';
414 453
 		$this->fk_phcp_type='';
415 454
     $this->phcp_type=null;
455
+		$this->fk_societe='';
456
+    $this->societe=null;
416 457
 		
417 458
 	}
418 459
 

+ 65
- 25
class/phcptype.class.php View File

@@ -43,8 +43,7 @@ class PhcpType extends CommonObject
43 43
     var $id;
44 44
     
45 45
 	var $nom;
46
-	var $ref_ext;
47
-	var $ref_int;
46
+	var $ref;
48 47
   var $products;
49 48
     
50 49
 
@@ -61,6 +60,33 @@ class PhcpType extends CommonObject
61 60
     }
62 61
 
63 62
 
63
+    function all(){
64
+      global $conf, $langs;
65
+      $sql = "SELECT";
66
+		  $sql.= " t.rowid";
67
+      $sql.= " FROM ".MAIN_DB_PREFIX."phcp_type as t";
68
+
69
+      $list = array();
70
+
71
+    	dol_syslog(get_class($this)."::all sql=".$sql, LOG_DEBUG);
72
+      $resql=$this->db->query($sql);
73
+      if ($resql){
74
+        if ($num = $this->db->num_rows($resql)){
75
+          $i = 0;
76
+          while ($i < $num){
77
+            $obj = $this->db->fetch_object($resql);
78
+            if ($obj){
79
+              $phcptype = new PhcpType($this->db);
80
+              $phcptype->fetch($obj->rowid);
81
+              $list[]= $phcptype;
82
+            }
83
+            $i++;
84
+          }
85
+        }
86
+      }
87
+      return $list;
88
+    }
89
+
64 90
 
65 91
   function add_product($fk_product){
66 92
           global $conf, $langs;
@@ -112,8 +138,8 @@ class PhcpType extends CommonObject
112 138
     	global $conf, $langs;
113 139
       $error=0;
114 140
 
115
-          foreach($this->products as $key => $product){
116
-                  if($product->id == $fk_product)
141
+      foreach($this->products as $key => $product){
142
+                  if(intval($product->id) == intval($fk_product))
117 143
                     unset($this->products[$key]);
118 144
           }
119 145
       $sql = "DELETE FROM ".MAIN_DB_PREFIX."phcp_type_product ";
@@ -141,7 +167,6 @@ class PhcpType extends CommonObject
141 167
 		      else
142 168
 		      {
143 169
             $this->db->commit();
144
-            $this->products[] = $product;
145 170
             return 1;
146 171
 		      }
147 172
 
@@ -162,27 +187,27 @@ class PhcpType extends CommonObject
162 187
 		// Clean parameters
163 188
         
164 189
 		if (isset($this->nom)) $this->nom=trim($this->nom);
165
-		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
166
-		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
190
+		if (isset($this->ref)) $this->ref=trim($this->ref);
167 191
 
168 192
         
169
-
193
+    
170 194
 		// Check parameters
171 195
 		// Put here code to add control on parameters values
172
-
196
+    if ($this->nom == ''){
197
+      $error++; $this->errors[]="Vous devez spécifier un label pour le type de photocopieur";
198
+    }
199
+    if(!$error){
173 200
         // Insert request
174 201
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."phcp_type(";
175 202
 		
176 203
 		$sql.= "nom,";
177
-		$sql.= "ref_ext,";
178
-		$sql.= "ref_int";
204
+		$sql.= "ref";
179 205
 
180 206
 		
181 207
         $sql.= ") VALUES (";
182 208
         
183 209
 		$sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").",";
184
-		$sql.= " ".(! isset($this->ref_ext)?'NULL':"'".$this->db->escape($this->ref_ext)."'").",";
185
-		$sql.= " ".(! isset($this->ref_int)?'NULL':"'".$this->db->escape($this->ref_int)."'")."";
210
+		$sql.= " ".(! isset($this->ref)?'NULL':"'".$this->db->escape($this->ref)."'")."";
186 211
 
187 212
         
188 213
 		$sql.= ")";
@@ -192,7 +217,7 @@ class PhcpType extends CommonObject
192 217
 	   	dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
193 218
         $resql=$this->db->query($sql);
194 219
     	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
195
-
220
+    }
196 221
 		if (! $error)
197 222
         {
198 223
             $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."phcp_type");
@@ -243,8 +268,7 @@ class PhcpType extends CommonObject
243 268
 		$sql.= " t.rowid,";
244 269
 		
245 270
 		$sql.= " t.nom,";
246
-		$sql.= " t.ref_ext,";
247
-		$sql.= " t.ref_int";
271
+		$sql.= " t.ref";
248 272
 
249 273
 		
250 274
         $sql.= " FROM ".MAIN_DB_PREFIX."phcp_type as t";
@@ -261,8 +285,7 @@ class PhcpType extends CommonObject
261 285
                 $this->id    = $obj->rowid;
262 286
                 
263 287
 				$this->nom = $obj->nom;
264
-				$this->ref_ext = $obj->ref_ext;
265
-        $this->ref_int = $obj->ref_int;
288
+        $this->ref = $obj->ref;
266 289
         $this->products = array();
267 290
 
268 291
         $sql2 = "SELECT";
@@ -315,8 +338,7 @@ class PhcpType extends CommonObject
315 338
 		// Clean parameters
316 339
         
317 340
 		if (isset($this->nom)) $this->nom=trim($this->nom);
318
-		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
319
-		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
341
+		if (isset($this->ref)) $this->ref=trim($this->ref);
320 342
 
321 343
         
322 344
 
@@ -327,8 +349,7 @@ class PhcpType extends CommonObject
327 349
         $sql = "UPDATE ".MAIN_DB_PREFIX."phcp_type SET";
328 350
         
329 351
 		$sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").",";
330
-		$sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").",";
331
-		$sql.= " ref_int=".(isset($this->ref_int)?"'".$this->db->escape($this->ref_int)."'":"null")."";
352
+		$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null")."";
332 353
 
333 354
         
334 355
         $sql.= " WHERE rowid=".$this->id;
@@ -406,6 +427,25 @@ class PhcpType extends CommonObject
406 427
 
407 428
 		if (! $error)
408 429
 		{
430
+    		$sql = "UPDATE ".MAIN_DB_PREFIX."phcp";
431
+        $sql.= " SET fk_phcp_type=NULL";
432
+        $sql.= " WHERE fk_phcp_type=".$this->id;
433
+
434
+    		dol_syslog(get_class($this)."::delete sql=".$sql);
435
+    		$resql = $this->db->query($sql);
436
+        	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
437
+		}
438
+		if (! $error)
439
+		{
440
+    		$sql = "DELETE FROM ".MAIN_DB_PREFIX."phcp_type_product";
441
+    		$sql.= " WHERE fk_phcp_type=".$this->id;
442
+
443
+    		dol_syslog(get_class($this)."::delete sql=".$sql);
444
+    		$resql = $this->db->query($sql);
445
+        	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
446
+		}
447
+		if (! $error)
448
+		{
409 449
     		$sql = "DELETE FROM ".MAIN_DB_PREFIX."phcp_type";
410 450
     		$sql.= " WHERE rowid=".$this->id;
411 451
 
@@ -413,7 +453,6 @@ class PhcpType extends CommonObject
413 453
     		$resql = $this->db->query($sql);
414 454
         	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
415 455
 		}
416
-
417 456
         // Commit or rollback
418 457
 		if ($error)
419 458
 		{
@@ -499,8 +538,9 @@ class PhcpType extends CommonObject
499 538
 		$this->id=0;
500 539
 		
501 540
 		$this->nom='';
502
-		$this->ref_ext='';
503
-		$this->ref_int='';
541
+    $this->ref='';
542
+
543
+    $this->products=array();
504 544
 
505 545
 		
506 546
 	}

+ 35
- 0
class/societe.class.php View File

@@ -0,0 +1,35 @@
1
+<?php
2
+require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
3
+
4
+class CSociete extends Societe {
5
+
6
+    function all(){
7
+      global $conf, $langs;
8
+      $sql = "SELECT";
9
+		  $sql.= " t.rowid";
10
+      $sql.= " FROM ".MAIN_DB_PREFIX."societe as t";
11
+
12
+      $list = array();
13
+
14
+    	dol_syslog(get_class($this)."::all sql=".$sql, LOG_DEBUG);
15
+      $resql=$this->db->query($sql);
16
+      if ($resql){
17
+        if ($num = $this->db->num_rows($resql)){
18
+          $i = 0;
19
+          while ($i < $num){
20
+            $obj = $this->db->fetch_object($resql);
21
+            if ($obj){
22
+              $societe = new Societe($this->db);
23
+              $societe->fetch($obj->rowid);
24
+              $list[]= $societe;
25
+            }
26
+            $i++;
27
+          }
28
+        }
29
+      }
30
+      return $list;
31
+    }
32
+
33
+}
34
+
35
+?>

+ 136
- 107
phcp.php View File

@@ -9,6 +9,7 @@ if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@
9 9
 if (! $res) die("Include of main fails");
10 10
 // Change this following line to use the correct relative path from htdocs
11 11
 dol_include_once('/photocopies/class/phcp.class.php');
12
+dol_include_once('/photocopies/class/societe.class.php');
12 13
 
13 14
 // Load traductions files requiredby by page
14 15
 $langs->load("companies");
@@ -30,11 +31,14 @@ $title    = null;
30 31
 
31 32
 $phcp = new Phcp($db);
32 33
 if($id) $phcp->fetch($id);
34
+else $phcp->initAsSpecimen();
33 35
 
34 36
 //------------------------------------------------------------------------------
35 37
 if ($action == 'create') {
38
+	$phcp->ref=$_POST["ref"];
36 39
 	$phcp->nom=$_POST["nom"];
37
-	$phcp->fk_phcp_type=$_POST["fk_phcp_type"];
40
+	$phcp->fk_phcp_type= $_POST["fk_phcp_type"] ?: null;
41
+	$phcp->fk_societe= $_POST["fk_societe"] ?: null;
38 42
 	if ($phcp->create($user) >= 0)
39 43
     $action = 'show';
40 44
   else
@@ -42,35 +46,21 @@ if ($action == 'create') {
42 46
 }
43 47
 //------------------------------------------------------------------------------
44 48
 elseif ($action == 'update'){
49
+	$phcp->ref=$_POST["ref"];
45 50
 	$phcp->nom=$_POST["nom"];
46
-	$phcp->fk_phcp_type=$_POST["fk_phcp_type"];
51
+	$phcp->fk_phcp_type=$_POST["fk_phcp_type"] ?: null;
52
+	$phcp->fk_societe= $_POST["fk_societe"] ?: null;
47 53
 	if ($phcp->update($user) >= 0)
48 54
     $action = 'show';
49 55
   else 
50 56
     $action = 'edit';
51 57
 }
52
-
53
-$phcp_types = "";
54
-
55
-if($action == 'new' || $action == 'edit'){
56
-  $sql = "SELECT pt.rowid, pt.nom ";
57
-  $sql.= "FROM ".MAIN_DB_PREFIX."phcp_type as pt";
58
-  $resql=$db->query($sql);
59
-  if($resql){
60
-    $num = $db->num_rows($resql);
61
-    $i = 0;
62
-    if ($num){
63
-      while ($i < $num){
64
-        $obj = $db->fetch_object($resql);
65
-        if ($obj){
66
-          $extra = "";
67
-          if($phcp && $phcp->fk_phcp_type == $obj->rowid){ $extra = 'selected="selected"'; }
68
-          $phcp_types.= '<option value="'.$obj->rowid.'" '.$extra.'>'.$obj->nom.'</option>'."\n";
69
-        }
70
-        $i++;
71
-      }
72
-    }
73
-  }
58
+//------------------------------------------------------------------------------
59
+elseif ($action == 'delete'){
60
+	if ($phcp->delete($user) >= 0)
61
+    $action = 'list';
62
+  else 
63
+    $action = 'list';
74 64
 }
75 65
 
76 66
 switch($action){
@@ -109,48 +99,95 @@ if($phcp && $phcp->error){
109 99
 
110 100
 <?php
111 101
 //------------------------------------------------------------------------------
112
-if ($action == 'new') {       
113
-?>
114
-  <form action="<?= $url."?action=create" ?>" method="POST">
115
-    <label for="phcp_nom">Nom du photocopieur</label>
116
-    <input name="nom" id="phcp_nom" type="text" placeholder="Nom du photocopieur" /><br />
117
-    <label for="phcp_type">Type de photocopieur</label>
118
-    <select name="fk_phcp_type" id="phcp_type" placeholder="Type de photocopieur">
119
-      <?= $phcp_types ?>
120
-    </select><br />
121
-    <div class="tabsAction">
122
-      <div class="inline-block divButAction">
123
-        <input type="submit" class="butAction" value="Créer" />
124
-      </div>
125
-    </div>
126
-  </form>
127
-<?php
128
-}        
129
-//------------------------------------------------------------------------------
130
-elseif ($action == 'edit') {
102
+if (($action == 'new') || ($action == 'edit')){
131 103
 ?>
132
-  <form action="<?= $url."?action=update" ?>" method="POST">
133
-    <input type="hidden" name="id" value="<?= $id ?>" />
134
-    <label for="phcp_nom">Nom du photocopieur</label>
135
-    <input name="nom" id="phcp_nom" type="text" placeholder="Nom du photocopieur" value="<?= $phcp->nom ?>" /><br />
136
-    <label for="phcp_type">Type de photocopieur</label>
137
-    <select name="fk_phcp_type" id="phcp_type" placeholder="Type de photocopieur">
138
-      <?= $phcp_types ?>
139
-    </select><br />
104
+  <form action="<?= $url."?action=".($action=='new'?'create':'update') ?>" method="POST">
105
+    <?php if($id){ ?><input type="hidden" name="id" value="<?= $id ?>" /><?php } ?>
106
+    <table width="100%" class="border">
107
+      <tbody>
108
+        <tr>
109
+          <td class="fieldrequired" width="20%"><label for="phcp_ref">Ref.</label></td>
110
+          <td><input type="text" id="phcp_ref" name="ref" value="<?= $phcp->ref ?>" placeholder="Reference" /></td>
111
+        </tr>
112
+        <tr>
113
+          <td class="fieldrequired"><label for="phcp_nom">Label du photocopieur</label></td>
114
+          <td><input name="nom" id="phcp_nom" type="text" placeholder="Label du photocopieur" value="<?= $phcp->nom ?>" /></td>
115
+        </tr>
116
+        <tr>
117
+          <td class=""><label for="phcp_type">Type de Photocopieur</label></td>
118
+          <td>
119
+            <select name="fk_phcp_type" id="phcp_type" placeholder="Type de photocopieur">
120
+              <option value="">AUCUN</option>
121
+              <?php
122
+                $phcptype = new PhcpType($db); 
123
+                foreach($phcptype->all() as $pt){
124
+              ?>
125
+                <option value="<?= $pt->id ?>" <?= intval($pt->id) == intval($phcp->fk_phcp_type) ? 'selected="selected"':'' ?>><?= $pt->nom ?></option>
126
+              <?php } ?>
127
+            </select>
128
+          </td>
129
+        </tr>
130
+        <tr>
131
+          <td class=""><label for="societe">Chez Client</label></td>
132
+          <td>
133
+            <select name="fk_societe" id="societe" placeholder="Chez Client">
134
+              <option value="">NON</option>
135
+              <?php 
136
+                $societe = new CSociete($db); 
137
+                foreach($societe->all() as $s){
138
+              ?>
139
+                <option value="<?= $s->id ?>" <?= intval($s->id) == intval($phcp->fk_societe) ? 'selected="selected"':'' ?>><?= $s->nom ?></option>
140
+              <?php } ?>
141
+            </select>
142
+          </td>
143
+        </tr>
144
+      </tbody>
145
+    </table>
140 146
     <div class="tabsAction">
141 147
       <div class="inline-block divButAction">
142
-        <input type="submit" class="butAction" value="Modifier" />
148
+        <input type="submit" class="butAction" value="<?= $action=='new'?'Créer':'Modifier' ?>" />
143 149
       </div>
144 150
     </div>
145 151
   </form>
146 152
 <?php
147
-        
148 153
 } 
149 154
 //------------------------------------------------------------------------------
150 155
 elseif ($action == 'show') { 
151 156
 ?>
152
-  <strong>Nom : </strong><?= $phcp->nom ?><br />
153
-  <strong>Phococopieur Type : </strong><?= $phcp->phcp_type->nom ?><br />
157
+  <div class="tabBar">
158
+    <table width="100%" class="border">
159
+      <tbody>
160
+        <tr>
161
+          <td width="15%">Ref.</td>
162
+          <td colspan="2"><?= $phcp->ref ?></td>
163
+        </tr>
164
+        <tr>
165
+          <td>Label</td>
166
+          <td colspan="2"><?= $phcp->nom ?></td>
167
+        </tr>
168
+        <tr>
169
+          <td>Photocopieur Type</td>
170
+          <td colspan="2">
171
+            <?php if($phcp->phcp_type) { ?>
172
+              <a href="<?= DOL_URL_ROOT.'/photocopies/phcptype.php?action=show&id='.$phcp->phcp_type->id ?>">
173
+                <?= $phcp->phcp_type->ref ?> - <?= $phcp->phcp_type->nom ?>
174
+              </a>
175
+            <?php } else echo 'AUCUN' ?>
176
+          </td>
177
+        </tr>
178
+        <tr>
179
+          <td>Chez Client</td>
180
+          <td colspan="2">
181
+            <?php if($phcp->societe) { ?>
182
+              <a href="<?= DOL_URL_ROOT.'/societe/soc.php?socid='.$phcp->societe->id ?>">
183
+                <?= $phcp->societe->nom ?>
184
+              </a>
185
+            <?php } else echo 'NON' ?>
186
+          </td>
187
+        </tr>
188
+      </tbody>
189
+    </table>
190
+  </div>
154 191
   <div class="tabsAction">
155 192
     <div class="inline-block divButAction">
156 193
       <a href="<?= $url."?id=".$phcp->id."&action=edit" ?>" class="butAction">
@@ -164,58 +201,50 @@ elseif ($action == 'show') {
164 201
 <?php 
165 202
 }
166 203
 //------------------------------------------------------------------------------
167
-else {
168
-
169
-  $form= new Form($db);
170
-  $sql = "SELECT";
171
-  $sql.= " p.rowid,";
172
-	$sql.= " p.nom,";
173
-	$sql.= " pt.nom as phcp_type";
174
-  $sql.= " FROM ".MAIN_DB_PREFIX."phcp as p, ";
175
-  $sql.= MAIN_DB_PREFIX."phcp_type as pt";
176
-  $sql.= " WHERE pt.rowid = p.fk_phcp_type";
177
-
178
-  print '<table class="noborder" width="100%">'."\n";
179
-  print '<tr class="liste_titre">';
180
-  print_liste_field_titre($langs->trans('rowid'),$_SERVER['PHP_SELF'],'p.rowid','',$param,'',$sortfield,$sortorder);
181
-  print_liste_field_titre($langs->trans('nom'),$_SERVER['PHP_SELF'],'p.nom','',$param,'',$sortfield,$sortorder);
182
-  print_liste_field_titre($langs->trans('phcp_type'),$_SERVER['PHP_SELF'],'pt.nom','',$param,'',$sortfield,$sortorder);
183
-  print '</tr>';
184
-
185
-  dol_syslog($script_file." sql=".$sql, LOG_DEBUG);
186
-  $resql=$db->query($sql);
187
-  if ($resql)
188
-  {
189
-      $num = $db->num_rows($resql);
190
-      $i = 0;
191
-      if ($num)
192
-      {
193
-          while ($i < $num)
194
-          {
195
-              $obj = $db->fetch_object($resql);
196
-              if ($obj)
197
-              {
198
-                  // You can use here results
199
-                  print '<tr><td>';
200
-                  print $obj->rowid;
201
-                  print '</td><td><a href="'.$url.'?id='.$obj->rowid.'&action=show">';
202
-                  print $obj->nom;
203
-                  print '</a></td><td>';
204
-                  print $obj->phcp_type;
205
-                  print '</td></tr>';
206
-              }
207
-              $i++;
208
-          }
209
-      }
210
-  }
211
-  else
212
-  {
213
-      $error++;
214
-      dol_print_error($db);
215
-  }
216
-  print '</table>'."\n";
217
-}
218
-?>
204
+else { ?>
205
+  <table class="noborder" width="100%">
206
+    <thead>
207
+      <tr class="liste_titre">
208
+        <th>Ref.</th>
209
+        <th>Photocopieur Label</th>
210
+        <th>Photocopieur Type</th>
211
+        <th>Chez Client</th>
212
+        <th>&nbsp;</th>
213
+      </tr>
214
+    </thead>
215
+    <tbody>
216
+      <?php foreach($phcp->all() as $p){ ?>
217
+        <tr>
218
+          <td>
219
+            <a href="<?= $url.'?id='.$p->id.'&action=show' ?>">
220
+              <?= $p->ref ?>
221
+            </a>
222
+          </td>
223
+          <td>
224
+            <a href="<?= $url.'?id='.$p->id.'&action=show' ?>">
225
+              <?= $p->nom ?>
226
+            </a>
227
+          </td>
228
+          <td>
229
+            <?php if($p->fk_phcp_type){ ?>
230
+              <a href="<?= DOL_URL_ROOT.'/photocopies/phcptype.php?id='.$p->fk_phcp_type.'&action=show' ?>">
231
+                <?= $p->phcp_type->nom ?>
232
+              </a>
233
+            <?php } else echo 'AUCUN'; ?>
234
+          </td>
235
+          <td>
236
+            <?php if($p->fk_societe){ ?>
237
+              <a href="<?= DOL_URL_ROOT.'/societe/soc.php?socid='.$p->fk_societe ?>">
238
+                <?= $p->societe->nom ?>
239
+              </a>
240
+            <?php } else echo 'NON'; ?>
241
+          </td>
242
+          <td align="right"><a href="<?= $url.'?id='.$p->id.'&action=delete' ?>">X</a></td>
243
+        </tr>
244
+      <?php } ?>
245
+    </tbody>
246
+  </table>
247
+<?php } ?>
219 248
     <!--/div-->
220 249
   </div>
221 250
 </div> 

+ 106
- 63
phcptype.php View File

@@ -30,18 +30,25 @@ $title    = null;
30 30
 
31 31
 $phcptype = new PhcpType($db);
32 32
 if($id) $phcptype->fetch($id);
33
+else {
34
+  $phcptype->initAsSpecimen();
35
+  $phcptype->nom = GETPOST('phcp_nom', 'alpha') ?: '';
36
+}
33 37
 
34 38
 //------------------------------------------------------------------------------
35 39
 if ($action == 'create') {
40
+	$phcptype->ref=$_POST["ref"];
36 41
 	$phcptype->nom=$_POST["nom"];
37 42
 	$phcptype->fk_phcp_type=$_POST["fk_phcp_type"];
38
-	if ($phcptype->create($user) >= 0)
39
-    $action = 'show';
40
-  else
43
+  if ($phcptype->create($user) >= 0){
44
+    $id = $phcptype->id;
41 45
     $action = 'edit';
46
+  } else
47
+    $action = 'new';
42 48
 }
43 49
 //------------------------------------------------------------------------------
44 50
 elseif ($action == 'update'){
51
+	$phcptype->ref=$_POST["ref"];
45 52
 	$phcptype->nom=$_POST["nom"];
46 53
 	$phcptype->fk_phcp_type=$_POST["fk_phcp_type"];
47 54
 	if ($phcptype->update($user) >= 0)
@@ -50,6 +57,14 @@ elseif ($action == 'update'){
50 57
     $action = 'edit';
51 58
 }
52 59
 //------------------------------------------------------------------------------
60
+elseif ($action == 'delete'){
61
+        if($phcptype->delete($user) >= 0)
62
+                $action = 'list';
63
+        else
64
+                $action = 'list';
65
+  
66
+}
67
+//------------------------------------------------------------------------------
53 68
 elseif ($action == 'add_product'){
54 69
         $fk_product = GETPOST('fk_product','int') ?: null;
55 70
   if($fk_product){
@@ -122,79 +137,103 @@ if($phcptype && $phcptype->error){
122 137
     <!--div class="fichethirdleft"-->
123 138
 <?php
124 139
 //------------------------------------------------------------------------------
125
-if ($action == 'new') {       
126
-?>
127
-  <form action="<?= $url."?action=create" ?>" method="POST">
128
-    <label for="phcp_nom">Nom du photocopieur</label>
129
-    <input name="nom" id="phcp_nom" type="text" placeholder="Nom du photocopieur" /><br />
130
-    <label for="phcp_type">Type de photocopieur</label>
131
-    <select name="fk_phcp_type" id="phcp_type" placeholder="Type de photocopieur">
132
-      <?= $phcptype_types ?>
133
-    </select><br />
134
-    <div class="tabsAction">
135
-      <div class="inline-block divButAction">
136
-        <input type="submit" class="butAction" value="Créer" />
137
-      </div>
138
-    </div>
139
-  </form>
140
-<?php
141
-}        
142
-//------------------------------------------------------------------------------
143
-elseif ($action == 'edit') {
140
+if (($action == 'new') || ($action == 'edit')){
144 141
 ?>
145
-  <form action="<?= $url."?action=update" ?>" method="POST">
146
-    <input type="hidden" name="id" value="<?= $id ?>" />
147
-    <label for="phcp_nom">Label type photocopieur</label>
148
-    <input name="nom" id="phcp_nom" type="text" placeholder="Nom du photocopieur" value="<?= $phcptype->nom ?>" /><br />
149
-    <label for="phcp_type">Tarifs associés</label>
150
-    <table class="noborder" width="100%">
151
-      <thead>
152
-        <tr class="liste_titre">
153
-          <th>Ref</th>
154
-          <th>Label</th>
155
-          <th>Price</th>
156
-          <th>&nbsp;</th>
157
-        </tr>
158
-      </thead>
142
+  <form action="<?= $url."?action=".($action=='new'?'create':'update') ?>" method="POST">
143
+    <?php if($id){ ?><input type="hidden" name="id" value="<?= $id ?>" /><?php } ?>
144
+    <table width="100%" class="border">
159 145
       <tbody>
160
-        <?php foreach($phcptype->products as $product){ ?>
146
+        <tr>
147
+          <td class="fieldrequired" width="20%"><label for="phcp_ref">Ref.</label></td>
148
+          <td><input type="text" id="phcp_ref" name="ref" value="<?= $phcptype->ref ?>" placeholder="Reference" /></td>
149
+        </tr>
150
+        <tr>
151
+          <td class="fieldrequired"><label for="phcp_nom">Label du type de photocopieur</label></td>
152
+          <td><input name="nom" id="phcp_nom" type="text" placeholder="Label du type de photocopieur" value="<?= $phcptype->nom ?>" /></td>
153
+        </tr>
154
+        <?php if($action == 'edit'){ ?>
161 155
           <tr>
162
-            <td><a href="<?= DOL_URL_ROOT ?>/product/fiche.php?id=<?= $product->id ?>"><?= $product->ref ?></a></td>
163
-            <td><?= $product->label ?></td>
164
-            <td><?= money_format("%i €", $product->price) ?></td>
165
-            <td align="right"><a href="<?= $url.'?action=remove_product&id='.$id.'&fk_product='.$product->id ?>">X</a></td>
156
+            <td><label for="phcp_type">Tarifs associés</label></td>
157
+            <td>
158
+              <table class="noborder" width="100%">
159
+                <thead>
160
+                  <tr class="liste_titre">
161
+                    <th>Ref</th>
162
+                    <th>Label</th>
163
+                    <th>Price</th>
164
+                    <th>&nbsp;</th>
165
+                  </tr>
166
+                </thead>
167
+                <tbody>
168
+                  <?php foreach($phcptype->products as $product){ ?>
169
+                    <tr>
170
+                      <td><a href="<?= DOL_URL_ROOT ?>/product/fiche.php?id=<?= $product->id ?>"><?= $product->ref ?></a></td>
171
+                      <td><?= $product->label ?></td>
172
+                      <td><?= money_format("%i €", $product->price) ?></td>
173
+                      <td align="right"><a href="<?= $url.'?action=remove_product&id='.$id.'&fk_product='.$product->id ?>">X</a></td>
174
+                    </tr>
175
+                  <?php } ?>
176
+                </tbody>
177
+              </table>
178
+            </td>
166 179
           </tr>
167 180
         <?php } ?>
168 181
       </tbody>
169 182
     </table>
170 183
     <div class="tabsAction">
171 184
       <div class="inline-block divButAction">
172
-        <input type="submit" class="butAction" value="Modifier" />
185
+        <input type="submit" class="butAction" value="<?= $action=='new'?'Créer':'Modifier' ?>" />
173 186
       </div>
174 187
     </div>
175 188
   </form>
176
-
177
-  <form action="<?= $url."?action=add_product&id=".$id ?>" method="POST">
178
-    <label for="fk_product">Tarif à associer</label>
179
-    <select name="fk_product" id="fk_product">
180
-      <option>Selectionnez un tarif à associer</option>
181
-      <?= $products ?>
182
-    </select>
183
-    <input type="submit" value="+ Associer le tarif" />
184
-  </form>
189
+  <?php if($action == 'edit'){ ?>
190
+    <form action="<?= $url."?action=add_product&id=".$id ?>" method="POST">
191
+      <label for="fk_product">Tarif à associer</label>
192
+      <select name="fk_product" id="fk_product">
193
+        <option>Selectionnez un tarif à associer</option>
194
+        <?= $products ?>
195
+      </select>
196
+      <input type="submit" value="+ Associer le tarif" />
197
+    </form>
198
+  <?php } ?>
185 199
 <?php
186 200
         
187 201
 } 
188 202
 //------------------------------------------------------------------------------
189 203
 elseif ($action == 'show') { 
190 204
 ?>
191
-  <strong>Nom : </strong><?= $phcptype->nom ?><br />
192
-  <strong>Tarifs Associés : </strong><br />
193
-  <ul>
194
-  <?php foreach($phcptype->products as $product){ ?>
195
-    <li><a href="<?= DOL_URL_ROOT ?>/product/fiche.php?id=<?= $product->id ?>"><?= $product->ref ?></a> - <?= $product->label ?> - <?= money_format("%i €", $product->price) ?></li>
196
-  <?php } ?>
197
-  </ul> 
205
+  <div class="tabBar">
206
+    <table width="100%" class="border">
207
+      <tbody>
208
+        <tr>
209
+          <td width="15%">Ref.</td>
210
+          <td colspan="2"><?= $phcptype->ref ?></td>
211
+        </tr>
212
+        <tr>
213
+          <td>Label</td>
214
+          <td colspan="2"><?= $phcptype->nom ?></td>
215
+        </tr>
216
+        <tr>
217
+          <td>Tarifs Associés</td>
218
+          <td colspan="2">
219
+            <table width="100%" class="border">
220
+              <tbody>
221
+                <?php foreach($phcptype->products as $product){ ?>
222
+                  <tr>
223
+                    <td>
224
+                      <a href="<?= DOL_URL_ROOT ?>/product/fiche.php?id=<?= $product->id ?>">
225
+                        <?= $product->ref ?>
226
+                      </a> - <?= $product->label ?> - <?= money_format("%i €", $product->price) ?>
227
+                    </td>
228
+                  </tr>
229
+                <?php } ?>
230
+              </tbody>
231
+            </table>
232
+          </td>
233
+        </tr>
234
+      </tbody>
235
+    </table>
236
+  </div>
198 237
   <div class="tabsAction">
199 238
     <div class="inline-block divButAction">
200 239
       <a href="<?= $url."?id=".$phcptype->id."&action=edit" ?>" class="butAction">
@@ -202,7 +241,7 @@ elseif ($action == 'show') {
202 241
       </a>
203 242
     </div>
204 243
     <div class="inline-block divButAction">
205
-      <span class="butActionDelete" id="action-delete">Delete</span>
244
+      <a href="<?= $url.'?id='.$phcptype->id.'&action=delete' ?>" class="butActionDelete" id="action-delete">Suprimer</a>
206 245
     </div>
207 246
   </div>
208 247
 <?php 
@@ -213,14 +252,16 @@ else {
213 252
   $form= new Form($db);
214 253
   $sql = "SELECT";
215 254
   $sql.= " pt.rowid,";
255
+  $sql.= " pt.ref,";
216 256
 	$sql.= " pt.nom";
217 257
   $sql.= " FROM ".MAIN_DB_PREFIX."phcp_type as pt";
218 258
 
219 259
   print '<table class="noborder" width="100%">'."\n";
220 260
   print '<tr class="liste_titre">';
221
-  print_liste_field_titre($langs->trans('rowid'),$_SERVER['PHP_SELF'],'pt.rowid','',$param,'',$sortfield,$sortorder);
222
-  print_liste_field_titre($langs->trans('nom'),$_SERVER['PHP_SELF'],'pt.nom','',$param,'',$sortfield,$sortorder);
261
+  print_liste_field_titre($langs->trans('Ref.'),$_SERVER['PHP_SELF'],'pt.ref','',$param,'',$sortfield,$sortorder);
262
+  print_liste_field_titre($langs->trans('Label Type Photocopieur'),$_SERVER['PHP_SELF'],'pt.nom','',$param,'',$sortfield,$sortorder);
223 263
   print '<th>Tarifs associés</th>';
264
+  print '<th>&nbsp;</th>';
224 265
   print '</tr>';
225 266
 
226 267
   dol_syslog($script_file." sql=".$sql, LOG_DEBUG);
@@ -233,7 +274,7 @@ else {
233 274
               $obj = $db->fetch_object($resql);
234 275
               if ($obj){
235 276
                   print '<tr><td>';
236
-                  print $obj->rowid;
277
+                  print $obj->ref;
237 278
                   print '</td><td><a href="'.$url.'?id='.$obj->rowid.'&action=show">';
238 279
                   print $obj->nom;
239 280
                   print '</a></td><td><ul>';
@@ -269,7 +310,9 @@ else {
269 310
 
270 311
                   // You can use here results
271 312
                   
272
-                  print '</ul></td></tr>';
313
+                  print '</ul></td><td align="right">';
314
+                  print '<a href="'.$url.'?id='.$obj->rowid.'&action=delete">X</a>';
315
+                  print '</td></tr>';
273 316
               }
274 317
               $i++;
275 318
           }

+ 14
- 14
sql/data.sql View File

@@ -15,22 +15,22 @@
15 15
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16
 
17 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);
18
+insert into llx_phcp_type(rowid, ref, nom)
19
+values (1, "PTA", "Photocopieur Type A") on duplicate key update nom=values(nom);
20
+insert into llx_phcp_type(rowid, ref, nom)
21
+values (2, "PTB", "Photocopieur Type B") on duplicate key update nom=values(nom);
22 22
 
23 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);
24
+insert into llx_phcp (rowid, ref, nom, fk_phcp_type, fk_societe) 
25
+values (1, "PA1", "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, ref, nom, fk_phcp_type, fk_societe) 
27
+values (2, "PA2", "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, ref, nom, fk_phcp_type, fk_societe) 
29
+values (3, "PA3", "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, ref, nom, fk_phcp_type, fk_societe) 
31
+values (4, "PB1", "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, ref, nom, fk_phcp_type, fk_societe) 
33
+values (5, "PB2", "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 34
 
35 35
 -- Type de photocopieurs avec leur tarifs
36 36
 insert into llx_phcp_type_product(rowid, fk_phcp_type, fk_product)

+ 1
- 0
sql/llx_phcp.key.sql View File

@@ -20,4 +20,5 @@ ALTER TABLE llx_phcp ADD INDEX idx_phcp_fk_phcp_type (fk_phcp_type);
20 20
 ALTER TABLE llx_phcp ADD INDEX idx_phcp_fk_societe (fk_societe);
21 21
 
22 22
 ALTER TABLE llx_phcp ADD CONSTRAINT fk_phcp_fk_phcp_type FOREIGN KEY (fk_phcp_type) REFERENCES llx_phcp_type (rowid);
23
+-- ON DELETE CASCADE ON UPDATE CASCADE
23 24
 ALTER TABLE llx_phcp ADD CONSTRAINT fk_phcp_fk_societe FOREIGN KEY (fk_societe) REFERENCES llx_societe (rowid);

+ 5
- 5
sql/llx_phcp.sql View File

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

+ 2
- 3
sql/llx_phcp_product.sql View File

@@ -18,14 +18,13 @@ create table llx_phcp_product
18 18
 (
19 19
   rowid					                            integer AUTO_INCREMENT PRIMARY KEY,
20 20
 
21
-  ref_ext				                            varchar(255),							-- reference into an external system (not used by dolibarr)
22
-  ref_int				                            varchar(255),							-- reference into an internal system (used by dolibarr)
21
+  ref   				                            varchar(255),							-- reference into an internal system (used by dolibarr)
23 22
 
24 23
   last_modification                         date,
25 24
   compteur                                  integer,
26 25
   last_compteur                             integer,
27 26
 
28
-  fk_phcp                           integer,								-- reference phcp
27
+  fk_phcp                                   integer,								-- reference phcp
29 28
   fk_product                                integer                 -- reference produuit
30 29
 
31 30
 )ENGINE=innodb;

+ 1
- 2
sql/llx_phcp_type.sql View File

@@ -20,7 +20,6 @@ create table llx_phcp_type
20 20
 
21 21
   nom                             varchar(255),             -- nom du type de phocotocopieur
22 22
 
23
-  ref_ext			                   	varchar(255),							-- reference into an external system (not used by dolibarr)
24
-  ref_int			                   	varchar(255)							-- reference into an internal system (used by dolibarr)
23
+  ref   			                   	varchar(255)							-- reference into an internal system (used by dolibarr)
25 24
 
26 25
 )ENGINE=innodb;

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

@@ -20,5 +20,5 @@
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);
22 22
 
23
-ALTER TABLE llx_phcp_type_product ADD CONSTRAINT fk_phcp_type_product_fk_phcp_tpye    FOREIGN KEY (fk_phcp_type) REFERENCES llx_phcp_type (rowid);
23
+ALTER TABLE llx_phcp_type_product ADD CONSTRAINT fk_phcp_type_product_fk_phcp_type    FOREIGN KEY (fk_phcp_type) REFERENCES llx_phcp_type (rowid);
24 24
 ALTER TABLE llx_phcp_type_product ADD CONSTRAINT fk_phcp_type_product_fk_product    FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);

+ 2
- 3
sql/llx_phcp_type_product.sql View File

@@ -18,10 +18,9 @@ create table llx_phcp_type_product
18 18
 (
19 19
   rowid					                          integer AUTO_INCREMENT PRIMARY KEY,
20 20
 
21
-  ref_ext		          	                	varchar(255),							-- reference into an external system (not used by dolibarr)
22
-  ref_int		          	                	varchar(255),							-- reference into an internal system (used by dolibarr)
21
+  ref   		          	                	varchar(255),							-- reference into an internal system (used by dolibarr)
23 22
 
24
-  fk_phcp_type	                	integer,								-- createur de la facture
23
+  fk_phcp_type        	                	integer,								-- createur de la facture
25 24
   fk_product	        	                	integer								-- valideur de la facture
26 25
 
27 26
 )ENGINE=innodb;

Loading…
Cancel
Save