示例#1
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'));
 }
示例#2
0
 public function save_unapproved(Request $request)
 {
     if ($request->ajax()) {
         $sales_id = $request->input('sales_id');
         $voucher = Voucher::find($sales_id);
         if (!empty($voucher)) {
             if ($voucher->sid == NULL && $voucher->cid != NULL) {
                 $customer = Customer::find($voucher->cid);
                 $sales = Physicalsale::where('status', 1)->where('customerid', $voucher->cid)->where('presentbalance', '<>', 0)->orderBy('id', 'desc')->get();
                 foreach ($sales as $s) {
                     $s->presentbalance = $s->presentbalance + $voucher->amount;
                     $s->previousdue = $s->previousdue + $voucher->amount;
                     $s->save();
                 }
                 $salesasc = Physicalsale::where('status', 1)->where('customerid', $voucher->cid)->orderBy('id', 'asc')->get();
                 foreach ($salesasc as $sasc) {
                     $presentbalance = $sasc->presentbalance;
                 }
                 $customer->lastdue = $presentbalance;
                 $customer->save();
             }
             $voucher->vstatus = 0;
             $voucher->save();
         } else {
             return response()->json(0);
         }
         return response()->json(1);
     }
 }
 public function cancel_status(Request $request)
 {
     if ($request->ajax()) {
         $sales_id = $request->input('sales_id');
         $sales = Physicalsale::find($sales_id);
         if (!empty($sales)) {
             $s = DB::table('sales')->where('id', $sales_id)->first();
             DB::table('customers')->where('id', $s->customerid)->update(['lastdue' => $s->previousdue]);
             $sales->delete();
             DB::table('salesdetails')->where('salesid', $sales_id)->delete();
         } else {
             return response()->json(0);
         }
         return response()->json(1);
     }
 }