public static function logToReceiptRecords($f)
 {
     $file_db = new PDO('sqlite:' . $f);
     $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $result = $file_db->query('SELECT * FROM transactions;');
     $receiptNO = "";
     foreach ($result as $m) {
         $receiptNo = $m["receiptNo"];
     }
     $receiptlines = ReceiptLine::where('receiptNo', $receiptNo)->get();
     foreach ($receiptlines as $receiptline) {
         ReceiptLine::destroy($receiptline->id);
     }
     $receiptRecords = Receiptrecord::where(['receiptNo' => $receiptNo, 'progress' => '提供済み'])->get();
     foreach ($receiptRecords as $receiptRecord) {
         $receiptRecord->payment_id = $m['payment_id'];
         $receiptRecord->progress = "支払い済み";
         $receiptRecord->save();
     }
     $file_db = new PDO('sqlite:' . $f);
     $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $result = $file_db->query('SELECT * FROM payments;');
     foreach ($result as $m) {
         $payment = new Payment();
         $payment->price = $m["price"];
         $payment->payment = $m["payment"];
         $payment->changes = $m["changes"];
         $payment->time = $m["time"];
         $payment->uuid = $m["uuid"];
         $payment->shopName = $m["shopName"];
         $payment->employeeName = $m["employeeName"];
         $payment->save();
     }
     //        unlink($f);
 }
 public static function showtransfer($f)
 {
     $file_db = new PDO('sqlite:' . $f);
     $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $result = $file_db->query('SELECT * FROM transfer;');
     /*
     1. Clear all old data of receiptlines before sending to clien
     2. Datafromio when deleted, set it to receipt line
     */
     foreach ($result as $m) {
         $r = new Receiptrecord();
         $r->tantoID = $m["tantoID"];
         $r->goodsTitle = $m["goodsTitle"];
         $r->kosu = $m["kosu"];
         $r->orderTime = $m["time"];
         $r->receiptNo = $m["receiptNo"];
         $r->tableNO = $m["tableNO"];
         $r->progress = "受注済み";
         $r->price = 0;
         $r->serveTime = "";
         $r->paymentTime = "";
         $r->payment_id = 0;
         $r->save();
     }
     $file_db = new PDO('sqlite:' . $f);
     $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $result = $file_db->query('SELECT * FROM transfer;');
     foreach ($result as $m) {
         $d = new Datafromio();
         $d->tanto = $m["tantoID"];
         $d->goodsTitle = $m["goodsTitle"];
         $d->kosu = $m["kosu"];
         $d->time = $m["time"];
         $d->receiptNo = $m["receiptNo"];
         $d->tableNO = $m["tableNO"];
         $d->save();
     }
     unlink($f);
 }
 /**
  * Remove the specified datafromio from storage.
  *
  * @param  int  $id
  * @return Response
  * @todo Separate operation for Datafromio and ReceiptLine
  */
 public function destroy($id)
 {
     if (Input::has('ReadyForPayment')) {
         $id = Input::get('id');
         $m = Datafromio::find($id);
         $i = Item::where('title', $m->goodsTitle)->first();
         /* save to Cashier.sqlite */
         $r = new ReceiptLine();
         $r->tantoID = $m->tanto;
         $r->goodsTitle = $m->goodsTitle;
         $r->kosu = $m->kosu;
         $r->time = $m->time;
         $r->receiptNo = $m->receiptNo;
         $r->tableNO = $m->tableNO;
         $r->price = $i->price;
         $r->save();
         /* log to ReceiptMaster.sqlite */
         $receipt_record = Receiptrecord::where(['receiptNo' => $m->receiptNo, 'goodsTitle' => $m->goodsTitle])->first();
         $receipt_record->serveTime = date("Y年m月d日 h:i:sa");
         $receipt_record->price = $i->price;
         $receipt_record->progress = "提供済み";
         $receipt_record->save();
         /* remove from ordered items */
         Datafromio::destroy($id);
         $message = "未清算注文へ転送しました。";
         return Redirect::route('dataFromIOs.index')->with('message', $message);
     }
     $id = Input::get('id');
     Datafromio::destroy($id);
     ReceiptLine::destroy($id);
     $message = "削除しました。";
     return Redirect::route('dataFromIOs.index')->with('message', $message);
 }
 /**
  * Remove the specified receiptrecord from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Receiptrecord::destroy($id);
     return Redirect::route('receiptrecords.index');
 }