Example #1
0
 /**
  * Delete supplier
  * @param $result
  * @return mixed
  */
 public function deleteSupplier($result)
 {
     // validate input
     if (!is_numeric($this->data->id)) {
         $result['error'] = "A valid id must be supplied";
         return $result;
     }
     $supMdl = new SuppliersModel();
     $qresult = $supMdl->remove($this->data->id);
     if ($qresult === false) {
         $result['error'] = "Could not delete the supplier";
     } else {
         $result['data'] = true;
         // log data
         Logger::write("Supplier deleted with id:" . $this->data->id, "SUPPLIER");
     }
     return $result;
 }
Example #2
0
 private function insertDemoRecords()
 {
     $suppliers = json_decode('[{"id": 1, "name":"Joe\'s Fruit&Veg Supplies", "dt":"0000-00-00 00:00:00"},
                     {"id": 2, "name":"Elecsys Electronic Distibution", "dt":"0000-00-00 00:00:00"},
                     {"id": 3, "name":"Fitwear Clothing Wholesale", "dt":"0000-00-00 00:00:00"},
                     {"id": 4, "name":"Yumbox Packaged Goods", "dt":"0000-00-00 00:00:00"},
                     {"id": 5, "name":"No Place Like Home-warehouse", "dt":"0000-00-00 00:00:00"}]');
     if ($suppliers == false) {
         die("Failed to add suppliers");
     } else {
         $supMdl = new SuppliersModel();
         foreach ($suppliers as $supplier) {
             $supMdl->create($supplier->name);
         }
         echo "Inserted Suppliers.<br/>";
     }
     $items = json_decode('[{"id": 1,"supplierid": 1,"code": "A","qty": 1,"name": "Apple","description": "Golden Delicious","taxid": "2","price": "0.99", "type":"general", "modifiers":[]},
                 {"id": 2,"supplierid": 1,"code": "B","qty": 1,"name": "Bannana","description": "Lady Finger","taxid": "2","price": "3.00", "type":"general", "modifiers":[]},
                 {"id": 3,"supplierid": 1,"code": "C","qty": 1,"name": "Coconut","description": "","taxid": "2","price": "3.00", "type":"general", "modifiers":[]},
                 {"id": 4,"supplierid": 4,"code": "D","qty": 1,"name": "Doritos","description": "","taxid": "2","price": "2.50", "type":"general", "modifiers":[]},
                 {"id": 5, "supplierid": 4,"code": "E","qty": 1,"name": "Energy Drink","description": "","taxid": "2","price": "3.45", "type":"general", "modifiers":[]},
                 {"id": 6, "supplierid": 4,"code": "F","qty": 1,"name": "Chocolate Fudge","description": "","taxid": "2","price": "1.55", "type":"general", "modifiers":[]},
                 {"id": 7, "supplierid": 5,"code": "G","qty": 1,"name": "Gardening Gloves","description": "","taxid": "2","price": "8.55", "type":"general", "modifiers":[]},
                 {"id": 8,"supplierid": 5,"code": "H","qty": 1,"name": "Homewares","description": "","taxid": "1","price": "", "type":"general", "modifiers":[]},
                 {"id": 9,"supplierid": 4,"code": "I","qty": 1,"name": "Ice Cream","description": "","taxid": "1","price": "4.65", "type":"general", "modifiers":[]},
                 {"id": 10,"supplierid": 5,"code": "J","qty": 1,"name": "Jug","description": "","taxid": "1","price": "11.00", "type":"general", "modifiers":[]},
                 {"id": 11,"supplierid": 5,"code": "K","qty": 1,"name": "Kettle","description": "","taxid": "1","price": "15.00", "type":"general", "modifiers":[]},
                 {"id": 12,"supplierid": 1,"code": "L","qty": 1,"name": "Lime","description": "","taxid": "1","price": "2.00", "type":"general", "modifiers":[]},
                 {"id": 13,"supplierid": 3,"code": "M","qty": 1,"name": "Men\'s Clothing","description": "","taxid": "1","price": "", "type":"general", "modifiers":[]},
                 {"id": 14,"supplierid": 4,"code": "N","qty": 1,"name": "Nut mix","description": "","taxid": "1","price": "4.60", "type":"general", "modifiers":[]},
                 {"id": 15,"supplierid": 1,"code": "O","qty": 1,"name": "Orange","description": "","taxid": "1","price": "1.50", "type":"general", "modifiers":[]},
                 {"id": 16,"supplierid": 1,"code": "P","qty": 1,"name": "Pineapple","description": "","taxid": "1","price": "4.00", "type":"general", "modifiers":[]},
                 {"id": 17,"supplierid": 1,"code": "Q","qty": 1,"name": "Quince","description": "","taxid": "1","price": "1.70", "type":"general", "modifiers":[]},
                 {"id": 18,"supplierid": 4,"code": "R","qty": 1,"name": "Raviolli","description": "","taxid": "1","price": "7.35", "type":"general", "modifiers":[]},
                 {"id": 19,"supplierid": 4,"code": "S","qty": 1,"name": "Shapes Pizza","description": "","taxid": "1","price": "3.00", "type":"general", "modifiers":[]},
                 {"id": 20,"supplierid": 5,"code": "T","qty": 1,"name": "Toys","description": "","taxid": "1","price": "", "type":"general", "modifiers":[]},
                 {"id": 21,"supplierid": 5,"code": "U","qty": 1,"name": "Ukelele","description": "","taxid": "1","price": "16.90", "type":"general", "modifiers":[]},
                 {"id": 22,"supplierid": 3,"code": "V","qty": 1,"name": "Vest","description": "","taxid": "1","price": "47.00", "type":"general", "modifiers":[]},
                 {"id": 23,"supplierid": 3,"code": "W","qty": 1,"name": "Women\'s Clothing","description": "","taxid": "1","price": "", "type":"general", "modifiers":[]},
                 {"id": 24,"supplierid": 5,"code": "X","qty": 1,"name": "Xylophone","description": "","taxid": "1","price": "200.50", "type":"general", "modifiers":[]},
                 {"id": 25,"supplierid": 4,"code": "Y","qty": 1,"name": "Yeast","description": "","taxid": "1","price": "5.80", "type":"general", "modifiers":[]},
                 {"id": 26,"supplierid": 1,"code": "Z","qty": 1,"name": "Zuccini","description": "","taxid": "1","price": "1.10", "type":"general", "modifiers":[]},
                 {"id": 27,"supplierid": 4,"code": "BEER","qty": 1,"name": "Tasman Bitter","description": "375ml bottle","taxid": "1","price": "2.20", "type":"general", "modifiers":[]},
                 {"id": 28,"supplierid": 2,"code": "ROBO3D","qty": 1,"name": "Robo 3d Printer","description": "","taxid": "2","price": "599.00", "type":"general", "modifiers":[]},
                 {"id": 29,"supplierid": 2,"code": "PS4","qty": 1,"name": "Sony Playstation 4","description": "","taxid": "2","price": "600.00", "type":"general", "modifiers":[]},
                 {"id": 30,"supplierid": 2,"code": "XBOX","qty": 1,"name": "Xbox","description": "","taxid": "2","price": "600.00", "type":"general", "modifiers":[]}]');
     if ($items == false) {
         die("Failed to add items");
     } else {
         $itemMdl = new StoredItemsModel();
         foreach ($items as $item) {
             $itemMdl->create($item);
         }
         echo "Inserted Items.<br/>";
     }
     $locations = json_decode('[{"id": 1, "name":"Sydney", "dt":"0000-00-00 00:00:00"},
                     {"id": 2, "name":"Melbourne", "dt":"0000-00-00 00:00:00"},
                     {"id": 3, "name":"Adelaide", "dt":"0000-00-00 00:00:00"},
                     {"id": 4, "name":"Perth", "dt":"0000-00-00 00:00:00"}]');
     if ($locations == false) {
         die("Failed to add locations");
     } else {
         $locMdl = new LocationsModel();
         foreach ($locations as $location) {
             $locMdl->create($location->name);
         }
         echo "Inserted Locations.<br/>";
     }
     $devices = json_decode('[{"id": 1, "name":"Register 1", "locationid":1, "type":"general_register", "dt":"0000-00-00 00:00:00"},
                     {"id": 2, "name":"Register 2", "locationid":1, "type":"general_register", "dt":"0000-00-00 00:00:00"},
                     {"id": 3, "name":"Register 1", "locationid":2, "type":"general_register", "dt":"0000-00-00 00:00:00"},
                     {"id": 4, "name":"Register 2", "locationid":2, "type":"general_register", "dt":"0000-00-00 00:00:00"},
                     {"id": 5, "name":"Register 1", "locationid":3, "type":"general_register", "dt":"0000-00-00 00:00:00"},
                     {"id": 6, "name":"Register 1", "locationid":4, "type":"general_register", "dt":"0000-00-00 00:00:00"}]');
     if ($devices == false) {
         die("Failed to add devices");
     } else {
         $devMdl = new DevicesModel();
         foreach ($devices as $device) {
             $devMdl->create($device);
         }
         echo "Inserted Devices.<br/>";
     }
     $customers = json_decode('[{"id":1,"name":"Jo Doe", "email":"*****@*****.**", "address":"10 Fake St", "phone":"99999999", "mobile":"111111111", "suburb":"Faketown", "state":"NSW", "postcode":"2000", "country":"Australia", "notes":"", "dt":"0000-00-00 00:00:00"},
                     {"id": 2, "name":"Jane Doe", "email":"*****@*****.**", "address":"10 Fake St", "phone":"99999999", "mobile":"111111111", "suburb":"Faketown", "state":"NSW", "postcode":"2000", "country":"Australia", "notes":"", "dt":"0000-00-00 00:00:00"}]');
     if ($customers == false) {
         die("Failed to add customers");
     } else {
         $devMdl = new CustomerModel();
         foreach ($customers as $cust) {
             $devMdl->create($cust->email, $cust->name, $cust->phone, $cust->mobile, $cust->address, $cust->suburb, $cust->postcode, $cust->state, $cust->country);
         }
         echo "Inserted Customers.<br/>";
     }
 }
Example #3
0
 /**
  * @param $result
  * @return mixed Returns an array of suppliers
  */
 public function getSuppliers($result)
 {
     $suppliersMdl = new SuppliersModel();
     $suppliers = $suppliersMdl->get();
     if (is_array($suppliers)) {
         $supplierdata = [];
         foreach ($suppliers as $supplier) {
             $supplierdata[$supplier['id']] = $supplier;
         }
         $result['data'] = $supplierdata;
     } else {
         $result['error'] = $suppliersMdl->errorInfo;
     }
     return $result;
 }