예제 #1
0
파일: Sale.php 프로젝트: ThunderID/SHOP-API
 /**
  * generate unique number
  * 
  * @param model of sale
  * @return unique_number
  */
 public function generateUniqueNumber($sale)
 {
     if (!is_null($sale['unique_number'])) {
         $i = 0;
         $amount = true;
         while ($amount) {
             $prev_number = Sale::orderBy('id', 'DESC')->status('wait')->first();
             $limit = StoreSetting::type('limit_unique_number')->ondate('now')->first();
             if ($prev_number['unique_number'] < $limit['value']) {
                 $unique_number = $i + $prev_number['unique_number'] + 1;
             } else {
                 $unique_number = $i + 1;
             }
             $amount = Sale::amount($sale->amount - $unique_number)->status('wait')->notid($sale->id)->first();
             $i = $i + 1;
         }
         return $unique_number;
     } else {
         return $sale['unique_number'];
     }
 }
예제 #2
0
 public function index()
 {
     $now = new \DateTime('now');
     $month = $now->format('m');
     $c = Purchase::get();
     $c1 = Physicalsale::get();
     $var = array($month);
     $spname = "salesreport";
     $c2 = Info::callinfo($var, $spname);
     $var1 = array($month - 1);
     $spname1 = "salesreportp";
     $c3 = Info::callinfo($var1, $spname1);
     $spname2 = "todaysales";
     $c4 = Combo::callcombo($spname2);
     $spname3 = "todaycash";
     $c5 = Combo::callcombo($spname3);
     $spname4 = "todaybankcollection";
     $c6 = Combo::callcombo($spname4);
     $spname5 = "todaycashcollection";
     $c7 = Combo::callcombo($spname5);
     $spname6 = "todaycontracollection";
     $c8 = Combo::callcombo($spname6);
     $spbkash = "todaybkashcollection";
     $bkash = Combo::callcombo($spbkash);
     $spsap = "todaysapcollection";
     $sap = Combo::callcombo($spsap);
     $spkcs = "todaykcscollection";
     $kcs = Combo::callcombo($spkcs);
     $spmbank = "todaymbankcollection";
     $mbank = Combo::callcombo($spmbank);
     // print_r($c4);
     $sales_info = Sale::orderBy('created_at', 'desc')->take(5)->get();
     $purchase_info = Purchase::orderBy('created_at', 'desc')->take(5)->get();
     $bankaccount_info = Bankaccount::orderBy('created_at', 'desc')->take(5)->get();
     return view('home', compact('c', 'c1', 'c2', 'c3', 'sales_info', 'purchase_info', 'bankaccount_info', 'c4', 'c5', 'c6', 'c7', 'c8', 'bkash', 'sap', 'kcs', 'mbank'));
 }