Exemple #1
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/>";
     }
 }
Exemple #2
0
 /**
  * Add a new UUID to bind to the device
  * @param $deviceId
  * @param $uuid
  *
  * @return bool true if uuid insert successful
  */
 private function addNewUuid($deviceId, $uuid)
 {
     $devMdl = new DevicesModel();
     if ($devMdl->addUuid($deviceId, $uuid) !== false) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * Broadcast the transaction to admin dash & devices included via config
  * @param $curdeviceid
  * @param bool $updatedsaleflag
  * @param bool $delete
  * @return bool
  */
 private function broadcastSale($curdeviceid, $updatedsaleflag = false, $delete = false)
 {
     $socket = new WposSocketIO();
     $wposConfig = new WposAdminSettings();
     $config = $wposConfig->getSettingsObject("pos");
     $devices = [];
     switch ($config->saledevice) {
         case "device":
             return true;
             // no need to do anything, the device will already get the updated record
         // no need to do anything, the device will already get the updated record
         case "all":
             // get all device id's
             $devMdl = new DevicesModel();
             $devices = $devMdl->getDeviceIds();
             break;
         case "location":
             // get location device id array
             $devMdl = new DevicesModel();
             $devices = $devMdl->getLocationDeviceIds($curdeviceid);
             break;
     }
     // put devices into object, node.js array functions suck
     $dobject = new stdClass();
     foreach ($devices as $value) {
         if ($curdeviceid != $value) {
             // remove the current device from broadcast
             $dobject->{$value} = $value;
         }
     }
     if ($updatedsaleflag == true) {
         $this->jsonobj->isupdate = 1;
     }
     $socket->sendSaleUpdate($dobject, $delete ? $this->jsonobj->ref : $this->jsonobj);
     return true;
 }
 /**
  * If stime & etime are not set, This function returns sales using the provided devices ID, using POS configuration values.
  *
  * @param $result
  * @return mixed
  */
 public function getSales($result)
 {
     if (!isset($this->data->stime) || !isset($this->data->etime)) {
         // time not set, retrieving POS records, get config.
         $WposConfig = new WposAdminSettings();
         $config = $WposConfig->getSettingsObject("pos");
         // set the sale range based on the config setting
         $etime = time() * 1000;
         $stime = strtotime("-1 " . (isset($config->salerange) ? $config->salerange : "week")) * 1000;
         // determine which devices transactions to include based on config
         if (isset($this->data->deviceid)) {
             switch ($config->saledevice) {
                 case "device":
                     break;
                     // no need to do anything, id already set
                 // no need to do anything, id already set
                 case "all":
                     unset($this->data->deviceid);
                     // unset the device id to get all sales
                     break;
                 case "location":
                     // get location device id array
                     $devMdl = new DevicesModel();
                     $this->data->deviceid = $devMdl->getLocationDeviceIds($this->data->deviceid);
             }
         }
     } else {
         $stime = $this->data->stime;
         $etime = $this->data->etime;
     }
     // Get all transactions within the specified timeframe/devices
     $salesMdl = new SalesModel();
     $dbSales = $salesMdl->getRangeWithRefunds($stime, $etime, isset($this->data->deviceid) ? $this->data->deviceid : null);
     if (is_array($dbSales)) {
         $sales = [];
         foreach ($dbSales as $sale) {
             $sales[$sale['ref']] = json_decode($sale['data'], true);
         }
         $result['data'] = $sales;
     } else {
         if ($dbSales === false) {
             $result['error'] = $salesMdl->errorInfo;
         }
     }
     return $result;
 }