Skip to content

Commit

Permalink
Bug Fixes and enhancements
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Ashutosh pathak authored Apr 21, 2019
2 parents bd74295 + 4fe7d64 commit 1c09bf9
Show file tree
Hide file tree
Showing 51 changed files with 797 additions and 320 deletions.
2 changes: 1 addition & 1 deletion app/ApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class ApiKey extends Model
{
protected $table = 'api_keys';
protected $fillable = ['rzp_key', 'rzp_secret', 'apilayer_key', 'bugsnag_api_key',
'zoho_api_key', 'msg91_auth_key', 'twitter_consumer_key',
'zoho_api_key', 'msg91_auth_key', 'msg91_sender', 'twitter_consumer_key',
'twitter_consumer_secret', 'twitter_access_token', 'access_tooken_secret', 'license_api_secret', 'license_api_url', 'nocaptcha_sitekey', 'captcha_secretCheck', 'update_api_url', 'update_api_secret', 'terms_url', 'pipedrive_api_key', ];
}
27 changes: 22 additions & 5 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,30 @@ public function retryOTP(Request $request)
$code = $request->input('code');
$mobile = $request->input('mobile');
$otp = $request->input('otp');
$number = $code.$mobile;
$result = $this->sendOtp($mobile, $code);
$number = '(+'.$code.') '.$mobile;
$result = $this->sendForReOtp($mobile, $code, $request->input('type'));
// dd($result);
switch ($request->input('type')) {
case 'text':
$array = json_decode($result, true);
$response = ['type' => 'success',
'message' => 'OTP has been resent to '.$number.'.Please Enter the OTP to login!!', ];

break;

case 'voice':
$array = json_decode($result, true);
$response = ['type' => 'success',
'message' => 'Voice call has been sent to '.$number.'.Please Enter the OTP received on the call to login!!', ];
break;

default:
$array = json_decode($result, true);
$response = ['type' => 'success',
'message' => 'Voice call has been sent to '.$number.'.Please Enter the OTP received on the call to login!!', ];
break;

$array = json_decode($result, true);
$response = ['type' => 'success',
'message' => 'OTP has been resent to '.$number.'.Please Enter the OTP to login!!', ];
}

return response()->json($response);
} catch (\Exception $ex) {
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/Auth/BaseAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public static function sendOtp($mobile, $code)
{
$client = new \GuzzleHttp\Client();
$number = $code.$mobile;
$key = ApiKey::where('id', 1)->value('msg91_auth_key');
$key = ApiKey::where('id', 1)->select('msg91_auth_key', 'msg91_sender')->first();
$response = $client->request('GET', 'https://control.msg91.com/api/sendotp.php', [
'query' => ['authkey' => $key, 'mobile' => $number],
'query' => ['authkey' => $key->msg91_auth_key, 'mobile' => $number, 'sender'=>$key->msg91_sender],
]);
$send = $response->getBody()->getContents();
$array = json_decode($send, true);
Expand All @@ -68,13 +68,13 @@ public static function sendOtp($mobile, $code)
/**
* ReSends Otp.
*/
public function sendForReOtp($mobile, $code)
public function sendForReOtp($mobile, $code, $type)
{
$client = new \GuzzleHttp\Client();
$number = $code.$mobile;
$key = ApiKey::where('id', 1)->value('msg91_auth_key');
$response = $client->request('GET', 'https://control.msg91.com/api/retryotp.php', [
'query' => ['authkey' => $key, 'mobile' => $number],
'query' => ['authkey' => $key, 'mobile' => $number, 'retrytype'=>$type],
]);
$send = $response->getBody()->getContents();
$array = json_decode($send, true);
Expand Down Expand Up @@ -107,7 +107,7 @@ public function requestOtpFromAjax(Request $request)
$userid = $request->input('id');
$email = $request->input('email');
$pass = $request->input('password');
$number = $code.$mobile;
$number = '(+'.$code.') '.$mobile;
$mobileStatus = StatusSetting::pluck('msg91_status')->first();
$companyEmail = Setting::find(1)->company_email;
$msg1 = '';
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/AutoUpdate/AutoUpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ private function postCurl($post_url, $post_info)
/*
* Add New Product
*/
public function addNewProduct($product_name, $product_sku)
public function addNewProductToAUS($product_name, $product_sku)
{
$url = $this->url;
$key = str_random(16);
$api_key_secret = $this->api_key_secret;
$addProduct = $this->postCurl($url, "api_key_secret=$api_key_secret&api_function=products_add&product_title=$product_name&product_sku=$product_sku&product_key='123456'&product_status=1");
$addProduct = $this->postCurl($url, "api_key_secret=$api_key_secret&api_function=products_add&product_title=$product_name&product_sku=$product_sku&product_key=$key&product_status=1");
}

/*
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BaseHomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function checkUpdatesExpiry(Request $request)
$orderId = Order::where('number', 'LIKE', $order_number)->pluck('id')->first();
if ($orderId) {
$expiryDate = Subscription::where('order_id', $orderId)->pluck('update_ends_at')->first();
if (\Carbon\Carbon::now()->toDateTimeString() < $expiryDate->toDateTimeString()) {
if (\Carbon\Carbon::now()->toDateTimeString() < $expiryDate) {
return ['status' => 'success', 'message' => 'allow-auto-update'];
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Common/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function getKeys(ApiKey $apikeys)
$secretKey = $apikeys->pluck('captcha_secretCheck')->first();
$updateSecret = $apikeys->pluck('update_api_secret')->first();
$mobileauthkey = $apikeys->pluck('msg91_auth_key')->first();
$msg91Sender = $apikeys->pluck('msg91_sender')->first();
$updateUrl = $apikeys->pluck('update_api_url')->first();
$emailStatus = StatusSetting::pluck('emailverification_status')->first();
$twitterKeys = $apikeys->select('twitter_consumer_key','twitter_consumer_secret',
Expand All @@ -83,7 +84,7 @@ public function getKeys(ApiKey $apikeys)
$pipedriveStatus = StatusSetting::pluck('pipedrive_status')->first();
$model = $apikeys->find(1);

return view('themes.default1.common.apikey', compact('model', 'status', 'licenseSecret', 'licenseUrl', 'siteKey', 'secretKey', 'captchaStatus', 'updateStatus', 'updateSecret', 'updateUrl', 'mobileStatus', 'mobileauthkey', 'emailStatus', 'twitterStatus', 'twitterKeys', 'zohoStatus', 'zohoKey', 'rzpStatus', 'rzpKeys', 'mailchimpSetting', 'mailchimpKey', 'termsStatus', 'termsUrl', 'pipedriveKey', 'pipedriveStatus'));
return view('themes.default1.common.apikey', compact('model', 'status', 'licenseSecret', 'licenseUrl', 'siteKey', 'secretKey', 'captchaStatus', 'updateStatus', 'updateSecret', 'updateUrl', 'mobileStatus', 'mobileauthkey', 'msg91Sender', 'emailStatus', 'twitterStatus', 'twitterKeys', 'zohoStatus', 'zohoKey', 'rzpStatus', 'rzpKeys', 'mailchimpSetting', 'mailchimpKey', 'termsStatus', 'termsUrl', 'pipedriveKey', 'pipedriveStatus'));
} catch (\Exception $ex) {
return redirect('/')->with('fails', $ex->getMessage());
}
Expand Down
13 changes: 12 additions & 1 deletion app/Http/Controllers/License/LicenseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ public function searchProductId($product_sku)
}
}

public function deleteProductFromAPL($product)
{
$url = $this->url;
$api_key_secret = $this->api_key_secret;
$productId = $this->searchProductId($product->product_sku);
$productTitle = $product->name;
$productSku = $product->sku;
$delProduct = $this->postCurl($url, "api_key_secret=$api_key_secret&api_function=products_edit
&product_id=$productId&product_title=$productTitle&product_sku=$productSku&product_status=1&delete_record=1");
}

/*
* Edit User
*/
Expand Down Expand Up @@ -143,7 +154,7 @@ public function createNewLicene($orderid, $product, $user_id,
$orderNo = $order->number;
$domain = $order->domain;
$productId = $this->searchProductId($sku);
$addLicense = $this->postCurl($url, "api_key_secret=$api_key_secret&api_function=licenses_add&product_id=$productId&license_code=$serial_key&license_require_domain=1&license_status=1&license_order_number=$orderNo&license_domain=$domain&license_limit=2&license_expire_date=$licenseExpiry&license_updates_date=$updatesExpiry&license_support_date=$supportExpiry&license_disable_ip_verification=0");
$addLicense = $this->postCurl($url, "api_key_secret=$api_key_secret&api_function=licenses_add&product_id=$productId&license_code=$serial_key&license_require_domain=1&license_status=1&license_order_number=$orderNo&license_domain=$domain&license_limit=6&license_expire_date=$licenseExpiry&license_updates_date=$updatesExpiry&license_support_date=$supportExpiry&license_disable_ip_verification=0");
}

/*
Expand Down
7 changes: 5 additions & 2 deletions app/Http/Controllers/Order/ExtendedBaseInvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,19 @@ public function edit($invoiceid, Request $request)
{
$totalSum = '0';
$invoice = Invoice::where('id', $invoiceid)->first();
$date = date('m/d/Y', strtotime($invoice->date));
$payment = Payment::where('invoice_id', $invoiceid)->pluck('amount')->toArray();
if ($payment) {
$totalSum = array_sum($payment);
}

return view('themes.default1.invoice.editInvoice', compact('userid', 'invoiceid', 'invoice', 'totalSum'));
return view('themes.default1.invoice.editInvoice', compact('userid', 'date', 'invoiceid', 'invoice', 'totalSum'));
}

public function postEdit($invoiceid, Request $request)
{
$this->validate($request, [
'date' => 'required',
'total' => 'required',
'status'=> 'required',
]);
Expand All @@ -87,7 +89,8 @@ public function postEdit($invoiceid, Request $request)
$total = $request->input('total');
$status = $request->input('status');
$paid = $request->input('paid');
$invoice = Invoice::where('id', $invoiceid)->update(['grand_total'=>$total, 'status'=>$status]);
$invoice = Invoice::where('id', $invoiceid)->update(['grand_total'=> $total, 'status'=>$status,
'date' => \Carbon\Carbon::parse($request->input('date')), ]);
$order = Order::where('invoice_id', $invoiceid)->update(['price_override'=>$total]);

return redirect()->back()->with('success', \Lang::get('message.updated-successfully'));
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Order/InvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ public function createInvoiceItems($invoiceid, $cart, $codevalue = '')
public function invoiceGenerateByForm(Request $request, $user_id = '')
{
$this->validate($request, [

'date' => 'required',
'domain' => 'sometimes|nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
'plan' => 'required_if:subscription,true',
'price' => 'required',
], [
Expand Down Expand Up @@ -392,7 +393,7 @@ public function invoiceGenerateByForm(Request $request, $user_id = '')
$userCurrency = $controller->currency($user_id);
$currency = $userCurrency['currency'];
$number = rand(11111111, 99999999);
$date = \Carbon\Carbon::now();
$date = \Carbon\Carbon::parse($request->input('date'));
$product = Product::find($productid);
$cost = $controller->cost($productid, $user_id, $plan);
$grand_total = $this->getGrandTotal($code, $total, $cost, $productid, $currency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ public function getProductField(int $productid)
$product = Product::find($productid);
if ($product->require_domain == 1) {
$field .= "<div class='col-md-4 form-group'>
<label class='required'>"./* @scrutinizer ignore-type */
<label>"./* @scrutinizer ignore-type */
\Lang::get('message.domain')."</label>
<input type='text' name='domain' class='form-control'
id='domain' placeholder='http://example.com'>
id='domain' placeholder='domain.com or sub.domain.com'>
</div>";
}

Expand Down
13 changes: 9 additions & 4 deletions app/Http/Controllers/Product/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,17 @@ public function store(Request $request)
// $currency = $input['currency'];

return redirect()->back()
->withErrors($v);
->withErrors($v)
->withInput($request->input());
}

try {
$licenseStatus = StatusSetting::pluck('license_status')->first();
if ($licenseStatus == 1) { //If License Setting Status is on,Add Product to the License Manager
$addProductToLicensing = $this->licensing->addNewProduct($input['name'], $input['product_sku']);
}
$licenseCont = new \App\Http\Controllers\AutoUpdate\AutoUpdateController();
$addProductToLicensing = $licenseCont->addNewProduct($input['name'], $input['product_sku']);
$updateCont = new \App\Http\Controllers\AutoUpdate\AutoUpdateController();
$addProductToLicensing = $updateCont->addNewProductToAUS($input['name'], $input['product_sku']);
if ($request->hasFile('image')) {
$image = $request->file('image')->getClientOriginalName();
$imagedestinationPath = 'common/images';
Expand Down Expand Up @@ -316,7 +317,7 @@ public function store(Request $request)
app('log')->error($e->getMessage());
Bugsnag::notifyException($e);

return redirect()->with('fails', $e->getMessage());
return redirect()->back()->with('fails', $e->getMessage());
}
}

Expand Down Expand Up @@ -470,6 +471,10 @@ public function destroy(Request $request)
foreach ($ids as $id) {
$product = $this->product->where('id', $id)->first();
if ($product) {
$licenseStatus = StatusSetting::pluck('license_status')->first();
if ($licenseStatus == 1) {
$this->licensing->deleteProductFromAPL($product);
}
$product->delete();
} else {
echo "<div class='alert alert-danger alert-dismissable'>
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/User/AdminOrderInvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function getClientInvoice($id)
})
->addColumn('date', function ($model) use ($client) {
$date1 = new \DateTime($model->date);
// $tz = \Auth::user()->timezone()->first()->name;
// $date1->setTimezone(new \DateTimeZone($tz));
$tz = \Auth::user()->timezone()->first()->name;
$date1->setTimezone(new \DateTimeZone($tz));
$date = $date1->format('M j, Y, g:i a ');

return $date;
Expand Down
15 changes: 7 additions & 8 deletions app/Http/Requests/User/ClientRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public function rules()
switch ($this->method()) {
case 'POST':
return [
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email|unique:users',
'mobile' => 'required|numeric',
'bussiness' => 'required',

'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email|unique:users',
'mobile' => 'required',
'bussiness' => 'required',
'timezone_id' => 'required',
'address' => 'required',
'zip' => 'required',
'user_name' => 'required|unique:users,user_name',
Expand All @@ -46,8 +46,7 @@ public function rules()
'last_name' => 'required',
'email' => 'required|email|unique:users,email,'.$this->getSegmentFromEnd().',id',
'company' => 'required',
'mobile' => 'required|numeric',
'mobile_code' => 'required|numeric',
'mobile' => 'required',
'address' => 'required',
'zip' => 'required',
'timezone_id' => 'required',
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Requests/User/ProfileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public function rules()
'last_name' => 'required|max:30',
'email' => 'required|email|unique:users',
'company' => 'required',
'mobile' => 'required|regex:/[0-9]/|min:5|max:20',
'mobile_code' => 'required|numeric',
'mobile' => 'required',
'user_name' => 'required|unique:users|min:3|max:50',
'terms' => 'accepted',
'zip' => 'required',
Expand Down
2 changes: 1 addition & 1 deletion app/Model/License/LicenseType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function permissions()

public function products()
{
return $this->hasMany('App\Model\Product\Product', 'type');
return $this->hasMany('App\Model\Product\Product');
}

public function delete()
Expand Down
2 changes: 1 addition & 1 deletion app/Traits/ApiKeySettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function updatemobileDetails(Request $request)
$status = $request->input('status');
$key = $request->input('msg91_auth_key');
StatusSetting::find(1)->update(['msg91_status'=>$status]);
ApiKey::find(1)->update(['msg91_auth_key'=>$key]);
ApiKey::find(1)->update(['msg91_auth_key'=>$key, 'msg91_sender'=>$request->input('msg91_sender')]);

return ['message' => 'success', 'update'=>'Msg91 Settings Updated'];
}
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

'name' => env('APP_NAME', 'Laravel'),

'version' => 'v1.0.24',
'version' => 'v1.0.26',

/*
|--------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ public function up()
$table->string('description', 2000);
$table->string('category', 225);
$table->integer('parent');
$table->integer('type')->unsigned()->index('products_type_foreign');
$table->integer('group')->unsigned()->index('products_group_foreign');
$table->integer('type')->nullable();
$table->integer('group')->nullable();
// $table->foreign('group')->references('id')->on('product_groups');
// $table->foreign('type')->references('id')->on('license_types');
$table->string('welcome_email');
$table->integer('require_domain');
$table->boolean('can_modify_agent')->nullable();
Expand Down
6 changes: 3 additions & 3 deletions database/migrations/2017_06_10_062630_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public function up()
$table->string('town');
$table->string('state')->nullable()->default('IN-KA');
$table->string('zip');
$table->string('profile_pic');
$table->string('profile_pic')->nullable();
$table->integer('active');
$table->string('role')->default('client');
$table->string('currency', 225)->default('INR');
$table->decimal('debit', 10, 0);
$table->decimal('debit', 10, 0)->nullable();
$table->integer('timezone_id')->default(114);
$table->string('remember_token', 100)->nullable();
$table->timestamps();
Expand All @@ -42,7 +42,7 @@ public function up()
$table->integer('mobile_verified');
$table->string('position', 225)->nullable();
$table->string('skype', 225)->nullable();
$table->integer('manager')->nullable();
$table->string('manager')->nullable();
});
}

Expand Down
Loading

0 comments on commit 1c09bf9

Please sign in to comment.