Trying to get property of non-object in C:
Publicado por jeinner (20 intervenciones) el 30/03/2017 14:35:21
Buen dia, Ing´s La WDP
Estoy tratando de editar un sistema para invetarios, pero al tratar de extraer los valores de una input, se me generan varios errores, he intentado de varias maneras pero no logro continuar con el trabajo.
este el archivo sell view
Y este el archivo onesell donde dice que estan los errores pero no he podido solucionarlo.
adjunto imagen con los errores, el numero de la linea donde se encuentra.
Agradezco todos los comentarios o ayuda que me puedan ofrecer con este problema. Muchas gracias

Estoy tratando de editar un sistema para invetarios, pero al tratar de extraer los valores de una input, se me generan varios errores, he intentado de varias maneras pero no logro continuar con el trabajo.
este el archivo sell view
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
<div class="row">
<div class="col-md-12">
<h1>Venta</h1>
<p><b>Buscar producto por nombre o por codigo:</b></p>
<form id="searchp">
<div class="row">
<div class="col-md-6">
<input type="hidden" name="view" value="sell">
<input type="text" id="product_code" name="product" class="form-control">
</div>
<div class="col-md-3">
<button type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-search"></i> Buscar</button>
</div>
</div>
</form>
</div>
<div id="show_search_results"></div>
<script>
//jQuery.noConflict();
$(document).ready(function(){
$("#searchp").on("submit",function(e){
e.preventDefault();
$.get("./?action=searchproduct",$("#searchp").serialize(),function(data){
$("#show_search_results").html(data);
});
$("#product_code").val("");
});
});
$(document).ready(function(){
$("#product_code").keydown(function(e){
if(e.which==17 || e.which==74){
e.preventDefault();
}else{
console.log(e.which);
}
})
});
</script>
<?php if(isset($_SESSION["errors"])):?>
<h2>Errores</h2>
<p></p>
<table class="table table-bordered table-hover">
<tr class="danger">
<th>Codigo</th>
<th>Producto</th>
<th>Mensaje</th>
</tr>
<?php foreach ($_SESSION["errors"] as $error):
$product = ProductData::getById($error["product_id"]);
?>
<tr class="danger">
<td><?php echo $product->id; ?></td>
<td><?php echo $product->name; ?></td>
<td><b><?php echo $error["message"]; ?></b></td>
</tr>
<?php endforeach; ?>
</table>
<?php
unset($_SESSION["errors"]);
endif; ?>
<!--- Carrito de compras :) -->
<?php if(isset($_SESSION["cart"])):
//$total = 0;
?>
<h2>Lista de venta</h2>
<table class="table table-bordered table-hover">
<thead>
<th style="width:30px;">Codigo</th>
<th style="width:30px;">Cantidad</th>
<th style="width:30px;">Unidad</th>
<th>Producto</th>
<th style="width:30px;">Precio Unitario</th>
<th style="width:30px;">Precio Total</th>
<th ></th>
</thead>
<?php foreach($_SESSION["cart"] as $p):
$product = ProductData::getById($p["product_id"]);
?>
<tr >
<td><?php echo $product->id; ?></td>
<td ><?php echo $p["q"]; ?></td>
<td><?php echo $product->unit; ?></td>
<td><?php echo $product->name; ?></td>
<td><b>$ <?php echo number_format($product->price_out); ?></b></td>
<td><b>$ <?php echo $product->price_out; ?></b></td>
<td style="width:30px;"><a href="index.php?view=clearcart&product_id=<?php echo $product->id; ?>" class="btn btn-danger"><i class="glyphicon glyphicon-remove"></i> Cancelar</a></td>
</tr>
<?php endforeach; ?>
</table>
<form method="post" class="form-horizontal" id="processsell" action="index.php?view=processsell">
<h2>Resumen</h2>
<div class="form-group">
<label for="inputEmail1" class="col-lg-2 control-label">Cliente</label>
<div class="col-lg-10">
<?php
$clients = PersonData::getClients();
?>
<select name="client_id" class="form-control">
<option value="">-- NINGUNO --</option>
<?php foreach($clients as $client):?>
<option value="<?php echo $client->id;?>"><?php echo $client->name." ".$client->lastname;?></option>
<?php endforeach;?>
</select>
</div>
</div>
<div class="form-group">
<label for="inputEmail1" class="col-lg-2 control-label">Descuento</label>
<div class="col-lg-10">
<input type="text" name="discount" class="form-control" id="discount" placeholder="Descuento">
</div>
</div>
<div class="form-group">
<label for="inputEmail1" class="col-lg-2 control-label">Efectivo</label>
<div class="col-lg-10">
<input type="text" name="money" required class="form-control" id="money" placeholder="Efectivo">
</div>
</div>
<input type="hidden" name="total" value="" class="form-control" placeholder="Total">
<div class="row">
<div class="col-md-6 col-md-offset-6">
<table class="table table-bordered">
<tr>
<td><p>Subtotal</p></td>
<td><p><b>$ <?php echo ("#discount"); ?></b></p></td>
</tr>
<tr>
<td><p>IVA</p></td>
<td><p><b>$ <?php echo ("#money"); ?></b></p></td>
</tr>
<tr>
<td><p>Total</p></td>
<td><p><b>$ <?php echo $product->price_out; ?></b></p></td>
</tr>
</table>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<div class="checkbox">
<label>
<input name="is_oficial" type="hidden" value="1">
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<div class="checkbox">
<label>
<a href="index.php?view=clearcart" class="btn btn-lg btn-danger"><i class="glyphicon glyphicon-remove"></i> Cancelar</a>
<button class="btn btn-lg btn-primary"><i class="glyphicon glyphicon-usd"></i><i class="glyphicon glyphicon-usd"></i> Finalizar Venta</button>
</label>
</div>
</div>
</div>
</form>
<script>
$("#processsell").submit(function(e){
discount = $("#discount").val();
money = $("#money").val();
if(money<(<?php echo $total;?>-discount)){
alert("No se puede efectuar la operacion");
e.preventDefault();
}else{
if(discount==""){ discount=0;}
go = confirm("Cambio: $"+(money-(<?php echo $total;?>-discount ) ) );
if(go){}
else{e.preventDefault();}
}
});
</script>
</div>
</div>
<br><br><br><br><br>
<?php endif; ?>
</div>
Y este el archivo onesell donde dice que estan los errores pero no he podido solucionarlo.
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
<div class="btn-group pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-download"></i> Descargar <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="report/onesell-word.php?id=<?php echo $_GET["id"];?>">Word 2007 (.docx)</a></li>
</ul>
</div>
<h1>Resumen de Venta</h1>
<?php if(isset($_GET["id"]) && $_GET["id"]!=""):?>
<?php
$sell = SellData::getById($_GET["id"]);
$operations = OperationData::getAllProductsBySellId($_GET["id"]);
//$total = 0;
?>
<?php
if(isset($_COOKIE["selled"])){
foreach ($operations as $operation) {
// print_r($operation);
$qx = OperationData::getQYesF($operation->product_id);
// print "qx=$qx";
$p = $operation->getProduct();
if($qx==0){
echo "<p class='alert alert-danger'>El producto <b style='text-transform:uppercase;'> $p->name</b> no tiene existencias en inventario.</p>";
}else if($qx<=$p->inventary_min/2){
echo "<p class='alert alert-danger'>El producto <b style='text-transform:uppercase;'> $p->name</b> tiene muy pocas existencias en inventario.</p>";
}else if($qx<=$p->inventary_min){
echo "<p class='alert alert-warning'>El producto <b style='text-transform:uppercase;'> $p->name</b> tiene pocas existencias en inventario.</p>";
}
}
setcookie("selled","",time()-18600);
}
?>
<table class="table table-bordered">
<?php if($sell->person_id!=""):
$client = $sell->getPerson();
?>
<tr>
<td style="width:150px;">Cliente</td>
<td><?php echo $client->name." ".$client->lastname;?></td>
</tr>
<?php endif; ?>
<?php if($sell->user_id!=""):
$user = $sell->getUser();
?>
<tr>
<td>Atendido por</td>
<td><?php echo $user->name." ".$user->lastname;?></td>
</tr>
<?php endif; ?>
</table>
<br><table class="table table-bordered table-hover">
<thead>
<th>Codigo</th>
<th>Cantidad</th>
<th>Nombre del Producto</th>
<th>Precio Unitario</th>
<th>Total</th>
</thead>
<?php
foreach($operations as $operation){
$product = $operation->getProduct();
?>
<tr>
<td><?php echo $product->id ;?></td>
<td><?php echo $operation->q ;?></td>
<td><?php echo $product->name ;?></td>
<td>$ <?php echo $product->price_out ;?></td>
<td><b>$ <?php echo $product->price_out;?></b></td>
</tr>
<?php
}
?>
</table>
<br><br>
<div class="row">
<div class="col-md-4">
<table class="table table-bordered">
<tr>
<td><h4>Descuento:</h4></td>
<td><h4>$ <?php echo $sell->discount; ?></h4></td>
</tr>
<tr>
<td><h4>Subtotal:</h4></td>
<td><h4>$ <?php echo $sell->discount; ?></h4></td>
</tr>
<tr>
<td><h4>Total:</h4></td>
<td><h4>$ <?php echo $sell->discount; ?></h4></td>
</tr>
</table>
</div>
</div>
<?php else:?>
501 Internal Error
<?php endif; ?>
adjunto imagen con los errores, el numero de la linea donde se encuentra.
Agradezco todos los comentarios o ayuda que me puedan ofrecer con este problema. Muchas gracias

Valora esta pregunta


0