示例#1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     cart::create(['c_id' => 1, 'b_id' => 1]);
     cart::create(['c_id' => 1, 'b_id' => 3]);
     cart::create(['c_id' => 1, 'b_id' => 5]);
     cart::create(['c_id' => 1, 'b_id' => 7]);
     cart::create(['c_id' => 2, 'b_id' => 2]);
     cart::create(['c_id' => 2, 'b_id' => 4]);
     cart::create(['c_id' => 2, 'b_id' => 6]);
     cart::create(['c_id' => 2, 'b_id' => 8]);
 }
示例#2
0
 public function buy_books()
 {
     // session_start();
     if (!isset($_SESSION['user_id'])) {
         $msg = "You are not Login , Please Login First...";
         return view('login')->with('message', $msg);
     }
     $price = 0;
     $cid = cart::max('c_id') + 1;
     foreach ($_SESSION['cart'] as $item) {
         cart::create(['b_id' => $item["id"], 'c_id' => $cid]);
         $b = Book::where('b_id', $item["id"])->first();
         $price = $price + $b->price;
     }
     trans::create(['u_id' => $_SESSION['user_id'], 'c_id' => $cid, 'amount' => $price]);
     $_SESSION['cart'] = array();
     $msg = "Thank you for buying, Book are added to your transaction...";
     return redirect()->action('UserController@show_trans');
 }
示例#3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     session_start();
     $loguser = $_SESSION['user_id'];
     $data = Request::except('tax');
     $data['customer_id'] = $_SESSION['contact_report_to'];
     $data['call_log_id'] = 0;
     $data['owner_id'] = $loguser;
     $data['total'] = $_POST['sub_total'];
     $sale = App\sale::create($data);
     $last_id1 = $sale->id;
     //$sql3="INSERT INTO `sales`(`id`,`call_log_id`, `customer_id`, `category_id`,`product_id`, `qty`, `owner_id`, `created_time`, `modified_by`, `modified_time`, `assignedto`, `tax`, `discount`, `total`, `status`,  `account_id`, `date`, `remark`,`group`) VALUES
     //(NULL,'0','$_SESSION[contact_report_to]',NULL,NULL,NULL,'$loguser',SYSDATE(),NULL,NULL,'$_POST[assigned_to]',NULL,NULL,'$_POST[sub_total]','$_POST[status]',NULL,'$_POST[date]','$_POST[remark1]','$_POST[group_id]')";
     //$log = new crm_log;
     //$log->add_log("sales",$last_id1,"insert"); // add a log
     $cart_details = App\cart::where('user', $loguser)->get();
     foreach ($cart_details as $row4) {
         // select data from cart table
         $data = ['category' => $row4->category, 'product' => $row4->product, 'price' => $row4->price, 'sale_id' => $last_id1, 'qty' => $row4->qty, 'tax' => $row4->tax, 'discount' => $row4->discount];
         $last_sp_id = DB::table('sales_product')->insertGetId($data);
         //$sql5="INSERT INTO `sales_product`(`id`, `category`, `product`,`price`,`sale_id`, `qty`, `tax`, `discount`) VALUES(NULL,'$row4[category]','$row4[product]','$row4[price]','$last_id1','$row4[qty]','$row4[tax]','$row4[discount]')";
         $cart_tax_details = App\cart_tax::where('cart_id', $row4->id)->get();
         foreach ($cart_tax_details as $row6) {
             $sql_s = "INSERT INTO `s_p_tax`(`s_p_id`, `tax_id`, `tax_name`, `tax_value`, `user`) VALUES ('{$last_sp_id}','{$row6->tax_id}','{$row6->tax_name}','{$row6->tax_value}','{$loguser}')";
             DB::insert(DB::raw($sql_s));
             // add data to sales product tax table
         }
     }
     App\cart::where('user', $loguser)->delete();
     App\cart_tax::where('user', $loguser)->delete();
     return redirect('sale');
 }
示例#4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     session_start();
     $loguser = $_SESSION['user_id'];
     $input = Request::except('tax');
     //        var_dump($input);
     //
     //        die();
     if (isset($_GET['cid'])) {
         $input['contact_id'] = $_GET['cid'];
         $input['customer_id'] = $_GET['cid'];
     } else {
         $input['contact_no'] = $input['cli'];
         $input['contact_owner'] = $loguser;
         $input['contact_id'] = App\contact::create($input)->id;
         $input['customer_id'] = $input['contact_id'];
     }
     $input['call_owner'] = $loguser;
     $input['assignedto'] = $input['assignedto1'];
     $input['group_id'] = $input['group_id1'];
     $last_id = App\call_log::create($input)->id;
     $input['call_log_id'] = $last_id;
     if ($input['call_type'] == "Inquiry") {
         if ($input['status'] == "complete") {
             $endtime = date('Y-m-d H:i:s');
         } else {
             $endtime = NULL;
         }
         $input['inquiry_end_time'] = $endtime;
         App\inquiry::create($input);
     } elseif ($input['call_type'] == "Sales") {
         $input['owner_id'] = $loguser;
         $input['total'] = $_POST['sub_total'];
         $sale = App\sale::create($input);
         $last_id1 = $sale->id;
         //$log = new crm_log;
         //$log->add_log("sales",$last_id1,"insert"); // add a log
         $cart_details = App\cart::where('user', $loguser)->get();
         foreach ($cart_details as $row4) {
             // select data from cart table
             $input = ['category' => $row4->category, 'product' => $row4->product, 'price' => $row4->price, 'sale_id' => $last_id1, 'qty' => $row4->qty, 'tax' => $row4->tax, 'discount' => $row4->discount];
             $last_sp_id = DB::table('sales_product')->insertGetId($input);
             //$sql5="INSERT INTO `sales_product`(`id`, `category`, `product`,`price`,`sale_id`, `qty`, `tax`, `discount`) VALUES(NULL,'$row4[category]','$row4[product]','$row4[price]','$last_id1','$row4[qty]','$row4[tax]','$row4[discount]')";
             $cart_tax_details = App\cart_tax::where('cart_id', $row4->id)->get();
             foreach ($cart_tax_details as $row6) {
                 $sql_s = "INSERT INTO `s_p_tax`(`s_p_id`, `tax_id`, `tax_name`, `tax_value`, `user`) VALUES ('{$last_sp_id}','{$row6->tax_id}','{$row6->tax_name}','{$row6->tax_value}','{$loguser}')";
                 DB::insert(DB::raw($sql_s));
                 // add data to sales product tax table
             }
         }
         $cart = new cart();
         $cart->delete_user_cart();
         // remove cart data
     } elseif ($input['call_type'] == "Tickets") {
         $input['owner'] = $loguser;
         $ticket_id = App\ticket::create($input)->id;
         $input['last_id_ticket'] = $ticket_id;
         App\ticket_problem::create($input);
     }
 }