Browse Source

Photocopieur Types OK + Associate to Product OK + TODO Validation

Ghislain Loaec 5 years ago
parent
commit
f9869c6a76
10 changed files with 441 additions and 920 deletions
  1. 17
    7
      class/phcp.class.php
  2. 114
    25
      class/phcptype.class.php
  3. 3
    3
      core/modules/modPhotocopies.class.php
  4. 0
    136
      list_phcp.php
  5. 0
    132
      mypage.php
  6. 13
    54
      phcp.php
  7. 294
    0
      phcptype.php
  8. 0
    187
      phcptype_page.php
  9. 0
    188
      phcptypeproduct_page.php
  10. 0
    188
      societephcp_page.php

+ 17
- 7
class/phcp.class.php View File

@@ -25,7 +25,7 @@
25 25
 
26 26
 // Put here all includes required by your class file
27 27
 require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
28
-//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
28
+require_once(DOL_DOCUMENT_ROOT."/photocopies/class/phcptype.class.php");
29 29
 //require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
30 30
 
31 31
 
@@ -46,7 +46,7 @@ class Phcp extends CommonObject
46 46
 	var $ref_ext;
47 47
 	var $ref_int;
48 48
 	var $fk_phcp_type;
49
-
49
+  var $phcp_type;
50 50
     
51 51
 
52 52
 
@@ -79,8 +79,11 @@ class Phcp extends CommonObject
79 79
 		if (isset($this->nom)) $this->nom=trim($this->nom);
80 80
 		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
81 81
 		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
82
-		if (isset($this->fk_phcp_type)) $this->fk_phcp_type=trim($this->fk_phcp_type);
83
-
82
+    if (isset($this->fk_phcp_type)){
83
+      $this->fk_phcp_type=trim($this->fk_phcp_type);
84
+      $this->phcp_type=new PhcpType($this->db);
85
+      $this->phcp_type->fetch($this->fk_phcp_type);
86
+    }
84 87
         
85 88
 
86 89
 		// Check parameters
@@ -183,6 +186,10 @@ class Phcp extends CommonObject
183 186
 				$this->ref_ext = $obj->ref_ext;
184 187
 				$this->ref_int = $obj->ref_int;
185 188
 				$this->fk_phcp_type = $obj->fk_phcp_type;
189
+        if (isset($this->fk_phcp_type)){
190
+          $this->phcp_type=new PhcpType($this->db);
191
+          $this->phcp_type->fetch($this->fk_phcp_type);
192
+        }
186 193
 
187 194
                 
188 195
             }
@@ -216,8 +223,11 @@ class Phcp extends CommonObject
216 223
 		if (isset($this->nom)) $this->nom=trim($this->nom);
217 224
 		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
218 225
 		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
219
-		if (isset($this->fk_phcp_type)) $this->fk_phcp_type=trim($this->fk_phcp_type);
220
-
226
+    if (isset($this->fk_phcp_type)){
227
+      $this->fk_phcp_type=trim($this->fk_phcp_type);
228
+      $this->phcp_type=new PhcpType($this->db);
229
+      $this->phcp_type->fetch($this->fk_phcp_type);
230
+    }
221 231
         
222 232
 
223 233
 		// Check parameters
@@ -402,7 +412,7 @@ class Phcp extends CommonObject
402 412
 		$this->ref_ext='';
403 413
 		$this->ref_int='';
404 414
 		$this->fk_phcp_type='';
405
-
415
+    $this->phcp_type=null;
406 416
 		
407 417
 	}
408 418
 

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

@@ -26,28 +26,26 @@
26 26
 // Put here all includes required by your class file
27 27
 require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
28 28
 //require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
29
-//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
29
+require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
30 30
 
31 31
 
32 32
 /**
33 33
  *	Put here description of your class
34 34
  */
35
-class Phcptype extends CommonObject
35
+class PhcpType extends CommonObject
36 36
 {
37 37
 	var $db;							//!< To store db handler
38 38
 	var $error;							//!< To return error code (or message)
39 39
 	var $errors=array();				//!< To return several error codes (or messages)
40 40
 	var $element='phcptype';			//!< Id that identify managed objects
41 41
 	var $table_element='phcptype';		//!< Name of table without prefix where object is stored
42
-
42
+  
43 43
     var $id;
44 44
     
45
-	var $phcp_type_number;
46
-	var $entity;
47 45
 	var $nom;
48 46
 	var $ref_ext;
49 47
 	var $ref_int;
50
-
48
+  var $products;
51 49
     
52 50
 
53 51
 
@@ -63,6 +61,92 @@ class Phcptype extends CommonObject
63 61
     }
