Passed
Push — master ( fa5a21...043752 )
by Alxarafe
27:01
created
dolibarr/htdocs/comm/remise.php 1 patch
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 // Security check
40 40
 if ($user->societe_id > 0)
41 41
 {
42
-	$socid = $user->societe_id;
42
+    $socid = $user->societe_id;
43 43
 }
44 44
 
45 45
 $backtopage = GETPOST('backtopage','alpha');
@@ -51,40 +51,40 @@  discard block
 block discarded – undo
51 51
 
52 52
 if (GETPOST('cancel','alpha') && ! empty($backtopage))
53 53
 {
54
-     header("Location: ".$backtopage);
55
-     exit;
54
+        header("Location: ".$backtopage);
55
+        exit;
56 56
 }
57 57
 
58 58
 if (GETPOST('action','aZ09') == 'setremise')
59 59
 {
60
-	$object = new Societe($db);
61
-	$object->fetch($id);
62
-
63
-	$discount_type = GETPOST('discount_type', 'int');
64
-
65
-	if(! empty($discount_type)) {
66
-		$result=$object->set_remise_supplier(price2num(GETPOST("remise")),GETPOST("note"),$user);
67
-	} else {
68
-		$result=$object->set_remise_client(price2num(GETPOST("remise")),GETPOST("note"),$user);
69
-	}
70
-
71
-	if ($result > 0)
72
-	{
73
-	    if (! empty($backtopage))
74
-	    {
75
-    		header("Location: ".$backtopage);
76
-    		exit;
77
-	    }
78
-	    else
79
-	    {
80
-    		header("Location: remise.php?id=".$_GET["id"]);
81
-    		exit;
82
-	    }
83
-	}
84
-	else
85
-	{
86
-		setEventMessages($object->error, $object->errors, 'errors');
87
-	}
60
+    $object = new Societe($db);
61
+    $object->fetch($id);
62
+
63
+    $discount_type = GETPOST('discount_type', 'int');
64
+
65
+    if(! empty($discount_type)) {
66
+        $result=$object->set_remise_supplier(price2num(GETPOST("remise")),GETPOST("note"),$user);
67
+    } else {
68
+        $result=$object->set_remise_client(price2num(GETPOST("remise")),GETPOST("note"),$user);
69
+    }
70
+
71
+    if ($result > 0)
72
+    {
73
+        if (! empty($backtopage))
74
+        {
75
+            header("Location: ".$backtopage);
76
+            exit;
77
+        }
78
+        else
79
+        {
80
+            header("Location: remise.php?id=".$_GET["id"]);
81
+            exit;
82
+        }
83
+    }
84
+    else
85
+    {
86
+        setEventMessages($object->error, $object->errors, 'errors');
87
+    }
88 88
 }
89 89
 
90 90
 
@@ -104,21 +104,21 @@  discard block
 block discarded – undo
104 104
  *********************************************************************************/
105 105
 if ($socid > 0)
