Browse Source

Deletion PHcp ok

master
Ghislain Loaec 5 years ago
parent
commit
b53d8e754b
2 changed files with 16 additions and 3 deletions
  1. 9
    0
      class/phcp.class.php
  2. 7
    3
      phcp.php

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

@@ -435,6 +435,15 @@ class Phcp extends CommonObject
435 435
 
436 436
 		if (! $error)
437 437
 		{
438
+    		$sql = "DELETE FROM ".MAIN_DB_PREFIX."compteur";
439
+    		$sql.= " WHERE fk_phcp=".$this->id;
440
+
441
+    		dol_syslog(get_class($this)."::delete sql=".$sql);
442
+    		$resql = $this->db->query($sql);
443
+        	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
444
+		}
445
+		if (! $error)
446
+		{
438 447
     		$sql = "DELETE FROM ".MAIN_DB_PREFIX."phcp";
439 448
     		$sql.= " WHERE rowid=".$this->id;
440 449
 

+ 7
- 3
phcp.php View File

@@ -79,6 +79,11 @@ if($phcp && $phcp->error){
79 79
   })
80 80
 </script>
81 81
 <?php } ?>
82
+<script type="text/javascript">
83
+  function deletePhcp(){
84
+    return confirm("Cette action entrainera la suppression des compteurs auquels le photcopieur est associé. Êtes-vous sûr de vouloir continuer ?");
85
+  }
86
+</script>
82 87
 
83 88
 <div class="fiche">
84 89
   <table width="100%" border="0" style="margin-bottom: 2px;" class="notopnoleftnoright" summary="">
@@ -195,8 +200,7 @@ elseif ($action == 'show') {
195 200
       </a>
196 201
     </div>
197 202
     <div class="inline-block divButAction">
198
-      <!-- TODO: Action supprimer -->
199
-      <span class="butActionDelete" id="action-delete">Supprimer</span>
203
+      <a class="butActionDelete" id="action-delete" href="<?= $url.'?id='.$phcp->id.'&action=delete' ?>" onClick="return deletePhcp()">Supprimer</a>
200 204
     </div>
201 205
   </div>
202 206
 <?php 
@@ -246,7 +250,7 @@ else { ?>
246 250
               </a>
247 251
             <?php } else echo 'NON'; ?>
248 252
           </td>
249
-          <td align="right"><a href="<?= $url.'?id='.$p->id.'&action=delete' ?>">X</a></td>
253
+          <td align="right"><a href="<?= $url.'?id='.$p->id.'&action=delete' ?>" onClick="return deletePhcp()">X</a></td>
250 254
         </tr>
251 255
       <?php } ?>
252 256
     </tbody>

Loading…
Cancel
Save