64 62
 
65 63
 
64
+
65
+  function add_product($fk_product){
66
+          global $conf, $langs;
67
+          $error =0;
68
+          $present = false;
69
+          foreach($this->products as $product){
70
+            $present |= $product->id == $fk_product;
71
+          }
72
+          if(!$present){
73
+
74
+          $product = new Product($this->db);
75
+          $product->fetch($fk_product);
76
+       
77
+          $sql = "INSERT INTO ".MAIN_DB_PREFIX."phcp_type_product(";
78
+          $sql.= "fk_phcp_type, fk_product) ";
79
+          $sql.= "VALUES (";
80
+          $sql.= $this->id.",";
81
+          $sql.= $fk_product.")";
82
+
83
+		      $this->db->begin();
84
+
85
+	   	    dol_syslog(get_class($this)."::add_product sql=".$sql, LOG_DEBUG);
86
+          $resql=$this->db->query($sql);
87
+    	    if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
88
+
89
+
90
+          // Commit or rollback
91
+          if ($error)
92
+	      	{
93
+			      foreach($this->errors as $errmsg)
94
+		      	{
95
+	            dol_syslog(get_class($this)."::add_product ".$errmsg, LOG_ERR);
96
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
97
+		      	}
98
+			      $this->db->rollback();
99
+		      	return -1*$error;
100
+		      }
101
+		      else
102
+		      {
103
+            $this->db->commit();
104
+            $this->products[] = $product;
105
+            return 1;
106
+		      }
107
+          }
108
+
109
+  }
110
+
111
+  function remove_product($fk_product){
112
+    	global $conf, $langs;
113
+      $error=0;
114
+
115
+          foreach($this->products as $key => $product){
116
+                  if($product->id == $fk_product)
117
+                    unset($this->products[$key]);
118
+          }
119
+      $sql = "DELETE FROM ".MAIN_DB_PREFIX."phcp_type_product ";
120
+      $sql.= "WHERE fk_product = ".$fk_product." ";
121
+      $sql.= "AND fk_phcp_type = ".$this->id;
122
+
123
+		      $this->db->begin();
124
+
125
+	   	    dol_syslog(get_class($this)."::remove_product sql=".$sql, LOG_DEBUG);
126
+          $resql=$this->db->query($sql);
127
+    	    if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
128
+
129
+
130
+          // Commit or rollback
131
+          if ($error)
132
+	      	{
133
+			      foreach($this->errors as $errmsg)
134
+		      	{
135
+	            dol_syslog(get_class($this)."::remove_product ".$errmsg, LOG_ERR);
136
+	            $this->error.=($this->error?', '.$errmsg:$errmsg);
137
+		      	}
138
+			      $this->db->rollback();
139
+		      	return -1*$error;
140
+		      }
141
+		      else
142
+		      {
143
+            $this->db->commit();
144
+            $this->products[] = $product;
145
+            return 1;
146
+		      }
147
+
148
+  }
149
+
66 150
     /**
67 151
      *  Create object into database
68 152
      *
@@ -77,8 +161,6 @@ class Phcptype extends CommonObject
77 161
 
78 162
 		// Clean parameters
79 163
         
80
-		if (isset($this->phcp_type_number)) $this->phcp_type_number=trim($this->phcp_type_number);
81
-		if (isset($this->entity)) $this->entity=trim($this->entity);
82 164
 		if (isset($this->nom)) $this->nom=trim($this->nom);
83 165
 		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
84 166
 		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
@@ -91,8 +173,6 @@ class Phcptype extends CommonObject
91 173
         // Insert request
92 174
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."phcp_type(";
93 175
 		
94
-		$sql.= "phcp_type_number,";
95
-		$sql.= "entity,";
96 176
 		$sql.= "nom,";
97 177
 		$sql.= "ref_ext,";
98 178
 		$sql.= "ref_int";
@@ -100,8 +180,6 @@ class Phcptype extends CommonObject
100 180
 		
101 181
         $sql.= ") VALUES (";
102 182
         
103
-		$sql.= " ".(! isset($this->phcp_type_number)?'NULL':"'".$this->db->escape($this->phcp_type_number)."'").",";
104
-		$sql.= " ".(! isset($this->entity)?'NULL':"'".$this->entity."'").",";
105 183
 		$sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").",";
106 184
 		$sql.= " ".(! isset($this->ref_ext)?'NULL':"'".$this->db->escape($this->ref_ext)."'").",";
107 185
 		$sql.= " ".(! isset($this->ref_int)?'NULL':"'".$this->db->escape($this->ref_int)."'")."";
@@ -164,8 +242,6 @@ class Phcptype extends CommonObject
164 242
         $sql = "SELECT";
165 243
 		$sql.= " t.rowid,";
166 244
 		
167
-		$sql.= " t.phcp_type_number,";
168
-		$sql.= " t.entity,";
169 245
 		$sql.= " t.nom,";
170 246
 		$sql.= " t.ref_ext,";
171 247
 		$sql.= " t.ref_int";
@@ -184,13 +260,32 @@ class Phcptype extends CommonObject
184 260
 
185 261
                 $this->id    = $obj->rowid;
186 262
                 
187
-				$this->phcp_type_number = $obj->phcp_type_number;
188
-				$this->entity = $obj->entity;
189 263
 				$this->nom = $obj->nom;
190 264
 				$this->ref_ext = $obj->ref_ext;
191
-				$this->ref_int = $obj->ref_int;
192
-
193
-                
265
+        $this->ref_int = $obj->ref_int;
266
+        $this->products = array();
267
+
268
+        $sql2 = "SELECT";
269
+        $sql2.= " ptpr.fk_product";
270
+        $sql2.= " FROM ".MAIN_DB_PREFIX."phcp_type_product as ptpr";
271
+        $sql2.= " WHERE ptpr.fk_phcp_type = ".$this->id;
272
+
273
+        $resql2=$this->db->query($sql2);
274
+        if ($resql2){
275
+            $num2 = $this->db->num_rows($resql2);
276
+            $i2 = 0;
277
+            if ($num2){
278
+                while ($i2 < $num2){
279
+                    $obj2 = $this->db->fetch_object($resql2);
280
+                    if ($obj2){
281
+                       $product = new Product($this->db);
282
+                       $product->fetch($obj2->fk_product);
283
+                       $this->products[] = $product;
284
+                    }
285
+                    $i2++;
286
+                }
287
+            }
288
+        }
194 289
             }
195 290
             $this->db->free($resql);
196 291
 
@@ -219,8 +314,6 @@ class Phcptype extends CommonObject
219 314
 
220 315
 		// Clean parameters
221 316
         
222
-		if (isset($this->phcp_type_number)) $this->phcp_type_number=trim($this->phcp_type_number);
223
-		if (isset($this->entity)) $this->entity=trim($this->entity);
224 317
 		if (isset($this->nom)) $this->nom=trim($this->nom);
225 318
 		if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext);
226 319
 		if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
@@ -233,8 +326,6 @@ class Phcptype extends CommonObject
233 326
         // Update request
234 327
         $sql = "UPDATE ".MAIN_DB_PREFIX."phcp_type SET";
235 328
         
236
-		$sql.= " phcp_type_number=".(isset($this->phcp_type_number)?"'".$this->db->escape($this->phcp_type_number)."'":"null").",";
237
-		$sql.= " entity=".(isset($this->entity)?$this->entity:"null").",";
238 329
 		$sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").",";
239 330
 		$sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").",";
240 331
 		$sql.= " ref_int=".(isset($this->ref_int)?"'".$this->db->escape($this->ref_int)."'":"null")."";
@@ -407,8 +498,6 @@ class Phcptype extends CommonObject
407 498
 	{
408 499
 		$this->id=0;
409 500
 		
410
-		$this->phcp_type_number='';
411
-		$this->entity='';
412 501
 		$this->nom='';
413 502
 		$this->ref_ext='';
414 503
 		$this->ref_int='';

+ 3
- 3
core/modules/modPhotocopies.class.php View File

@@ -362,7 +362,7 @@ class modPhotocopies extends DolibarrModules
362 362
         	'titre'=>'Photocopieur Types',
363 363
         	'mainmenu'=>'photocopies',
364 364
         	'leftmenu'=>'photocopieur_types',
365
-        	'url'=>'/photocopies/list_phcp_types.php',
365
+        	'url'=>'/photocopies/phcptype.php?action=list',
366 366
         	// Lang file to use (without .lang) by module.
367 367
         	// File must be in langs/code_CODE/ directory.
368 368
         	'langs'=>'photocopies',
@@ -387,7 +387,7 @@ class modPhotocopies extends DolibarrModules
387 387
         	'titre'=>'New Photocopieur Type',
388 388
         	'mainmenu'=>'photocopies',
389 389
         	'leftmenu'=>'new_phcp_type',
390
-        	'url'=>'/photocopies/new_phcp_type.php',
390
+        	'url'=>'/photocopies/phcptype.php?action=new',
391 391
         	// Lang file to use (without .lang) by module.
392 392
         	// File must be in langs/code_CODE/ directory.
393 393
         	'langs'=>'photocopies',
@@ -412,7 +412,7 @@ class modPhotocopies extends DolibarrModules
412 412
         	'titre'=>'List',
413 413
         	'mainmenu'=>'photocopies',
414 414
         	'leftmenu'=>'list_phcp_type',
415
-        	'url'=>'/photocopies/list_phcp_type.php',
415
+        	'url'=>'/photocopies/phcptype.php?action=list',
416 416
         	// Lang file to use (without .lang) by module.
417 417
         	// File must be in langs/code_CODE/ directory.
418 418
         	'langs'=>'photocopies',

+ 0
- 136
list_phcp.php View File

@@ -1,136 +0,0 @@
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>

+ 0
- 132
mypage.php View File

@@ -1,132 +0,0 @@
1
-<?php
2
-/* <one line to give the program's name and a brief idea of what it does.>
3
- * Copyright (C) <year>  <name of author>
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		mypage.php
21
- *	\ingroup	photocopies
22
- *	\brief		This file is an example php page
23
- *				Put some comments here
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');
31
-//if (! defined('NOTOKENRENEWAL'))	define('NOTOKENRENEWAL','1');
32
-// If there is no menu to show
33
-//if (! defined('NOREQUIREMENU'))	define('NOREQUIREMENU','1');
34
-// If we don't need to load the html.form.class.php
35
-//if (! defined('NOREQUIREHTML'))	define('NOREQUIREHTML','1');
36
-//if (! defined('NOREQUIREAJAX'))	define('NOREQUIREAJAX','1');
37
-// If this page is public (can be called outside logged session)
38
-//if (! defined("NOLOGIN"))			define("NOLOGIN",'1');
39
-// Choose the following lines to use the correct relative path
40
-// (../, ../../, etc)
41
-$res = 0;
42
-if (! $res && file_exists("../main.inc.php")) {
43
-    $res = @include("../main.inc.php");
44
-}
45
-if (! $res && file_exists("../../main.inc.php")) {
46
-    $res = @include("../../main.inc.php");
47
-}
48
-if (! $res && file_exists("../../../main.inc.php")) {
49
-    $res = @include("../../../main.inc.php");
50
-}
51
-// The following should only be used in development environments
52
-if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) {
53
-    $res = @include("../../../dolibarr/htdocs/main.inc.php");
54
-}
55
-if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) {
56
-    $res = @include("../../../../dolibarr/htdocs/main.inc.php");
57
-}
58
-if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) {
59
-    $res = @include("../../../../../dolibarr/htdocs/main.inc.php");
60
-}
61
-if (! $res) {
62
-    die("Main include failed");
63
-}
64
-// Change this following line to use the correct relative path from htdocs
65
-// (do not remove DOL_DOCUMENT_ROOT)
66
-require_once DOL_DOCUMENT_ROOT . "/photocopies/class/myclass.class.php";
67
-
68
-// Load translation files required by the page
69
-$langs->load("photocopies@photocopies");
70
-
71
-// Get parameters
72
-$id = GETPOST('id', 'int');
73
-$action = GETPOST('action', 'alpha');
74
-$myparam = GETPOST('myparam', 'alpha');
75
-
76
-// Access control
77
-if ($user->societe_id > 0) {
78
-    // External user
79
-    accessforbidden();
80
-}
81
-
82
-/*
83
- * ACTIONS
84
- *
85
- * Put here all code to do according to value of "action" parameter
86
- */
87
-
88
-if ($action == 'add') {
89
-    $myobject = new SkeletonClass($db);
90
-    $myobject->prop1 = $_POST["field1"];
91
-    $myobject->prop2 = $_POST["field2"];
92
-    $result = $myobject->create($user);
93
-    if ($result > 0) {
94
-        // Creation OK
95
-    } {
96
-        // Creation KO
97
-        $mesg = $myobject->error;
98
-    }
99
-}
100
-
101
-/*
102
- * VIEW
103
- *
104
- * Put here all code to build page
105
- */
106
-
107
-llxHeader('', 'Photocopies', '');
108
-
109
-$form = new Form($db);
110
-
111
-// Put here content of your page
112
-// Example 1 : Adding jquery code
113
-echo '<script type="text/javascript" language="javascript">
114
-jQuery(document).ready(function() {
115
-    function init_myfunc()
116
-    {
117
-        jQuery("#myid").removeAttr(\'disabled\');
118
-        jQuery("#myid").attr(\'disabled\',\'disabled\');
119
-    }
120
-    init_myfunc();
121
-    jQuery("#mybutton").click(function() {
122
-        init_needroot();
123
-    });
124
-});
125
-</script>';
126
-
127
-// Example 2 : Adding jquery code
128
-$somethingshown = $myobject->showLinkedObjectBlock();
129
-
130
-// End of page
131
-llxFooter();
132
-$db->close();

+ 13
- 54
phcp.php View File

@@ -16,79 +16,38 @@ $langs->load("other");
16 16
 
17 17
 // Get parameters
18 18
 $id			  = GETPOST('id','int');
19
-$action		= GETPOST('action','alpha');
19
+$action		= GETPOST('action','alpha') ?: 'list';
20 20
 $myparam	= GETPOST('myparam','alpha');
21 21
 $url      = DOL_URL_ROOT."/photocopies/phcp.php";
22 22
 $phcp     = null;
23 23
 $title    = null;
24 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 25
 /*******************************************************************
55 26
 * ACTIONS
56 27
 *
57 28
 * Put here all code to do according to value of "action" parameter
58 29
 ********************************************************************/
59 30
 
31
+$phcp = new Phcp($db);
32
+if($id) $phcp->fetch($id);
33
+
60 34
 //------------------------------------------------------------------------------
61 35
 if ($action == 'create') {
62
-	$phcp = new Phcp($db);
63 36
 	$phcp->nom=$_POST["nom"];
64 37
 	$phcp->fk_phcp_type=$_POST["fk_phcp_type"];
65
-	$result = $phcp->create($user);
66
-	if ($result > 0)
67
-	{
68
-    // Creation OK
38
+	if ($phcp->create($user) >= 0)
69 39
     $action = 'show';
70
-  } 
71
-	{
72
-		// Creation KO
40
+  else
73 41
     $action = 'edit';
74
-	}
75 42
 }
76 43
 //------------------------------------------------------------------------------
77 44
 elseif ($action == 'update'){
78
-  $phcp = new Phcp($db);
79
-  $phcp->fetch($id);
80 45
 	$phcp->nom=$_POST["nom"];
81 46
 	$phcp->fk_phcp_type=$_POST["fk_phcp_type"];
82
-	$result = $phcp->update($user);
83
-	if ($result > 0)
84
-	{
85
-    // Creation OK
47
+	if ($phcp->update($user) >= 0)
86 48
     $action = 'show';
87
-  } 
88
-	{
89
-		// Creation KO
49
+  else 
90 50
     $action = 'edit';
91
-	}
92 51
 }
93 52
 
94 53
 $phcp_types = "";
@@ -146,7 +105,7 @@ if($phcp && $phcp->error){
146 105
   </table>
147 106
 
148 107
   <div class="fichecenter">
149
-    <div class="fichethirdleft">
108
+    <!--div class="fichethirdleft"-->
150 109
 
151 110
 <?php
152 111
 //------------------------------------------------------------------------------
@@ -191,10 +150,10 @@ elseif ($action == 'edit') {
191 150
 elseif ($action == 'show') { 
192 151
 ?>
193 152
   <strong>Nom : </strong><?= $phcp->nom ?><br />
194
-  <strong>Phococopieur Type : </strong><?= $phcp->phcp_type ?><br />
153
+  <strong>Phococopieur Type : </strong><?= $phcp->phcp_type->nom ?><br />
195 154
   <div class="tabsAction">
196 155
     <div class="inline-block divButAction">
197
-      <a href="<?= $url."?id=".$phcp->rowid."&action=edit" ?>" class="butAction">
156
+      <a href="<?= $url."?id=".$phcp->id."&action=edit" ?>" class="butAction">
198 157
         Modifier
199 158
       </a>
200 159
     </div>
@@ -207,7 +166,7 @@ elseif ($action == 'show') {
207 166
 //------------------------------------------------------------------------------
208 167
 else {
209 168
 
210
-  $form=new Form($db);
169
+  $form= new Form($db);
211 170
   $sql = "SELECT";
212 171
   $sql.= " p.rowid,";
213 172
 	$sql.= " p.nom,";
@@ -257,7 +216,7 @@ else {
257 216
   print '</table>'."\n";
258 217
 }
259 218
 ?>
260
-    </div>
219
+    <!--/div-->
261 220
   </div>
262 221
 </div> 
263 222
 

+ 294
- 0
phcptype.php View File

@@ -0,0 +1,294 @@
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/phcptype.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') ?: 'list';
20
+$myparam	= GETPOST('myparam','alpha');
21
+$url      = DOL_URL_ROOT."/photocopies/phcptype.php";
22
+$phcptype     = null;
23
+$title    = null;
24
+
25
+/*******************************************************************
26
+* ACTIONS
27
+*
28
+* Put here all code to do according to value of "action" parameter
29
+********************************************************************/
30
+
31
+$phcptype = new PhcpType($db);
32
+if($id) $phcptype->fetch($id);
33
+
34
+//------------------------------------------------------------------------------
35
+if ($action == 'create') {
36
+	$phcptype->nom=$_POST["nom"];
37
+	$phcptype->fk_phcp_type=$_POST["fk_phcp_type"];
38
+	if ($phcptype->create($user) >= 0)
39
+    $action = 'show';
40
+  else
41
+    $action = 'edit';
42
+}
43
+//------------------------------------------------------------------------------
44
+elseif ($action == 'update'){
45
+	$phcptype->nom=$_POST["nom"];
46
+	$phcptype->fk_phcp_type=$_POST["fk_phcp_type"];
47
+	if ($phcptype->update($user) >= 0)
48
+    $action = 'show';
49
+  else 
50
+    $action = 'edit';
51
+}
52
+//------------------------------------------------------------------------------
53
+elseif ($action == 'add_product'){
54
+        $fk_product = GETPOST('fk_product','int') ?: null;
55
+  if($fk_product){
56
+    $phcptype->add_product($fk_product);
57
+  }
58
+  $action = "edit";
59
+}
60
+//------------------------------------------------------------------------------
61
+elseif ($action == 'remove_product'){
62
+        $fk_product = GETPOST('fk_product','int') ?: null;
63
+        if($fk_product){
64
+          $phcptype->remove_product($fk_product);
65
+        }
66
+        $action = "edit";
67
+}
68
+
69
+$products = "";
70
+
71
+if($action == 'new' || $action == 'edit'){
72
+  $sql = "SELECT pr.rowid, pr.ref, pr.label, pr.price ";
73
+  $sql.= "FROM ".MAIN_DB_PREFIX."product as pr";
74
+  $resql=$db->query($sql);
75
+  if($resql){
76
+    $num = $db->num_rows($resql);
77
+    $i = 0;
78
+    if ($num){
79
+      while ($i < $num){
80
+        $obj = $db->fetch_object($resql);
81
+        if ($obj){
82
+          $products.= '<option value="'.$obj->rowid.'">'.$obj->ref.' - '.$obj->label.' - '.money_format("%i €", $obj->price).'</option>'."\n";
83
+        }
84
+        $i++;
85
+      }
86
+    }
87
+  }
88
+}
89
+
90
+switch($action){
91
+  case 'new': $title = "Nouveau Type de Photocopieur"; llxHeader('',$title,''); break;
92
+  case 'edit': $title = "Modifier le type de Photocopieur"; llxHeader('',$title,''); break;
93
+  case 'list': $title = "Liste des types de Photocopieurs"; llxHeader('',$title,''); break;
94
+  case 'show': $title = "Photocopieur Type : ".$phcptype->nom; llxHeader('',$title,''); break;
95
+}
96
+
97
+//===============================[TEMPLATE]=====================================
98
+if($phcptype && $phcptype->error){
99
+?>
100
+<script type="text/javascript">
101
+  $(document).ready(function(){
102
+    $.jnotify("<?= $phcptype->error ?>", "error");
103
+  })
104
+</script>
105
+<?php } ?>
106
+
107
+<div class="fiche">
108
+  <table width="100%" border="0" style="margin-bottom: 2px;" class="notopnoleftnoright" summary="">
109
+    <tbody>
110
+      <tr>
111
+        <td width="40" valign="middle" align="left" class="nobordernopadding hideonsmartphone">
112
+          <img border="0" id="pictotitle" title="" alt="" src="/dolibarr/theme/auguria/img/title.png">
113
+        </td>
114
+        <td valign="middle" class="nobordernopadding">
115
+          <div class="titre"><?= $title ?></div>
116
+        </td>
117
+      </tr>
118
+    </tbody>
119
+  </table>
120
+
121
+  <div class="fichecenter">
122
+    <!--div class="fichethirdleft"-->
123
+<?php
124
+//------------------------------------------------------------------------------
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') {
144
+?>
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>
159
+      <tbody>
160
+        <?php foreach($phcptype->products as $product){ ?>
161
+          <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>
166
+          </tr>
167
+        <?php } ?>
168
+      </tbody>
169
+    </table>
170
+    <div class="tabsAction">
171
+      <div class="inline-block divButAction">
172
+        <input type="submit" class="butAction" value="Modifier" />
173
+      </div>
174
+    </div>
175
+  </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>
185
+<?php
186
+        
187
+} 
188
+//------------------------------------------------------------------------------
189
+elseif ($action == 'show') { 
190
+?>
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> 
198
+  <div class="tabsAction">
199
+    <div class="inline-block divButAction">
200
+      <a href="<?= $url."?id=".$phcptype->id."&action=edit" ?>" class="butAction">
201
+        Modifier
202
+      </a>
203
+    </div>
204
+    <div class="inline-block divButAction">
205
+      <span class="butActionDelete" id="action-delete">Delete</span>
206
+    </div>
207
+  </div>
208
+<?php 
209
+}
210
+//------------------------------------------------------------------------------
211
+else {
212
+
213
+  $form= new Form($db);
214
+  $sql = "SELECT";
215
+  $sql.= " pt.rowid,";
216
+	$sql.= " pt.nom";
217
+  $sql.= " FROM ".MAIN_DB_PREFIX."phcp_type as pt";
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'],'pt.rowid','',$param,'',$sortfield,$sortorder);
222
+  print_liste_field_titre($langs->trans('nom'),$_SERVER['PHP_SELF'],'pt.nom','',$param,'',$sortfield,$sortorder);
223
+  print '<th>Tarifs associés</th>';
224
+  print '</tr>';
225
+
226
+  dol_syslog($script_file." sql=".$sql, LOG_DEBUG);
227
+  $resql=$db->query($sql);
228
+  if ($resql){
229
+      $num = $db->num_rows($resql);
230
+      $i = 0;
231
+      if ($num){
232
+          while ($i < $num){
233
+              $obj = $db->fetch_object($resql);
234
+              if ($obj){
235
+                  print '<tr><td>';
236
+                  print $obj->rowid;
237
+                  print '</td><td><a href="'.$url.'?id='.$obj->rowid.'&action=show">';
238
+                  print $obj->nom;
239
+                  print '</a></td><td><ul>';
240
+
241
+                  $sql2 = "SELECT";
242
+                  $sql2.= " pr.rowid,";
243
+                  $sql2.= " pr.label,";
244
+                  $sql2.= " pr.ref,";
245
+                  $sql2.= " pr.price";
246
+                  $sql2.= " FROM ".MAIN_DB_PREFIX."product as pr,";
247
+                  $sql2.= " ".MAIN_DB_PREFIX."phcp_type_product as ptpr";
248
+                  $sql2.= " WHERE pr.rowid = ptpr.fk_product";
249
+                  $sql2.= " AND ptpr.fk_phcp_type = ".$obj->rowid;
250
+
251
+                  $resql2=$db->query($sql2);
252
+                  if ($resql2){
253
+                      $num2 = $db->num_rows($resql2);
254
+                      $i2 = 0;
255
+                      if ($num2){
256
+                          while ($i2 < $num2){
257
+                              $obj2 = $db->fetch_object($resql2);
258
+                              if ($obj2){
259
+                                      print "<li>";
260
+                                print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$obj2->rowid.'">'.$obj2->ref.'</a>';
261
+                                print ' - '.$obj2->label;
262
+                                print " - ".money_format("%i €",$obj2->price);
263
+                                print "</li>";
264
+                              }
265
+                              $i2++;
266
+                          }
267
+                      }
268
+                  }
269
+
270
+                  // You can use here results
271
+                  
272
+                  print '</ul></td></tr>';
273
+              }
274
+              $i++;
275
+          }
276
+      }
277
+  }
278
+  else
279
+  {
280
+      $error++;
281
+      dol_print_error($db);
282
+  }
283
+  print '</table>'."\n";
284
+}
285
+?>
286
+    <!--/div-->
287
+  </div>
288
+</div> 
289
+
290
+<?php
291
+  // End of page
292
+  llxFooter();
293
+  $db->close();
294
+?>

+ 0
- 187
phcptype_page.php View File

@@ -1,187 +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/Phcptypes/Phcptype_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/phcptype.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 Phcptype($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_type_number,";
134
-		$sql.= " t.entity,";
135
-		$sql.= " t.nom,";
136
-		$sql.= " t.ref_ext,";
137
-		$sql.= " t.ref_int";
138
-
139
-    
140
-    $sql.= " FROM ".MAIN_DB_PREFIX."phcp_type as t";
141
-    $sql.= " WHERE field3 = 'xxx'";
142
-    $sql.= " ORDER BY field1 ASC";
143
-
144
-    print '<table class="noborder">'."\n";
145
-    print '<tr class="liste_titre">';
146
-    print_liste_field_titre($langs->trans('field1'),$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
147
-    print_liste_field_titre($langs->trans('field2'),$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
148
-    print '</tr>';
149
-
150
-    dol_syslog($script_file." sql=".$sql, LOG_DEBUG);
151
-    $resql=$db->query($sql);
152
-    if ($resql)
153
-    {
154
-        $num = $db->num_rows($resql);
155
-        $i = 0;
156
-        if ($num)
157
-        {
158
-            while ($i < $num)
159
-            {
160
-                $obj = $db->fetch_object($resql);
161
-                if ($obj)
162
-                {
163
-                    // You can use here results
164
-                    print '<tr><td>';
165
-                    print $obj->field1;
166
-                    print $obj->field2;
167
-                    print '</td></tr>';
168
-                }
169
-                $i++;
170
-            }
171
-        }
172
-    }
173
-    else
174
-    {
175
-        $error++;
176
-        dol_print_error($db);
177
-    }
178
-
179
-    print '</table>'."\n";
180
-}
181
-
182
-
183
-
184
-// End of page
185
-llxFooter();
186
-$db->close();
187
-?>

+ 0
- 188
phcptypeproduct_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/Phcptypeproducts/Phcptypeproduct_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/phcptypeproduct.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 Phcptypeproduct($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_type_product_number,";
134
-		$sql.= " t.entity,";
135
-		$sql.= " t.ref_ext,";
136
-		$sql.= " t.ref_int,";
137
-		$sql.= " t.fk_phcp_type,";
138
-		$sql.= " t.fk_product";
139
-
140
-    
141
-    $sql.= " FROM ".MAIN_DB_PREFIX."phcp_type_product 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
- 188
societephcp_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/Societephcps/Societephcp_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/societephcp.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 Societephcp($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_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
-
140
-    
141
-    $sql.= " FROM ".MAIN_DB_PREFIX."societe_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
-?>