PHP - No consigo que envíe email

 
Vista:
sin imagen de perfil
Val: 9
Ha aumentado su posición en 14 puestos en PHP (en relación al último mes)
Gráfica de PHP

No consigo que envíe email

Publicado por Gonzalo (13 intervenciones) el 28/05/2021 12:37:53
Buenos días, tengo un problema a la hora de que se envíe un correo al crear un "pedido" que simplemente es un formulario que llama a X tablas de BBDD y hace un select progresivo, filtrando los campos para poder seleccionar los productos según la familia y luego poner la cantidad deseada y que te calcule el total. Aparte hay un botón de enviar email que envía la tabla creada con los artículos.

Mi problema es que he conseguido modificar la tabla con las necesidades que me han pedido (simplemente he quitado varios campos que no nos hacían falta y he hecho que se calcule el total nuevamente)

Promociones.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
<?php require_once('../connections/comercial.php'); ?>
<?php
	if (!isset($_SESSION)) {
	  session_start();
	}
	$MM_authorizedUsers = "";
	$MM_donotCheckaccess = "true";
 
	// *** Restrict Access To Page: Grant or deny access to this page
	function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
	  // For security, start by assuming the visitor is NOT authorized.
	  $isValid = False;
 
	  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
	  // Therefore, we know that a user is NOT logged in if that Session variable is blank.
	  if (!empty($UserName)) {
		// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
		// Parse the strings into arrays.
		$arrUsers = Explode(",", $strUsers);
		$arrGroups = Explode(",", $strGroups);
		if (in_array($UserName, $arrUsers)) {
		  $isValid = true;
		}
		// Or, you may restrict access to only certain users based on their username.
		if (in_array($UserGroup, $arrGroups)) {
		  $isValid = true;
		}
		if (($strUsers == "") && true) {
		  $isValid = true;
		}
	  }
	  return $isValid;
	}
 
	$MM_restrictGoTo = "../logout.php";
	if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
	  $MM_qsChar = "?";
	  $MM_referrer = $_SERVER['PHP_SELF'];
	  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
	  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
		$MM_referrer .= "?" . $QUERY_STRING;
	  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
	  header("Location: ". $MM_restrictGoTo);
	  exit;
	}
?>
<?php
	if (!function_exists("GetSQLValueString")) {
	  function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
	  {
		$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
		$theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($theValue) : mysqli_escape_string($theValue);
 
		switch ($theType) {
		  case "text":
		  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
		  break;
		  case "long":
		  case "int":
		  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
		  break;
		  case "double":
		  $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
		  break;
		  case "date":
		  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
		  break;
		  case "defined":
		  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
		  break;
		}
		return $theValue;
	  }
	}
 
	$currentPage = $_SERVER["PHP_SELF"];
 
	mysqli_select_db($comercial, $database_comercial);
	$query_Recordset1 = "SELECT * FROM cliente WHERE cliente.cli_id='".$_REQUEST['id']."'";
	$Recordset1 = mysqli_query($comercial, $query_Recordset1) or die(mysqli_error());
	$row_Recordset1 = mysqli_fetch_assoc($Recordset1);
	$totalRows_Recordset1 = mysqli_num_rows($Recordset1);
 
	mysqli_select_db($comercial, $database_comercial);
	$query_Recordset2 = "SELECT DISTINCT familia FROM articulos ORDER BY familia";
	$Recordset2 = mysqli_query($comercial, $query_Recordset2) or die(mysqli_error());
	$row_Recordset2 = mysqli_fetch_assoc($Recordset2);
	$totalRows_Recordset2 = mysqli_num_rows($Recordset2);
 
	mysqli_select_db($comercial, $database_comercial);
	$query_Recordset3 = "SELECT * FROM regalospromos ORDER BY descripcion";
	$Recordset3 = mysqli_query($comercial, $query_Recordset3) or die(mysqli_error());
	$row_Recordset3 = mysqli_fetch_assoc($Recordset3);
	$totalRows_Recordset3 = mysqli_num_rows($Recordset3);
?>
 
<!DOCTYPE html>
<html lang="es">
	<head>
		<meta charset="utf-8" />
		<title>Portal CRM</title>
		<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" />
		<link href="../bootstrap/css/estilos.css" rel="stylesheet" />
		<script src="../bootstrap/js/jquery.js"></script>
		<script src="../bootstrap/js/bootstrap.min.js"></script>
		<script src="../includes/date.format.js"></script>
		<link rel="icon" type="image/x-icon" href="../favicon.ico" />
	</head>
	<body>
		<script type="text/javascript">
			var producto = [];
			var regalo;
			var filaactual;
			var familiastexto;
			//FUNCIONES
			function deshabilitar(num){
			  //document.getElementById("ref"+num).innerHTML = "";
			  document.getElementById("pvp"+num).innerHTML = "";
			  //document.getElementById("emb"+num).innerHTML = "";
			  //document.getElementById("caj"+num).innerHTML = "";
			  $( "#cant"+num ).val('');
			  $("#cant"+num).prop('disabled', true);
			}
			function habilitar(num){
			  $("#cant"+num).prop('disabled', false);
			  $("#cant"+num).val(producto[num]["caja"]);
			  $("#cant"+num).change();
			}
			function habilitarselects(num){
			  //alert("#fam"+num);
			  $("#fam"+num).prop('disabled', false);
			  $("#fam"+num).change();
			}
			function obtenerfamilias(){
			  var data = "";
			  $.ajax({
				type: 'GET',
				url: 'filtro_promociones.php?o=f5',
				data: data,
				success: function(data, textStatus, jqXHR)
				{
				  familias = jQuery.parseJSON(data);
				  familiastexto = "<option value=><b>Familia</b></option>";
				  for(var i=0; i<familias.length; i++){
					familiastexto += "<option value="+familias[i]+">"+familias[i]+"</option>";
				  }
				}});
			}
			function cambiartotal(num){
			  var filaactual = num;
			  var neto = parseFloat(producto[filaactual]["pvp"]);
			  $("#neto"+filaactual).html(neto.toFixed(2));
			  var total = parseInt($( "#cant"+filaactual ).val())*neto;
			  $("#total"+filaactual).html(total.toFixed(2));
			  cambiarresultado();
			}
			function cambiarresultado(){
			  var saltar = true;
			  var costetotal = 0;
			  var total = 0;
			  $("#tablappal tbody tr").each(function() {
				if (saltar) saltar = false;
				else{
				  var filanum = $(this).prop("id").replace('fila','');
				  total += parseFloat($("#total"+filanum).html());
				  costetotal += parseInt($( "#cant"+filanum ).val())*parseFloat(producto[filanum]["coste"]);
				}
			  });
			  $("#totaltotal").html("<b>"+total.toFixed(2)+"</b>");
			  var margenobt = total;
			  var margendes = total;
			  if(margenobt=margendes){ $("#resultado").html("ACEPTADA"); $("#mailbutton").prop("disabled",false);}
			  else{ $("#resultado").html("RECHAZADA"); $("#mailbutton").prop("disabled",true);}
			}
			function crearfila(){
			  var filaactual = window.filaactual;
			  var fila = document.getElementById('tablappal').insertRow(-1);
			  fila.id = "fila"+filaactual;
			  var t="";
			  t += "<td bgcolor='#ffffff'><select name=\"fam"+filaactual+"\" id=\"fam"+filaactual+"\" size=\"1\" disabled=\"true\">"+familiastexto+"</select></td>";
			  t += "<td bgcolor='#ffffff'><select name=\"marca"+filaactual+"\" id=\"marca"+filaactual+"\" size=\"1\"><option value=>Marca</option></select></td>";
			  t += "<td bgcolor='#ffffff'><select name=\"prod"+filaactual+"\" id=\"prod"+filaactual+"\" size=\"1\"><option value=>Producto</option></select></td>";
			  //t += "<td bgcolor='#ffffff' id=\"ref"+filaactual+"\"></td>";
			  //t += "<td bgcolor='#ffffff' id=\"emb"+filaactual+"\"></td>";
			  t += "<td bgcolor='#ffffff'><input id=\"cant"+filaactual+"\" type=\"number\" name=\"cant"+filaactual+"\" step=\"1\" disabled=\"true\" style=\"text-align: center; width: 50px\"></td>";
			  //t += "<td bgcolor='#ffffff' id=\"caj"+filaactual+"\"></td>";
			  t += "<td bgcolor='#ffffff' id=\"pvp"+filaactual+"\"></td>";
			  t += "<td bgcolor='#ffffff' id=\"total"+filaactual+"\"></td>";
			  t += "<td><button type=\"button\" id=\"borrar"+filaactual+"\" onclick=\"eliminarfila("+filaactual+");\" style='border:none;background-color: transparent'><img src='../botones/borrar.png' class='img-responsive' alt='Borrar producto' width='24'></button></td>";
			  fila.innerHTML = t;
 
			document.getElementById('fam'+filaactual).onchange = function(){
				deshabilitar(filaactual);
				var select = document.getElementById("marca"+filaactual);
				var length = select.options.length;
				for (i = 0; i < length; i++) select.options[i] = null;
				  var data = "";
				$.ajax({
				  type: 'GET',
				  url: 'filtro_promociones.php?o=f1&fam='+$( "#fam"+filaactual ).val(),
				  data: data,
				  success: function(data, textStatus, jqXHR)
				  {
					var t = "<option value=>Marca</option>";
					var marcas = jQuery.parseJSON("["+data+"]");
					for(var i=0; i<marcas[0].length; i++){
					  t += "<option value="+marcas[0][i]+">"+marcas[0][i]+"</option>";
					}
					document.getElementById("marca"+filaactual).innerHTML = t;
					document.getElementById("prod"+filaactual).innerHTML = "<option value=>Producto</option>";
					$("#prod"+filaactual).change();
				  }});
			};
			deshabilitar(filaactual);
			document.getElementById('marca'+filaactual).onchange = function(){
				deshabilitar(filaactual);
				var select = document.getElementById("prod"+filaactual);
				var length = select.options.length;
				for (i = 0; i < length; i++) select.options[i] = null;
				  var data = "";
				$.ajax({
				  type: 'GET',
				  url: 'filtro_promociones.php?o=f2&fam='+$( "#fam"+filaactual ).val()+'&marca='+$( "#marca"+filaactual ).val(),
				  data: data,
				  success: function(data, textStatus, jqXHR)
				  {
					var t = "<option value=>Producto</option>";
					var productos = jQuery.parseJSON("["+data+"]");
					for(var i=0; i<productos[0].length; i++){
					  t += "<option value="+productos[0][i][0]+">"+productos[0][i][1]+"</option>";
					}
					document.getElementById("prod"+filaactual).innerHTML = t;
					$("#prod"+filaactual).change();
				  }});
			};
			document.getElementById('prod'+filaactual).onchange = function(){
				deshabilitar(filaactual);
				var data = "";
				$.ajax({
				  type: 'GET',
				  url: 'filtro_promociones.php?o=f3&prod='+$( "#prod"+filaactual ).val(),
				  data: data,
				  success: function(data, textStatus, jqXHR)
				  {
					producto[filaactual] = jQuery.parseJSON(data);
					//document.getElementById("ref"+filaactual).innerHTML = producto[filaactual]["ref"];
					document.getElementById("pvp"+filaactual).innerHTML = parseFloat(producto[filaactual]["pvp"]).toFixed(2);
					//document.getElementById("emb"+filaactual).innerHTML = producto[filaactual]["caja"];
					habilitar(filaactual);
				  }});
			};
			document.getElementById('cant'+filaactual).onchange = function(){
				if($( "#cant"+filaactual ).val()=="") $( "#cant"+filaactual ).val(producto[filaactual]["caja"]);
				//document.getElementById("caj"+filaactual).innerHTML = (parseInt($( "#cant"+filaactual ).val())/parseInt(producto[filaactual]["caja"])).toFixed(2);
				cambiartotal(filaactual);
			  };
			  habilitarselects(filaactual);
			  window.filaactual++;
			}
			function eliminarfila(num){
			  $("#fila"+num).remove();
			  cambiarresultado();
			}
			function prueba(){
			  alert("prueba");
			}
			function enviarmail(){
			  var tablatexto = "";
			  var cliente = "<?php echo $row_Recordset1['cli_id'].' - '.$row_Recordset1['cli_nombre']; ?>";
			  var saltar = true;
			  $("#tablappal tbody tr").each(function() {
				if (saltar){
				  tablatexto += "<tr>"+$(this).html()+"</tr>";
				  saltar = false;
				}else{
				  var filanum = $(this).prop("id").replace('fila','');
				  tablatexto += "<tr><td style='text-align: center'>"+$("#fam"+filanum).find(":selected").text()+"</td>";
				  tablatexto += "<td style='text-align: center'>"+$("#marca"+filanum).find(":selected").text()+"</td>";
				  tablatexto += "<td style='text-align: center'>"+$("#prod"+filanum).find(":selected").text()+"</td>";
				  tablatexto += "<td style='text-align: center'>"+$("#cant"+filanum).val()+"</td>";
				  tablatexto += "<td style='text-align: center'>"+$("#pvp"+filanum).html()+"</td>";
				  tablatexto += "<td style='text-align: center'>"+$("#total"+filanum).html()+"</td></tr>";
				}
			  });
			var total = "<h2 align=\"center\"><b>Total:</b> <span>"+$("#totaltotal").html()+"</span> euros</h2><h2 align=\"center\">"+$("#resultado").html()+"</h2>";
			var data="";
			$.ajax({
			  type: "GET",
			  url: "filtro_promociones.php?o=f6&tabla="+tablatexto+"&cliente="+cliente+"&total="+total+"&regalodesc="+regalo["descripcion"],
			  data: data,
			  success: function(data, textStatus, jqXHR){
				if(data == "error"){
				  alert("Error enviando el correo.");
				}else{
				  console.log(data);
				  alert("Correo enviado con \u00e9xito.");
				 //window.location = $('#volver').attr('href');
			   }
			 }
			});
			}
 
			//FIN FUNCIONES
			obtenerfamilias();
			filaactual=1;
		</script>
		<div class="row">
			<div class="col-md-2 nopadding">
				<div class="sidebar-nav">
					<div class="navbar navbar-default" role="navigation">
						<div class="navbar-header">
							<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
								<span class="sr-only">Toggle navigation</span>
								<span class="icon-bar"></span>
								<span class="icon-bar"></span>
								<span class="icon-bar"></span>
							</button>
							<img src="../images/prueba.png" class="img-responsive" alt="Logo">
							<p class="nav navbar-nav">
								<a class="navbar-brand izqmargin" href="../menuadmin.php"><?php echo ucfirst($_SESSION['nom']) . ' ' . ucfirst($_SESSION['ape']); ?></a>
								<div class="opcionescuenta">
									<a href="../logout.php" role="button" class="btn btn-default btn-xs">Cerrar sesi&oacute;n</a>
								</div>
							</p>
						</div>
						<div id="navbar" class="navbar-collapse collapse sidebar-navbar-collapse">
							<ul class="nav navbar-nav">
								<li class="nav-divider"></li>
								<li><a href="../visitas/accionesadmin.php">Acciones</a></li>
								<li><a href="../visitas/clientesadmin.php">Clientes</a></li>
								<li><a href="../visitas/menucadmin.php">Comerciales</a></li>
								<li><a href="../especialista/menucadmin.php">Especialistas</a></li>
								<li><a href="../informes.php">Informes</a></li>
								<li><a href="../visitas/redesadmin.php">Redes</a></li>
								<li class="nav-divider"></li>
								<li><a href="http:\\www.prueba.com" target="_blank">prueba.com</a></li>
								<li><a href="http:\\www.pruebas.com" target="_blank">pruebas.com</a></li>
								<li><a href="https:\\web.whatsapp.com" target="_blank">WhatsApp WEB</a></li>
							</ul>
						</div>
					</div>
				</div>
			</div>
			<div class="col-md-10 nopadding">
				<div class="col-md-12 top-buffer">
					<div class="jumbotron col-md-11">
						<div class="text-center">
							<h2><b>Crear pedido/presupuesto</b></h2>
							<h3><?php echo $row_Recordset1['cli_id']; ?> - <?php echo utf8_encode($row_Recordset1['cli_nombre']); ?> <?php if($row_Recordset1['baja']=='B') echo '<font color="#e74c3c"><b>BAJA</b></font>'; ?></h3>
						</div>
						<br>
						<form name="form1" method="post" action="javascript:void(0);">
							<div align="center">
								<select name="regalo" id="regalo" class="form-control" size="1">
									<option><b>SELECCIONAR ACCIÓN</b></option>
									<?php
									do {
									?>
										<option value="<?php echo $row_Recordset3['id']?>"><?php echo $row_Recordset3['descripcion']?></option>
									<?php
									} while ($row_Recordset3 = mysqli_fetch_assoc($Recordset3));
									$rows = mysqli_num_rows($Recordset3);
									if($rows > 0) {
										mysqli_data_seek($Recordset3, 0);
										$row_Recordset3 = mysqli_fetch_assoc($Recordset3);
									}
									?>
								</select>
								<br>
								<input class="btn btn-default" type="button" id="anyadir" onclick="crearfila()" value="A&ntilde;adir linea de pedido" disabled>
							  </p>
							  <script type="text/javascript">
								document.getElementById('regalo').onchange = function(){
								  var tb = document.getElementById('contabla');
								  var seleccionado = document.getElementById('regalo');
								  var pt = document.getElementById('anyadir');
								  var data = "";
								  if(seleccionado.selectedIndex == "0") {
									  $("#anyadir").prop("disabled",true);
									  pt.disabled = true;
									  tb.style.display = "none";
								  }
								  else {
									  pt.disabled = false;
									  tb.style.display = "inline";
								  }
								  $.ajax({
									type: 'GET',
									url: 'filtro_promociones.php?o=f4&regalo='+$( "#regalo" ).val(),
									data: data,
									success: function(data, textStatus, jqXHR)
									{
									  regalo = jQuery.parseJSON(data);
									  $("#anyadir").prop("disabled",false);
									  cambiarresultado();
									}});
								};
							  </script>
								<br>
								<div name="contabla" id="contabla" style="display:none">
									<table class="table table-bordered" align="center" width="100%" style="text-align: center" id="tablappal" name="tablappal">
										<tr style="color:white">
											<th style="text-align:center; vertical-align:middle" bgcolor="#2c3e50" width="10%">FAMILIA</th>
											<th style="text-align:center; vertical-align:middle" bgcolor="#2c3e50" width="10%">MARCA</th>
											<th style="text-align:center; vertical-align:middle" bgcolor="#2c3e50" width="20%">PRODUCTO</th>
											<!--<th scope="col">REFERENCIA</th>-->
											<!--<th scope="col">EMBALAJE</th>-->
											<th style="text-align:center; vertical-align:middle" bgcolor="#2c3e50" width="10%">CANTIDAD</th>
											<!--<th scope="col">CAJAS</th>-->
											<th style="text-align:center; vertical-align:middle" bgcolor="#2c3e50" width="10%">PVP</th>
											<th style="text-align:center; vertical-align:middle" bgcolor="#2c3e50" width="10%">TOTAL</th>
											<th style="text-align:center; vertical-align:middle" width="5%"></th>
										</tr>
									</table>
									<h2><b>TOTAL</b> <span id="totaltotal"></span></h2>
									<h2 id="resultado"></h2>
									<input class="btn btn-default" type="button" id="mailbutton" onclick="enviarmail()" value="Recibir correo" disabled>
									<br><br>
								</div>
							</div>
						</form>
						<div align="center">
							<a href="fichaclienteadmin.php?id=<?php echo $_GET['id'];?>&rep=<?php echo $_GET['rep'];?>">
								<img class="text-center" src="../images/atras.png" class="img-responsive" width="100" alt="Atr&aacute;s">
							</a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
 