106 106
 {
107
-	// On recupere les donnees societes par l'objet
108
-	$object = new Societe($db);
109
-	$object->fetch($socid);
107
+    // On recupere les donnees societes par l'objet
108
+    $object = new Societe($db);
109
+    $object->fetch($socid);
110 110
 
111
-	$head = societe_prepare_head($object);
111
+    $head = societe_prepare_head($object);
112 112
 
113
-	$isCustomer = $object->client == 1 || $object->client == 3;
114
-	$isSupplier = $object->fournisseur == 1;
113
+    $isCustomer = $object->client == 1 || $object->client == 3;
114
+    $isSupplier = $object->fournisseur == 1;
115 115
 
116
-	print '<form method="POST" action="remise.php?id='.$object->id.'">';
117
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
118
-	print '<input type="hidden" name="action" value="setremise">';
116
+    print '<form method="POST" action="remise.php?id='.$object->id.'">';
117
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
118
+    print '<input type="hidden" name="action" value="setremise">';
119 119
     print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
120 120
 
121
-	dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"), -1, 'company');
121
+    dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"), -1, 'company');
122 122
 
123 123
     dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
124 124
 
@@ -127,208 +127,208 @@  discard block
 block discarded – undo
127 127
     print '<div class="underbanner clearboth"></div>';
128 128
 
129 129
     if(! $isCustomer && ! $isSupplier) {
130
-    	print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>';
130
+        print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>';
131 131
 
132
-    	dol_fiche_end();
132
+        dol_fiche_end();
133 133
 
134
-    	print '</form>';
134
+        print '</form>';
135 135
 
136
-    	// End of page
136
+        // End of page
137 137
         llxFooter();
138 138
         $db->close();
139
-    	exit;
139
+        exit;
140 140
     }
141 141
 
142
-	print '<table class="border centpercent">';
142
+    print '<table class="border centpercent">';
143 143
 
144
-	if($isCustomer) {
145
-		// Customer discount
146
-		print '<tr><td class="titlefield">';
147
-		print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>";
148
-	}
144
+    if($isCustomer) {
145
+        // Customer discount
146
+        print '<tr><td class="titlefield">';
147
+        print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>";
148
+    }
149 149
 
150
-	if($isSupplier) {
151
-		// Supplier discount
152
-		print '<tr><td class="titlefield">';
153
-		print $langs->trans("SupplierRelativeDiscount").'</td><td>'.price2num($object->remise_supplier_percent)."%</td></tr>";
154
-	}
150
+    if($isSupplier) {
151
+        // Supplier discount
152
+        print '<tr><td class="titlefield">';
153
+        print $langs->trans("SupplierRelativeDiscount").'</td><td>'.price2num($object->remise_supplier_percent)."%</td></tr>";
154
+    }
155 155
 
156
-	print '</table>';
157
-	print '<br>';
156
+    print '</table>';
157
+    print '<br>';
158 158
 
159
-	print load_fiche_titre($langs->trans("NewRelativeDiscount"),'','');
159
+    print load_fiche_titre($langs->trans("NewRelativeDiscount"),'','');
160 160
 
161
-	print '<div class="underbanner clearboth"></div>';
161
+    print '<div class="underbanner clearboth"></div>';
162 162
 
163
-	if($isCustomer && ! $isSupplier) {
164
-		print '<input type="hidden" name="discount_type" value="0" />';
165
-	}
163
+    if($isCustomer && ! $isSupplier) {
164
+        print '<input type="hidden" name="discount_type" value="0" />';
165
+    }
166 166
 
167
-	if(! $isCustomer && $isSupplier) {
168
-		print '<input type="hidden" name="discount_type" value="1" />';
169
-	}
167
+    if(! $isCustomer && $isSupplier) {
168
+        print '<input type="hidden" name="discount_type" value="1" />';
169
+    }
170 170
 
171
-	print '<table class="border centpercent">';
171
+    print '<table class="border centpercent">';
172 172
 
173
-	if($isCustomer && $isSupplier) {
174
-		// Discount type
175
-		print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td>';
176
-		print '<td><input type="radio" name="discount_type" id="discount_type_0" selected value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>';
177
-		print ' <input type="radio" name="discount_type" id="discount_type_1" selected value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>';
178
-		print '</td></tr>';
179
-	}
173
+    if($isCustomer && $isSupplier) {
174
+        // Discount type
175
+        print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td>';
176
+        print '<td><input type="radio" name="discount_type" id="discount_type_0" selected value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>';
177
+        print ' <input type="radio" name="discount_type" id="discount_type_1" selected value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>';
178
+        print '</td></tr>';
179
+    }
180 180
 
181
-	// New value
182
-	print '<tr><td class="titlefield fieldrequired">';
183
-	print $langs->trans("NewValue").'</td><td><input type="text" size="5" name="remise" value="'.dol_escape_htmltag(GETPOST("remise")).'">%</td></tr>';
181
+    // New value
182
+    print '<tr><td class="titlefield fieldrequired">';
183
+    print $langs->trans("NewValue").'</td><td><input type="text" size="5" name="remise" value="'.dol_escape_htmltag(GETPOST("remise")).'">%</td></tr>';
184 184
 
185
-	// Motif/Note
186
-	print '<tr><td class="fieldrequired">';
187
-	print $langs->trans("NoteReason").'</td><td><input type="text" size="60" name="note" value="'.dol_escape_htmltag(GETPOST("note")).'"></td></tr>';
185
+    // Motif/Note
186
+    print '<tr><td class="fieldrequired">';
187
+    print $langs->trans("NoteReason").'</td><td><input type="text" size="60" name="note" value="'.dol_escape_htmltag(GETPOST("note")).'"></td></tr>';
188 188
 
189
-	print "</table>";
189
+    print "</table>";
190 190
 
191
-	print '</div>';
191
+    print '</div>';
192 192
 
193
-	dol_fiche_end();
193
+    dol_fiche_end();
194 194
 
195
-	print '<div class="center">';
196
-	print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
195
+    print '<div class="center">';
196
+    print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
197 197
     if (! empty($backtopage))
198 198
     {
199 199
         print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
200
-	    print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
200
+        print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
201 201
     }
202
-	print '</div>';
202
+    print '</div>';
203 203
 
204
-	print "</form>";
204
+    print "</form>";
205 205
 
206
-	print '<br>';
206
+    print '<br>';
207 207
 
208
-	if($isCustomer) {
209
-		if($isSupplier) {
210
-			print '<div class="fichecenter">';
211
-			print '<div class="fichehalfleft">';
212
-			print load_fiche_titre($langs->trans("CustomerDiscounts"), '', '');
213
-		}
208
+    if($isCustomer) {
209
+        if($isSupplier) {
210
+            print '<div class="fichecenter">';
211
+            print '<div class="fichehalfleft">';
212
+            print load_fiche_titre($langs->trans("CustomerDiscounts"), '', '');
213
+        }
214 214
 
215
-		/*
215
+        /*
216 216
 		 * List log of all customer percent discounts
217 217
 		 */
218
-		$sql  = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,";
219
-		$sql.= " u.login, u.rowid as user_id";
220
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u";
221
-		$sql.= " WHERE rc.fk_soc = " . $object->id;
222
-		$sql.= " AND rc.entity = " . $conf->entity;
223
-		$sql.= " AND u.rowid = rc.fk_user_author";
224
-		$sql.= " ORDER BY rc.datec DESC";
225
-
226
-		$resql=$db->query($sql);
227
-		if ($resql)
228
-		{
229
-			print '<table class="noborder" width="100%">';
230
-			$tag = !$tag;
231
-			print '<tr class="liste_titre">';
232
-			print '<td width="160">'.$langs->trans("Date").'</td>';
233
-			print '<td width="160" align="center">'.$langs->trans("CustomerRelativeDiscountShort").'</td>';
234
-			print '<td align="left">'.$langs->trans("NoteReason").'</td>';
235
-			print '<td align="center">'.$langs->trans("User").'</td>';
236
-			print '</tr>';
237
-			$num = $db->num_rows($resql);
238
-	        if ($num > 0)
239
-	        {
240
-			    $i = 0;
241
-	            while ($i < $num)
242
-	    		{
243
-	    			$obj = $db->fetch_object($resql);
244
-	    			print '<tr class="oddeven">';
245
-	    			print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>';
246
-	    			print '<td align="center">'.price2num($obj->remise_percent).'%</td>';
247
-	    			print '<td align="left">'.$obj->note.'</td>';
248
-	    			// print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>';
218
+        $sql  = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,";
219
+        $sql.= " u.login, u.rowid as user_id";
220
+        $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u";
221
+        $sql.= " WHERE rc.fk_soc = " . $object->id;
222
+        $sql.= " AND rc.entity = " . $conf->entity;
223
+        $sql.= " AND u.rowid = rc.fk_user_author";
224
+        $sql.= " ORDER BY rc.datec DESC";
225
+
226
+        $resql=$db->query($sql);
227
+        if ($resql)
228
+        {
229
+            print '<table class="noborder" width="100%">';
230
+            $tag = !$tag;
231
+            print '<tr class="liste_titre">';
232
+            print '<td width="160">'.$langs->trans("Date").'</td>';
233
+            print '<td width="160" align="center">'.$langs->trans("CustomerRelativeDiscountShort").'</td>';
234
+            print '<td align="left">'.$langs->trans("NoteReason").'</td>';
235
+            print '<td align="center">'.$langs->trans("User").'</td>';
236
+            print '</tr>';
237
+            $num = $db->num_rows($resql);
238
+            if ($num > 0)
239
+            {
240
+                $i = 0;
241
+                while ($i < $num)
242
+                {
243
+                    $obj = $db->fetch_object($resql);
244
+                    print '<tr class="oddeven">';
245
+                    print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>';
246
+                    print '<td align="center">'.price2num($obj->remise_percent).'%</td>';
247
+                    print '<td align="left">'.$obj->note.'</td>';
248
+                    // print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>';
249 249
                     print '<td align="center"><a href="' . BASE_URI . '?controller=user&method=card&id=' . $obj->user_id . '">' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $obj->login . '</a></td>';
250 250
                     print '</tr>';
251
-	    			$i++;
252
-	    		}
253
-			}
254
-			else
255
-			{
256
-			    print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
257
-			}
258
-			$db->free($resql);
259
-			print "</table>";
260
-		}
261
-		else
262
-		{
263
-			dol_print_error($db);
264
-		}
265
-	}
266
-
267
-	if($isSupplier) {
268
-		if($isCustomer) {
269
-			print '</div>'; // class="fichehalfleft"
270
-			print '<div class="fichehalfright">';
271
-			print '<div class="ficheaddleft">';
272
-			print load_fiche_titre($langs->trans("SupplierDiscounts"), '', '');
273
-		}
274
-
275
-		/*
251
+                    $i++;
252
+                }
253
+            }
254
+            else
255
+            {
256
+                print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
257
+            }
258
+            $db->free($resql);
259
+            print "</table>";
260
+        }
261
+        else
262
+        {
263
+            dol_print_error($db);
264
+        }
265
+    }
266
+
267
+    if($isSupplier) {
268
+        if($isCustomer) {
269
+            print '</div>'; // class="fichehalfleft"
270
+            print '<div class="fichehalfright">';
271
+            print '<div class="ficheaddleft">';
272
+            print load_fiche_titre($langs->trans("SupplierDiscounts"), '', '');
273
+        }
274
+
275
+        /*
276 276
 		 * List log of all supplier percent discounts
277 277
 		 */
278
-		$sql  = "SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,";
279
-		$sql.= " u.login, u.rowid as user_id";
280
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u";
281
-		$sql.= " WHERE rc.fk_soc = " . $object->id;
282
-		$sql.= " AND rc.entity = " . $conf->entity;
283
-		$sql.= " AND u.rowid = rc.fk_user_author";
284
-		$sql.= " ORDER BY rc.datec DESC";
285
-
286
-		$resql=$db->query($sql);
287
-		if ($resql)
288
-		{
289
-			print '<table class="noborder" width="100%">';
290
-			$tag = !$tag;
291
-			print '<tr class="liste_titre">';
292
-			print '<td width="160">'.$langs->trans("Date").'</td>';
293
-			print '<td width="160" align="center">'.$langs->trans("CustomerRelativeDiscountShort").'</td>';
294
-			print '<td align="left">'.$langs->trans("NoteReason").'</td>';
295
-			print '<td align="center">'.$langs->trans("User").'</td>';
296
-			print '</tr>';
297
-			$num = $db->num_rows($resql);
298
-			if ($num > 0)
299
-			{
300
-				$i = 0;
301
-				while ($i < $num)
302
-				{
303
-					$obj = $db->fetch_object($resql);
304
-					print '<tr class="oddeven">';
305
-					print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>';
306
-					print '<td align="center">'.price2num($obj->remise_percent).'%</td>';
307
-					print '<td align="left">'.$obj->note.'</td>';
308
-					// print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>';
278
+        $sql  = "SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,";
279
+        $sql.= " u.login, u.rowid as user_id";
280
+        $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u";
281
+        $sql.= " WHERE rc.fk_soc = " . $object->id;
282
+        $sql.= " AND rc.entity = " . $conf->entity;
283
+        $sql.= " AND u.rowid = rc.fk_user_author";
284
+        $sql.= " ORDER BY rc.datec DESC";
285
+
286
+        $resql=$db->query($sql);
287
+        if ($resql)
288
+        {
289
+            print '<table class="noborder" width="100%">';
290
+            $tag = !$tag;
291
+            print '<tr class="liste_titre">';
292
+            print '<td width="160">'.$langs->trans("Date").'</td>';
293
+            print '<td width="160" align="center">'.$langs->trans("CustomerRelativeDiscountShort").'</td>';
294
+            print '<td align="left">'.$langs->trans("NoteReason").'</td>';
295
+            print '<td align="center">'.$langs->trans("User").'</td>';
296
+            print '</tr>';
297
+            $num = $db->num_rows($resql);
298
+            if ($num > 0)
299
+            {
300
+                $i = 0;
301
+                while ($i < $num)
302
+                {
303
+                    $obj = $db->fetch_object($resql);
304
+                    print '<tr class="oddeven">';
305
+                    print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>';
306
+                    print '<td align="center">'.price2num($obj->remise_percent).'%</td>';
307
+                    print '<td align="left">'.$obj->note.'</td>';
308
+                    // print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>';
309 309
                     print '<td align="center"><a href="' . BASE_URI . '?controller=user&method=card&id=' . $obj->user_id . '">' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $obj->login . '</a></td>';
310 310
                     print '</tr>';
311
-					$i++;
312
-				}
313
-			}
314
-			else
315
-			{
316
-				print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
317
-			}
318
-			$db->free($resql);
319
-			print "</table>";
320
-		}
321
-		else
322
-		{
323
-			dol_print_error($db);
324
-		}
325
-
326
-		if($isCustomer) {
327
-			print '</div>'; // class="ficheaddleft"
328
-			print '</div>'; // class="fichehalfright"
329
-			print '</div>'; // class="fichecenter"
330
-		}
331
-	}
311
+                    $i++;
312
+                }
313
+            }
314
+            else
315
+            {
316
+                print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
317
+            }
318
+            $db->free($resql);
319
+            print "</table>";
320
+        }
321
+        else
322
+        {
323
+            dol_print_error($db);
324
+        }
325
+
326
+        if($isCustomer) {
327
+            print '</div>'; // class="ficheaddleft"
328
+            print '</div>'; // class="fichehalfright"
329
+            print '</div>'; // class="fichecenter"
330
+        }
331
+    }
332 332
 }
333 333
 
334 334
 // End of page
Please login to merge, or discard this patch.