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);
 }
 /**
  * Remove the specified receiptline from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     ReceiptLine::destroy($id);
     return Redirect::route('receipt_lines.index');
 }
 /**
  * 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);
 }