diff --git a/IES-Bandung/app/Http/Controllers/ObjectSellController.php b/IES-Bandung/app/Http/Controllers/ObjectSellController.php index 628fab6f72348bd14f4f876eaa58b14ddecfda0e..8cef94a21ef9f773e2d363c628b5fd0ce7e6d7a8 100644 --- a/IES-Bandung/app/Http/Controllers/ObjectSellController.php +++ b/IES-Bandung/app/Http/Controllers/ObjectSellController.php @@ -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); diff --git a/IES-Bandung/database/migrations/2016_04_04_022615_object_sell.php b/IES-Bandung/database/migrations/2016_04_04_022615_object_sell.php index df08559cec03df9451b90930022361e35a468631..862f71071d88b4b496cfb4d2b05b5aa9e91e6317 100644 --- a/IES-Bandung/database/migrations/2016_04_04_022615_object_sell.php +++ b/IES-Bandung/database/migrations/2016_04_04_022615_object_sell.php @@ -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'); diff --git a/IES-Bandung/database/migrations/2016_04_05_150010_object_sell_log.php b/IES-Bandung/database/migrations/2016_04_05_150010_object_sell_log.php index f7417f4053eff8e824382fd5ae1dcf2e66573b3a..0845f68f2e1f26f29676afaecf0716ed201157fe 100644 --- a/IES-Bandung/database/migrations/2016_04_05_150010_object_sell_log.php +++ b/IES-Bandung/database/migrations/2016_04_05_150010_object_sell_log.php @@ -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(); diff --git a/IES-Bandung/database/migrations/2016_04_06_054018_user_log_after_update_trigger.php b/IES-Bandung/database/migrations/2016_04_06_054018_user_log_after_update_trigger.php index a85617b9916956fe88b95e77ebd1e0b8678cc00c..1798000a59e61ff755c17092784abd98f214d5a9 100644 --- a/IES-Bandung/database/migrations/2016_04_06_054018_user_log_after_update_trigger.php +++ b/IES-Bandung/database/migrations/2016_04_06_054018_user_log_after_update_trigger.php @@ -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, diff --git a/IES-Bandung/database/migrations/2016_04_06_062533_object_sell_log_after_insert_trigger.php b/IES-Bandung/database/migrations/2016_04_06_062533_object_sell_log_after_insert_trigger.php index 2714004ea49e6e7381b27ce2a37ea62eaf54c38a..d9e50d6db6077897e93b2d9c70dcc2ed6c0e39ae 100644 --- a/IES-Bandung/database/migrations/2016_04_06_062533_object_sell_log_after_insert_trigger.php +++ b/IES-Bandung/database/migrations/2016_04_06_062533_object_sell_log_after_insert_trigger.php @@ -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 diff --git a/IES-Bandung/database/migrations/2016_04_06_063143_object_sell_log_after_update_trigger.php b/IES-Bandung/database/migrations/2016_04_06_063143_object_sell_log_after_update_trigger.php index 47d1209f41dcb1fb21a302a52893ee18dd2b9997..f687ae3c0941725f0986478ac93ce7ea0d7d805b 100644 --- a/IES-Bandung/database/migrations/2016_04_06_063143_object_sell_log_after_update_trigger.php +++ b/IES-Bandung/database/migrations/2016_04_06_063143_object_sell_log_after_update_trigger.php @@ -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 diff --git a/IES-Bandung/public/js/simple.js b/IES-Bandung/public/js/simple.js index 6dc6645f3c9bd4e0d0df31e1e06dd1114f05f932..5bc94cc4904162ff5c3dfd97115c23a7404a6152 100644 --- a/IES-Bandung/public/js/simple.js +++ b/IES-Bandung/public/js/simple.js @@ -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 diff --git a/IES-Bandung/resources/views/vendorUser.blade.php b/IES-Bandung/resources/views/vendorUser.blade.php index 461c3d38d7a0a5d99e40a09f2d1869f2fac7e6f3..30fd43d7d5ae16507aa30c5944cae0b83c542051 100755 --- a/IES-Bandung/resources/views/vendorUser.blade.php +++ b/IES-Bandung/resources/views/vendorUser.blade.php @@ -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>