forked from joaquinobed/simple-invoice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperfil.php
210 lines (175 loc) · 7.11 KB
/
perfil.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
<?php
/*-------------------------
Autor: Obed Alvarado
Web: obedalvarado.pw
Mail: info@obedalvarado.pw
---------------------------*/
session_start();
if (!isset($_SESSION['user_login_status']) AND $_SESSION['user_login_status'] != 1) {
header("location: login.php");
exit;
}
/* Connect To Database*/
require_once ("config/db.php");//Contiene las variables de configuracion para conectar a la base de datos
require_once ("config/conexion.php");//Contiene funcion que conecta a la base de datos
$active_facturas="";
$active_productos="";
$active_clientes="";
$active_usuarios="";
$active_perfil="active";
$title="Configuración | Simple Invoice";
$query_empresa=mysqli_query($con,"select * from perfil where id_perfil=1");
$row=mysqli_fetch_array($query_empresa);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include("head.php");?>
</head>
<body>
<?php
include("navbar.php");
?>
<div class="container">
<div class="row">
<form method="post" id="perfil">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 toppad" >
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title"><i class='glyphicon glyphicon-cog'></i> Configuración</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-3 col-lg-3 " align="center">
<div id="load_img">
<img class="img-responsive" src="<?php echo $row['logo_url'];?>" alt="Logo">
</div>
<br>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input class='filestyle' data-buttonText="Logo" type="file" name="imagefile" id="imagefile" onchange="upload_image();">
</div>
</div>
</div>
</div>
<div class=" col-md-9 col-lg-9 ">
<table class="table table-condensed">
<tbody>
<tr>
<td class='col-md-3'>Nombre de la empresa:</td>
<td><input type="text" class="form-control input-sm" name="nombre_empresa" value="<?php echo $row['nombre_empresa']?>" required></td>
</tr>
<tr>
<td>Teléfono:</td>
<td><input type="text" class="form-control input-sm" name="telefono" value="<?php echo $row['telefono']?>" required></td>
</tr>
<tr>
<td>Correo electrónico:</td>
<td><input type="email" class="form-control input-sm" name="email" value="<?php echo $row['email']?>" ></td>
</tr>
<tr>
<td>IVA (%):</td>
<td><input type="text" class="form-control input-sm" required name="impuesto" value="<?php echo $row['impuesto']?>"></td>
</tr>
<tr>
<td>Simbolo de moneda:</td>
<td>
<select class='form-control input-sm' name="moneda" required>
<?php
$sql="select name, symbol from currencies group by symbol order by name ";
$query=mysqli_query($con,$sql);
while($rw=mysqli_fetch_array($query)){
$simbolo=$rw['symbol'];
$moneda=$rw['name'];
if ($row['moneda']==$simbolo){
$selected="selected";
} else {
$selected="";
}
?>
<option value="<?php echo $simbolo;?>" <?php echo $selected;?>><?php echo ($simbolo);?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Dirección:</td>
<td><input type="text" class="form-control input-sm" name="direccion" value="<?php echo $row["direccion"];?>" required></td>
</tr>
<tr>
<td>Ciudad:</td>
<td><input type="text" class="form-control input-sm" name="ciudad" value="<?php echo $row["ciudad"];?>" required></td>
</tr>
<tr>
<td>Región/Provincia:</td>
<td><input type="text" class="form-control input-sm" name="estado" value="<?php echo $row["estado"];?>"></td>
</tr>
<tr>
<td>Código postal:</td>
<td><input type="text" class="form-control input-sm" name="codigo_postal" value="<?php echo $row["codigo_postal"];?>"></td>
</tr>
</tbody>
</table>
</div>
<div class='col-md-12' id="resultados_ajax"></div><!-- Carga los datos ajax -->
</div>
</div>
<div class="panel-footer text-center">
<button type="submit" class="btn btn-sm btn-success"><i class="glyphicon glyphicon-refresh"></i> Actualizar datos</button>
</div>
</div>
</div>
</form>
</div>
<?php
include("footer.php");
?>
</body>
</html>
<script type="text/javascript" src="js/bootstrap-filestyle.js"> </script>
<script>
$( "#perfil" ).submit(function( event ) {
$('.guardar_datos').attr("disabled", true);
var parametros = $(this).serialize();
$.ajax({
type: "POST",
url: "ajax/editar_perfil.php",
data: parametros,
beforeSend: function(objeto){
$("#resultados_ajax").html("Mensaje: Cargando...");
},
success: function(datos){
$("#resultados_ajax").html(datos);
$('.guardar_datos').attr("disabled", false);
}
});
event.preventDefault();
})
</script>
<script>
function upload_image(){
var inputFileImage = document.getElementById("imagefile");
var file = inputFileImage.files[0];
if( (typeof file === "object") && (file !== null) )
{
$("#load_img").text('Cargando...');
var data = new FormData();
data.append('imagefile',file);
$.ajax({
url: "ajax/imagen_ajax.php", // Url to which the request is send
type: "POST", // Type of request to be send, called as method
data: data, // Data sent to server, a set of key/value pairs (i.e. form fields and values)
contentType: false, // The content type used when sending data to the server.
cache: false, // To unable request pages to be cached
processData:false, // To send DOMDocument or non processed data file it is set to false
success: function(data) // A function to be called if request succeeds
{
$("#load_img").html(data);
}
});
}
}
</script>