public function postRefund()
 {
     $postdata = Input::all();
     $panIDPK = Input::get('pan_id_pk');
     $currenttime = Commonmodel::dateandtime();
     if (!$panIDPK) {
         return Response::json(array('status' => "failed", 'message' => 'Please send a PAN ID'));
     } else {
         $findrefuncid = Panoffiline::find($panIDPK);
         if ($findrefuncid) {
             $getcurrentuser = Panoffiline::where('pan_id_pk', '=', $panIDPK)->pluck('pan_created_by');
             $response = Panoffiline::where('pan_id_pk', $panIDPK)->get();
             if ($response) {
                 foreach ($response as $res) {
                     $userfinID = $res->pan_created_by;
                     $panCoupenNo = $res->pan_coupon_no;
                     $mainBalance = Userfinance::where('ufin_user_id', $userfinID)->pluck('ufin_main_balance');
                     $panTotBal = $mainBalance + 106;
                     $balanceDebit = array('ufin_main_balance' => $panTotBal);
                     if ($panCoupenNo != '0') {
                         Userfinance::where('ufin_user_id', '=', $userfinID)->update($balanceDebit);
                         $coupenReset = array('pan_coupon_no' => '');
                         Panoffiline::where('pan_id_pk', '=', $panIDPK)->update($coupenReset);
                         $panCoupenUpdate = array('pc_coupon_no' => $panCoupenNo);
                         $procode = Products::where('prod_short_name', '=', 'PANM')->pluck('prod_code');
                         $panledger = array('lr_date' => $currenttime, 'lr_trans_type' => 'CR', 'lr_comment' => 'Pan Refund', 'lr_credit_amount' => '106', 'lr_post_balance' => $panTotBal, 'lr_created_by' => $getcurrentuser, 'lr_prod_code' => $procode);
                         $panlegcreta = new Ledgerreport();
                         $panlegcreta->create($panledger);
                         $coupen = new Coupons();
                         $coupen->create($panCoupenUpdate);
                         return Response::json(array('status' => "success", 'message' => 'Amount debited successfully'));
                     } else {
                         return Response::json(array('status' => "failure", 'message' => 'PAN Card has been already applied for refund'));
                     }
                 }
             }
         } else {
             return Response::json(array('status' => "failure", 'message' => 'No User found for this ID'));
         }
     }
 }
示例#2
0
 public function postAddCoupon()
 {
     $getData = Input::all();
     $saveData = array();
     foreach ($getData as $value) {
         if (empty($value)) {
             $saveData[] = 1;
             return Redirect::to('admin/add-coupon')->with('error', 'Please complete all the fields')->withInput();
         }
     }
     $file = $getData['coupon_image'];
     if (count($saveData) == 0) {
         $all_uploaded_files = array('jpg', 'png', 'jpeg');
         $destinationPath = public_path() . '/uploads/images/coupon';
         //$filename = str_random(12);
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $final_img = $filename;
         list($width, $height, $type, $attr) = getimagesize($file);
         if (in_array($extension, $all_uploaded_files) && $width >= 300 && $height >= 150) {
             $upload_success = $file->move($destinationPath, $final_img);
             $img = Image::make($destinationPath . '/' . $final_img);
             $img->resize(300, 150);
             $img->save($destinationPath . '/' . $final_img);
             $saveData = array('coupon_name' => $getData['coupon_name'], 'coupon_code' => $getData['coupon_code'], 'category_id' => $getData['category_id'], 'store_id' => $getData['store_id'], 'coupon_image' => $final_img, 'short_description' => $getData['short_description'], 'description' => $getData['description'], 'url' => $getData['url'], 'tags' => $getData['tags']);
             if (Coupons::create($saveData)) {
                 return Redirect::to('admin/add-coupon')->with('success', 'Successfuly added new Coupon to store');
             }
         } else {
             return Redirect::to('admin/add-coupon')->with('error', 'Upload only JPG,JPEG,PNG type images of 300X150 dimensions.')->withInput();
         }
     }
 }