/**
  * Tests the update function in the SupplierController
  * @depends testStore
  * @param void
  * @return void
  */
 public function testUpdate()
 {
     $this->be(User::first());
     $this->runStore($this->input);
     $supplierSaved = Supplier::orderBy('id', 'desc')->take(1)->get()->toArray();
     // Update the supplier
     $this->runUpdate($this->inputUpdate, $supplierSaved[0]['id']);
     $supplierUpdated = Supplier::orderBy('id', 'desc')->take(1)->get()->toArray();
     $this->assertEquals($supplierUpdated[0]['name'], $this->inputUpdate['name']);
     $this->assertEquals($supplierUpdated[0]['phone_no'], $this->inputUpdate['phone_no']);
     $this->assertEquals($supplierUpdated[0]['email'], $this->inputUpdate['email']);
     $this->assertEquals($supplierUpdated[0]['physical_address'], $this->inputUpdate['physical_address']);
 }
Esempio n. 2
0
 public static function generateId()
 {
     $supplier = Supplier::orderBy('supplierID', 'DESC')->get()->first();
     $supplierId = $supplier->supplierID;
     $supplierId = substr($supplierId, 4);
     $newId = (int) $supplierId;
     $newId++;
     $newIdString = (string) $newId;
     $newIdString = "000000" . $newIdString;
     if (strlen($newIdString) > 3) {
         $newIdString = substr($newIdString, strlen($newIdString) - 3);
     }
     $newIdString = "SU" . $newIdString;
     return $newIdString;
 }
 public function get($id = null)
 {
     $search = Input::get('search');
     if (!is_null($search)) {
         $supplierOrders = SupplierOrder::select('supplier_orders.*')->join('suppliers', 'suppliers.id', '=', 'supplier_orders.suppliers_id')->where('suppliers.name', 'like', '%' . $search . '%')->orWhere('code', 'like', '%' . $search . '%')->orderBy('supplier_orders.created_at', 'DESC')->paginate(15);
     } else {
         $supplierOrders = SupplierOrder::where('status', 'generated')->orderBy('created_at', 'DESC')->paginate(15);
     }
     $selectedSupplierOrder = self::__checkExistence($id);
     if (!$selectedSupplierOrder) {
         $selectedSupplierOrder = new SupplierOrder();
     }
     $products = $selectedSupplierOrder->products->toArray();
     $suppliers = Supplier::orderBy('name')->get()->lists('name', 'id');
     return View::make('supplierOrders.main')->with('id', $id)->with('selectedSupplierOrder', $selectedSupplierOrder)->with('products', $products)->with('suppliers', $suppliers)->with('search', $search)->with('supplierOrders', $supplierOrders);
 }
Esempio n. 4
0
function suppliersList()
{
    $supplier_list = array('' => Lang::get('general.select_supplier')) + Supplier::orderBy('name', 'asc')->orderBy('name', 'asc')->lists('name', 'id');
    return $supplier_list;
}
Esempio n. 5
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $suppliers = Supplier::orderBy('name', 'ASC')->get();
     return View::make('inventory.supplier.index')->with('suppliers', $suppliers);
 }