<?php
	mysqli_free_result($Recordset1);
	mysqli_free_result($Recordset2);
	mysqli_free_result($Recordset3);
?>


En el archivo anterior llama varias veces a este archivo que adjunto ahora:

filtro_promociones.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php require_once('../connections/comercial.php'); ?>
<?php
	if (!isset($_SESSION)) {
	  session_start();
	}
	$MM_authorizedUsers = "";
	$MM_donotCheckaccess = "true";
 
	// *** Restrict Access To Page: Grant or deny access to this page
	function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
	  // For security, start by assuming the visitor is NOT authorized.
	  $isValid = False;
 
	  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
	  // Therefore, we know that a user is NOT logged in if that Session variable is blank.
	  if (!empty($UserName)) {
		// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
		// Parse the strings into arrays.
		$arrUsers = Explode(",", $strUsers);
		$arrGroups = Explode(",", $strGroups);
		if (in_array($UserName, $arrUsers)) {
		  $isValid = true;
		}
		// Or, you may restrict access to only certain users based on their username.
		if (in_array($UserGroup, $arrGroups)) {
		  $isValid = true;
		}
		if (($strUsers == "") && true) {
		  $isValid = true;
		}
	  }
	  return $isValid;
	}
 
	$MM_restrictGoTo = "../logout.php";
	if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
	  $MM_qsChar = "?";
	  $MM_referrer = $_SERVER['PHP_SELF'];
	  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
	  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
		$MM_referrer .= "?" . $QUERY_STRING;
	  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
	  header("Location: ". $MM_restrictGoTo);
	  exit;
	}
 
	function utf8ize($d) {
	  if (is_array($d)) {
		foreach ($d as $k => $v) {
		  $d[$k] = utf8ize($v);
		}
	  } else if (is_string ($d)) {
		return utf8_encode($d);
	  }
	  return $d;
	}
 
	switch($_GET['o']){
		case "f1": //marcas
	  mysqli_select_db($comercial, $database_comercial);
	  $q = "SELECT DISTINCT marca FROM articulos WHERE familia='".$_GET['fam']."' ORDER BY marca DESC";
	  $res = mysqli_query($comercial, $q) or die(mysql_error());
	  $rows = array();
	  while($row = mysqli_fetch_array($res)) {
	   $rows[] = $row['marca'];
	 }
				//header('Content-Type: application/json');
	 echo json_encode(utf8ize($rows));
	 break;
	case "f2": //articulos
	mysqli_select_db($comercial, $database_comercial);
	$q = "SELECT id, descripcion FROM articulos WHERE familia='".$_GET['fam']."' AND marca='".$_GET['marca']."' ORDER BY descripcion DESC";
	$res = mysqli_query($comercial, $q) or die(mysql_error());
	$rows = array();
	while($row = mysqli_fetch_array($res)) {
	  $rows[] = array($row['id'],$row['descripcion']);
	}
		  //header('Content-Type: application/json');
	echo json_encode(utf8ize($rows));
	break;
	case "f3": //datos articulo
	mysqli_select_db($comercial, $database_comercial);
	$q = "SELECT * FROM articulos WHERE id='".$_GET['prod']."'";
	$res = mysqli_query($comercial, $q) or die(mysql_error());
	$row = mysqli_fetch_array($res);
	echo json_encode(utf8ize($row));
	break;
	case "f4": //regalos
	mysqli_select_db($comercial, $database_comercial);
	$q = "SELECT * FROM regalospromos WHERE id='".$_GET['regalo']."'";
	$res = mysqli_query($q, $comercial) or die(mysql_error());
	$row = mysqli_fetch_array($res);
	echo json_encode(utf8ize($row));
	break;
	case "f5": //familias
	mysqli_select_db($comercial, $database_comercial);
	$q = "SELECT DISTINCT familia FROM articulos ORDER BY familia";
	$res = mysqli_query($comercial, $q) or die(mysql_error());
	$rows = array();
	while($row = mysqli_fetch_array($res)) {
	  $rows[] = $row['familia'];
	}
		  //header('Content-Type: application/json');
	echo json_encode(utf8ize($rows));
	break;
	case "f6":
	mysqli_select_db($comercial, $database_comercial);
	$q = "SELECT * FROM representante WHERE representante.user='".$_SESSION['MM_Username']."'";
	$res = mysqli_query($comercial, $q) or die(mysql_error());
	$row = mysqli_fetch_array($res);
 
	$para = $row['email'];
	$para = "informatica@rsegorbe.com";
	$tabla = $_GET['tabla'];
	$cliente = $_GET['cliente'];
	$total = $_GET['total'];
	$regalodesc = $_GET['regalodesc'];
	$representante = $row['nombre']." ".$row['apellido'];
	if($para != "" && $tabla != ""){
 
		// título
	  $titulo = 'Promoción enviada desde portal CRM';
 
		// mensaje
	  $mensaje = '
	  <html lang="es">
	  <body align="center" style="text-align:center;">
		REgalo
	  </body>
	  </html>
	  ';
 
		// Para enviar un correo HTML, debe establecerse la cabecera Content-type
	  $cabeceras  = 'MIME-Version: 1.0' . "\r\n";
	  $cabeceras .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
		// Cabeceras adicionales
	  $cabeceras .= 'FROM: RS Informatica <informatica@rsegorbe.com>' . "\r\n";
	  $cabeceras .= 'CC: informatica@rsegorbe.com' . "\r\n";
	  $cabeceras .= "Content-Transfer-Encoding: base64\r\n\r\n";
	  $email_message = chunk_split(base64_encode($mensaje));
 
	  //ini_set('sendmail_path', '/usr/syno/etc/php.ini');
	  if(!mail($para, utf8_decode($titulo), $email_message, $cabeceras))
		  echo "error";
	  else
		  echo $mensaje;
	}
	break;
	}
?>

El enviar el correo no funcionaba correctamente, el css no se aplicaba al correo.

Asi es como se ve actualmente. Con anterioridad habia una columna de neto y descuento (que son las que he quitado)
Captura

¡Saludos y gracias de antemano!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Yoel
Val: 617
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

No consigo que envíe email

Publicado por Yoel (198 intervenciones) el 28/05/2021 17:05:53
Hola Gonzalo, para tu colocar el ccs en el cuerpo del correo tienes que tener la ruta completa ya que cuando mandas el correo los estilos ccs no se colocan sino que se hacen referencia, lo mismo sucede con el javascript. Te dejo un ejemplo para que veas como tiene que quedar.

Así lo tienes:

1
<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" />

Así te tiene que quedar.

1
<link href="https://www.midominio.com/bootstrap/css/bootstrap.min.css" rel="stylesheet" />

Gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar