Skip to content
Snippets Groups Projects
Commit c4f23dc3 authored by Wiwit Rifa'i's avatar Wiwit Rifa'i
Browse files

add unit to objectsell

parent 5c846092
Branches
No related merge requests found
Pipeline #2666 skipped
......@@ -33,6 +33,7 @@ class ObjectSellController extends Controller
$item->name = $request->name;
$item->object_type_id = $objectType->id;
$item->price = $request->price;
$item->unit = $request->unit;
$item->save();
return redirect('/profile');
......@@ -54,6 +55,13 @@ class ObjectSellController extends Controller
$item->save();
}
}
if (array_key_exists('unit', $req)) {
foreach ($req['unit'] as $key => $value) {
$item = ObjectSell::find($key);
$item->unit = $value;
$item->save();
}
}
if (array_key_exists('type', $req)) {
foreach ($req['type'] as $key => $value) {
$objectType = ObjectType::getOrCreate($value);
......
......@@ -18,6 +18,7 @@ class ObjectSell extends Migration
$table->string('name');
$table->integer('object_type_id')->unsigned();
$table->integer('price')->unsigned();
$table->string('unit');
$table->string('ip_addr');
$table->foreign('vendor_user_id')->references('id')->on('vendor_users');
$table->foreign('object_type_id')->references('id')->on('object_types');
......
......@@ -20,6 +20,8 @@ class ObjectSellLog extends Migration
$table->integer('object_type_id')->unsigned();
$table->integer('old_price')->unsigned()->nullable();
$table->integer('new_price')->unsigned()->nullable();
$table->string('old_unit')->nullable();
$table->string('new_unit')->nullable();
$table->string('action');
$table->string('ip_addr');
$table->timestamps();
......
......@@ -18,7 +18,7 @@ class UserLogAfterUpdateTrigger extends Migration
AFTER UPDATE ON `users`
FOR EACH ROW
BEGIN
INSERT INTO `UserLog`
INSERT INTO `user_logs`
SET action = \'update.a\',
user_id = NEW.id,
username = NEW.username,
......
......@@ -26,6 +26,8 @@ class ObjectSellLogAfterInsertTrigger extends Migration
object_type_id = NEW.object_type_id,
old_price = NULL,
new_price = NEW.price,
old_unit = NULL,
new_unit = NEW.unit,
ip_addr = NEW.ip_addr,
updated_at = NEW.updated_at;
END
......
......@@ -26,6 +26,8 @@ class ObjectSellLogAfterUpdateTrigger extends Migration
object_type_id = NEW.object_type_id,
old_price = OLD.price,
new_price = NEW.price,
old_unit = OLD.unit,
new_unit = NEW.unit,
ip_addr = NEW.ip_addr,
updated_at = NEW.updated_at;
END
......
......@@ -33,7 +33,7 @@ $("#editDagangBtn").on("click", function(){
$(document).ready(function() {
$.getJSON("http://localhost:8888/api/object_type", function(data){
$.getJSON("/api/object_type", function(data){
var availableTags = data
$( ".suggest" ).autocomplete({
source: availableTags
......
......@@ -176,6 +176,7 @@
<tr>
<th>Nama Barang</th>
<th>Harga</th>
<th>Satuan</th>
<th data-breakpoints="xs sm">Jenis</th>
<th data-breakpoints="xs">Update</th>
<th>Terjual</th>
......@@ -192,6 +193,10 @@
<input type="text" value="{{ $object->price }}" class="fedit-barang toggle-display" name="price[{{ $object->id }}]"></input>
<p class="tedit-barang toggle-display displayit">{{ $object->price }}</p>
</td>
<td>
<input type="text" value="{{ $object->unit }}" class="fedit-barang toggle-display" name="unit[{{ $object->id }}]"></input>
<p class="tedit-barang toggle-display displayit">{{ $object->unit }}</p>
</td>
<td>
<input type="text" value="{{ $object->type }}" class="suggest fedit-barang toggle-display" name="type[{{ $object->id }}]"></input>
<p class="tedit-barang toggle-display displayit">{{ $object->type }}</p>
......@@ -232,7 +237,11 @@
</div>
<div class="form-group">
<label>Harga</label>
<input type="text" name="price" class="form-control form-currency" placeholder="Harga Barang" required>
<input type="text" name="price" class="form-control form-currency" placeholder="Harga Barang Per Satuan" required>
</div>
<div class="form-group">
<label>Satuan</label>
<input type="text" name="unit" class="form-control form-currency" placeholder="Satuan Barang" required>
</div>
<button type="submit" class="btn btn-sm btn-success">Tambahkan</button>
</form>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment