Ejemplo n.º 1
0
 private function generateInvoiceId()
 {
     $invdesc = Sale::orderBy('id', 'DESC')->first();
     if ($invdesc != null) {
         $invDescId = $invdesc->invoice_id;
         $invDescIdNo = substr($invDescId, 6);
         $subinv1 = substr($invDescId, 6);
         $dd = substr($invDescId, 0, 2);
         $mm = substr($invDescId, -8, -6);
         $yy = substr($invDescId, -6, -4);
         $tz = 'Asia/Dhaka';
         $timestamp = time();
         $dt = new \DateTime("now", new \DateTimeZone($tz));
         //first argument "must" be a string
         $dt->setTimestamp($timestamp);
         //adjust the object to correct timestamp
         $Today = $dt->format('d.m.Y');
         $explodToday = explode(".", $Today);
         $dd2 = $explodToday[1];
         $mm2 = $explodToday[0];
         $yy1 = $explodToday[2];
         $yy2 = substr($invDescId, 2);
         if ($dd == $dd2 && $yy == $yy2 && $mm == $mm2) {
             $invoiceidd = $dd2 . $mm2 . $yy2 . $invDescIdNo + 1;
         } else {
             $invoiceidd = $dd2 . $mm2 . $yy2 . "0001";
         }
     } else {
         $tz = 'Asia/Dhaka';
         $timestamp = time();
         $dt = new \DateTime("now", new \DateTimeZone($tz));
         //first argument "must" be a string
         $dt->setTimestamp($timestamp);
         //adjust the object to correct timestamp
         $Today = $dt->format('d.m.Y');
         $explodToday = explode(".", $Today);
         $dd2 = $explodToday[1];
         $mm2 = $explodToday[0];
         $yy1 = $explodToday[2];
         $yy2 = substr($yy1, 2);
         $invoiceidd = $dd2 . $mm2 . $yy2 . "0001";
     }
 }
Ejemplo n.º 2
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $sales = Sale::orderBy('id', 'desc')->first();
     $customers = Customer::lists('name', 'id');
     return view('sale.index')->with('sale', $sales)->with('customer', $customers);
 }