"use strict";angular.module("getlancerApp.Common.Wallet",["ngResource","ngSanitize","satellizer","ngAnimate","ui.bootstrap","ui.bootstrap.datetimepicker","ui.router","angular-growl","google.places","angular.filter","ngCookies","angular-md5","ui.select2","ui.select","http-auth-interceptor","vcRecaptcha","angulartics","pascalprecht.translate","angulartics.google.analytics","tmh.dynamicLocale","ngMap","chieffancypants.loadingBar","payment","builder","builder.components","validator.rules","angularMoment","ngFileUpload","720kb.socialshare","slugifier"]).config(function($stateProvider,$urlRouterProvider){var getToken={TokenServiceData:function(TokenService,$q){return $q.all({AuthServiceData:TokenService.promise,SettingServiceData:TokenService.promiseSettings})}};$urlRouterProvider.otherwise("/"),$stateProvider.state("wallets",{url:"/wallets",templateUrl:"scripts/plugins/Common/Wallet/views/default/wallet.html",resolve:getToken})}),angular.module("getlancerApp.Common.Wallet").controller("WalletController",["$rootScope","$scope","$window","countries","states","cities","usersAddresses","wallet","flash","$location","$filter","$state","paymentGateways","userSettings","ConstPaymentGateways","UserMeFactory","$timeout",function($rootScope,$scope,$window,countries,states,cities,usersAddresses,wallet,flash,$location,$filter,$state,paymentGateways,userSettings,ConstPaymentGateways,UserMeFactory,$timeout){$rootScope.url_split=$location.path().split("/")[1],$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("Add to wallet"),$scope.minimum_wallet_amount=$rootScope.settings.WALLET_MIN_WALLET_AMOUNT,$scope.maximum_wallet_amount=$rootScope.settings.WALLET_MAX_WALLET_AMOUNT,$scope.buyer={},$scope.paynow_is_disabled=!1,$scope.payment_note_enabled=!1,$scope.payer_form_enabled=!0,$scope.is_wallet_page=!0,$scope.existing_new_address=1,$scope.user_address_id="",$scope.user_address_add={},$scope.save_btn=!1,$scope.first_gateway_id="",$scope.gatewayError="",$scope.isPaytabs=!1,$scope.isPayPal=!1,$scope.index=function(){UserMeFactory.get({},function(response){$scope.user_available_balance=response.data.available_wallet_amount||0,0===parseInt($scope.user_available_balance)?$scope.is_show_wallet_paybtn=!1:$scope.is_show_wallet_paybtn=!0});var payment_gateways=[];paymentGateways.get({},function(payment_response){console.log("1-----");if(payment_response.PayPalREST){var response=payment_response.PayPalREST;response.paypalrest_enabled&&($scope.paypal_enabled=!0,$scope.isPaytabs=!0)}if(payment_response.PayTabs){var response=payment_response.PayTabs;response.paytabs_enabled&&($scope.paytabs_enabled=!0)}$scope.isPaytabs?($scope.isPaytabs=!0,$scope.isPayPal=!1):($scope.isPaytabs=!1,$scope.isPayPal=!0),$scope.group_gateway_id="",0===payment_response.error.code&&void 0!==payment_response.zazpay&&(angular.forEach(payment_response.zazpay.gateways,function(gateway_group_value,gateway_group_key){0===gateway_group_key&&($scope.group_gateway_id=gateway_group_value.id,$scope.first_gateway_id=gateway_group_value.id),angular.forEach(gateway_group_value.gateways,function(payment_geteway_value,payment_geteway_key){var payment_gateway={},suffix="sp_";0===gateway_group_key&&($scope.sel_payment_gateway="sp_"+payment_geteway_value.id),suffix+=payment_geteway_value.id,payment_gateway.id=payment_geteway_value.id,payment_gateway.payment_id=suffix,payment_gateway.group_id=gateway_group_value.id,payment_gateway.display_name=payment_geteway_value.display_name,payment_gateway.thumb_url=payment_geteway_value.thumb_url,payment_gateway.suffix=payment_geteway_value._form_fields._extends_tpl.join(),payment_gateway.form_fields=payment_geteway_value._form_fields._extends_tpl.join(),payment_gateway.instruction_for_manual=payment_geteway_value.instruction_for_manual,payment_gateways.push(payment_gateway)})}),$scope.gateway_groups=payment_response.zazpay.gateways,$scope.payment_gateways=payment_gateways,$scope.form_fields_tpls=payment_response.zazpay._form_fields_tpls,$scope.show_form=[],$scope.form_fields=[],angular.forEach($scope.form_fields_tpls,function(key,value){"buyer"===value&&($scope.form_fields[value]="scripts/plugins/Common/Wallet/views/default/buyer.html"),"credit_card"===value&&($scope.form_fields[value]="scripts/plugins/Common/Wallet/views/default/credit_card.html"),"manual"===value&&($scope.form_fields[value]="scripts/plugins/Common/Wallet/views/default/manual.html"),$scope.show_form[value]=!0}),$scope.gateway_id=ConstPaymentGateways.ZazPay)})},$scope.paneChanged=function(pane){"Manual / Offline"===pane&&($scope.payment_note_enabled=!0),"paypal"===pane&&($scope.gateway_id=ConstPaymentGateways.PayPal),$scope.defaultselect(pane);var keepGoing=!0;$scope.buyer={},$scope.PaymentForm.$setPristine(),$scope.PaymentForm.$setUntouched(),angular.forEach($scope.form_fields_tpls,function(key,value){$scope.show_form[value]=!1}),$scope.gateway_id=ConstPaymentGateways.ZazPay,angular.forEach($scope.gateway_groups,function(res){if(res.display_name===pane&&"Wallet"!==pane){var selPayment="";angular.forEach($scope.payment_gateways,function(response){keepGoing&&response.group_id===res.id&&(selPayment=response,keepGoing=!1,$scope.rdoclick(selPayment.id,selPayment.form_fields))}),$scope.sel_payment_gateway="sp_"+selPayment.id,$scope.group_gateway_id=selPayment.group_id}})},$scope.defaultselect=function(pane){var selectedTab,selectedPayment;$scope.gateways=[];var keepGoing=!0;angular.forEach($scope.gateway_groups,function(res){keepGoing&&res.display_name==pane&&(selectedTab=res,$scope.selectedTab=res,keepGoing=!1)}),keepGoing=!0,angular.forEach($scope.payment_gateways,function(res){keepGoing&&res.group_id==selectedTab.id&&(selectedPayment=res,keepGoing=!1,$scope.rdoclick(selectedPayment.id,selectedPayment.form_fields))}),$scope.gateways="sp_"+selectedPayment.id},$scope.rdoclick=function(res,res1){$scope.paynow_is_disabled=!1,$scope.sel_payment_gateway="sp_"+res,$scope.array=res1.split(","),angular.forEach($scope.array,function(value){$scope.show_form[value]=!0})},$scope.WalletFormSubmit=function(form){var payment_id="";if($scope.sel_payment_gateway&&$scope.gateway_id===ConstPaymentGateways.ZazPay&&(payment_id=$scope.sel_payment_gateway.split("_")[1]),$scope.buyer.user_id=$rootScope.user.id,$scope.buyer.amount=$scope.amount,$scope.buyer.payment_gateway_id=$scope.gateway_id,$scope.buyer.gateway_id=payment_id,angular.isDefined($scope.buyer.credit_card_expired)&&($scope.buyer.credit_card_expired.month||$scope.buyer.credit_card_expired.year)&&($scope.buyer.credit_card_expired.month>0&&$scope.buyer.credit_card_expired.month<10&&($scope.buyer.credit_card_expired.month="0"+$scope.buyer.credit_card_expired.month),$scope.buyer.credit_card_expire=$scope.buyer.credit_card_expired.month+"/"+$scope.buyer.credit_card_expired.year),form){$scope.paynow_is_disabled=!0;var flashMessage;wallet.create($scope.buyer,function(response){0===response.error.code?void 0!==response.redirect_url?$window.location.href=response.redirect_url:void 0!==response.payment_response.gateway_callback_url?$window.location.href=response.payment_response.gateway_callback_url:"Pending"===response.payment_response.status?(flashMessage=$filter("translate")("Your request is in pending."),flash.set(flashMessage,"error",!1),$state.reload()):"Captured"===response.payment_response.status?(flashMessage=$filter("translate")("Amount added successfully."),flash.set(flashMessage,"success",!1),$state.reload()):0===response.payment_response.error.code?(flashMessage=$filter("translate")("Payment successfully completed."),flash.set(flashMessage,"success",!1),$state.reload()):512===response.payment_response.error.code&&(flashMessage=$filter("translate")("Process Failed. Please, try again."),flash.set(flashMessage,"error",!1)):($scope.gatewayError=$filter("translate")(response.payment_response.error.message),flashMessage=$filter("translate")("Payment could not be completed.Please try again..."),flash.set(flashMessage,"error",!1)),$scope.paynow_is_disabled=!1},function(error){(angular.isDefined(error.payment_response.error.message)||null!==error.data.error.message)&&flash.set($filter("translate")(error.payment_response.error.message),"error",!1),$scope.paynow_is_disabled=!1})}},$scope.site_url=$location.absUrl().split("?")[1];var flashMessage;"error_code=0"===$scope.site_url&&(flashMessage=$filter("translate")("Payment successfully completed."),flash.set(flashMessage,"success",!1)),$scope.payNowPaytabClick=function(){var flashMessage;angular.isDefined($scope.amount)?($scope.buyer.user_id=$rootScope.user.id,$scope.buyer.amount=$scope.amount,$scope.buyer.payment_gateway_id=ConstPaymentGateways.PayTab,$scope.buyer.gateway_id=$scope.buyer.payment_gateway_id,$scope.buyer.lang=null!==$window.localStorage.getItem("NG_TRANSLATE_LANG_KEY")?$window.localStorage.getItem("NG_TRANSLATE_LANG_KEY"):"en",$scope.paynow_is_disabled=!0,wallet.create($scope.buyer,function(response){0===response.error.code?void 0!==response.data.payment_url?$window.location.href=response.data.payment_url:(flashMessage=$filter("translate")("Process Failed. Please, try again."),flash.set(flashMessage,"error",!1)):($scope.gatewayError=$filter("translate")(response.payment_response.error.message),flashMessage=$filter("translate")("Payment could not be completed.Please try again..."),flash.set(flashMessage,"error",!1)),$scope.paynow_is_disabled=!1},function(error){(angular.isDefined(error.payment_response.error.message)||null!==error.data.error.message)&&flash.set($filter("translate")(error.payment_response.error.message),"error",!1),$scope.paynow_is_disabled=!1})):(flashMessage=$filter("translate")("please enter amount."),flash.set(flashMessage,"error",!1))},$scope.payNowPayPalClick=function(){var flashMessage;angular.isDefined($scope.amount)?($scope.buyer.user_id=$rootScope.user.id,$scope.buyer.amount=$scope.amount,$scope.buyer.payment_gateway_id=ConstPaymentGateways.PayPal,$scope.buyer.gateway_id=$scope.buyer.payment_gateway_id,$scope.paynow_is_disabled=!0,wallet.create($scope.buyer,function(response){0===response.error.code?void 0!==response.redirect_url?$window.location.href=response.redirect_url:void 0!==response.payment_response.gateway_callback_url?$window.location.href=response.payment_response.gateway_callback_url:"Pending"===response.payment_response.status?(flashMessage=$filter("translate")("Your request is in pending."),flash.set(flashMessage,"error",!1),$state.reload()):"Captured"===response.payment_response.status?(flashMessage=$filter("translate")("Amount added successfully."),flash.set(flashMessage,"success",!1),$state.reload()):0===response.payment_response.error.code?(flashMessage=$filter("translate")("Payment successfully completed."),flash.set(flashMessage,"success",!1),$state.reload()):512===response.payment_response.error.code&&(flashMessage=$filter("translate")("Process Failed. Please, try again."),flash.set(flashMessage,"error",!1)):($scope.gatewayError=$filter("translate")(response.payment_response.error.message),flashMessage=$filter("translate")("Payment could not be completed.Please try again..."),flash.set(flashMessage,"error",!1)),$scope.paynow_is_disabled=!1},function(error){(angular.isDefined(error.payment_response.error.message)||null!==error.data.error.message)&&flash.set($filter("translate")(error.payment_response.error.message),"error",!1),$scope.paynow_is_disabled=!1})):(flashMessage=$filter("translate")("please enter the valid amount."),flash.set(flashMessage,"error",!1))},countries.get({limit:"all"},function(response){angular.isDefined(response.data)&&($scope.countries=response.data)}),$scope.index()}]),angular.module("getlancerApp.Common.Wallet").factory("wallet",["$resource",function($resource){return $resource("/api/v1/wallets",{},{create:{method:"POST"}})}]),angular.module("getlancerApp.Common.Wallet").run(["$templateCache",function($templateCache){$templateCache.put("scripts/plugins/Common/Wallet/views/default/buyer.html",'
')}]);angular.module('getlancerApp').requires.push('getlancerApp.Common.Wallet');"use strict";angular.module("getlancerApp.Common.Withdrawal",["ngResource","ngSanitize","satellizer","ngAnimate","ui.bootstrap","ui.bootstrap.datetimepicker","ui.router","angular-growl","google.places","angular.filter","ngCookies","angular-md5","ui.select2","ui.select","http-auth-interceptor","vcRecaptcha","angulartics","pascalprecht.translate","angulartics.google.analytics","tmh.dynamicLocale","ngMap","chieffancypants.loadingBar","payment","builder","builder.components","validator.rules","angularMoment","ngFileUpload","720kb.socialshare","slugifier"]).config(function($stateProvider,$urlRouterProvider){var getToken={TokenServiceData:function(TokenService,$q){return $q.all({AuthServiceData:TokenService.promise,SettingServiceData:TokenService.promiseSettings})}};$urlRouterProvider.otherwise("/"),$stateProvider.state("user_cash_withdrawals",{url:"/users/cash_withdrawals",templateUrl:"scripts/plugins/Common/Withdrawal/views/default/cash_withdrawals.html",resolve:getToken})}),angular.module("getlancerApp.Common.Withdrawal").controller("CashWithdrawalsController",["$rootScope","$scope","cashWithdrawals","moneyTransferAccount","flash","$filter","$state","UserMeFactory","$location","myUserFactory",function($rootScope,$scope,cashWithdrawals,moneyTransferAccount,flash,$filter,$state,UserMeFactory,$location,myUserFactory){$rootScope.url_split=$location.path().split("/")[2],$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("Cash Withdrawals"),$scope.minimum_withdraw_amount=$rootScope.settings.USER_MINIMUM_WITHDRAW_AMOUNT,$scope.maximum_withdraw_amount=$rootScope.settings.USER_MAXIMUM_WITHDRAW_AMOUNT,$scope.user_available_balance=$rootScope.user.available_wallet_amount,$scope.withDrawAmount=200,$scope.mul=$scope.withDrawAmount*$rootScope.settings.WITHDRAW_REQUEST_FEE,$scope.ExampleAmount=$scope.withDrawAmount-$rootScope.settings.WITHDRAW_REQUEST_FEE,$scope.total=$scope.mul/100,$scope.account_error=!1;var params={},cashparams={};params.user_id=$rootScope.user.id,cashparams.user_id=$rootScope.user.id,$scope.index=function(){$scope.loader=!0,UserMeFactory.get({},function(response){$scope.user_available_balance=response.data.available_wallet_amount,0===parseInt($scope.user_available_balance)?($scope.getMyuser(),$scope.is_show_wallet_paybtn=!1):$scope.is_show_wallet_paybtn=!0}),void 0===$scope.currentPage?cashparams.page=1:cashparams.page=$scope.currentPage,cashWithdrawals.get(cashparams,function(response){angular.isDefined(response._metadata)&&($scope.currentPage=response._metadata.current_page,$scope.totalItems=response._metadata.total,$scope.itemsPerPage=response._metadata.per_page,$scope.noOfPages=response._metadata.last_page),angular.isDefined(response.data)&&($scope.cashWithdrawalsList=response.data),$scope.loader=!1}),moneyTransferAccount.get(params,function(response){angular.isDefined(response.data)&&($scope.moneyTransferList=response.data)})},$scope.selectedAcc=function(id){$scope.account_id=id,$scope.account_error=!1},$scope.getMyuser=function(){$rootScope.isAuth&&myUserFactory.get(function(response){$scope.my_user=response.data})},$scope.submit_btn=!1,$scope.userCashWithdrawSubmit=function($valid){$scope.submit_btn=!0,void 0===$scope.account_id?$scope.account_error=!0:$scope.account_error=!1,$valid&&$scope.account_error===!1&&($scope.amount=parseFloat($("#amount").val()),parseFloat($scope.user_available_balance)>$scope.amount?(params.amount=$scope.amount,params.money_transfer_account_id=$scope.account_id,params.remark="",cashWithdrawals.save(params,function(response){0===response.error.code&&($scope.my_user.available_wallet_amount=$scope.my_user.available_wallet_amount-parseInt($scope.amount),flash.set($filter("translate")("Your request submitted successfully."),"success",!0),$scope.submit_btn=!1,$state.reload())},function(){flash.set($filter("translate")("Withdraw request could not be added"),"error",!1)})):flash.set("You Dont have sufficient amount in your wallet.","error",!1))},$scope.paginate=function(currentpg){$scope.currentPage=parseInt(currentpg),$scope.index()},$scope.index()}]),angular.module("getlancerApp.Common.Withdrawal").factory("cashWithdrawals",["$resource",function($resource){return $resource("/api/v1/users/:user_id/user_cash_withdrawals",{},{get:{method:"GET",params:{user_id:"@user_id"}},save:{method:"POST",params:{user_id:"@user_id"}}})}]),angular.module("getlancerApp.Common.Withdrawal").run(["$templateCache",function($templateCache){$templateCache.put("scripts/plugins/Common/Withdrawal/views/default/cash_withdrawals.html",'
')}]);angular.module('getlancerApp').requires.push('getlancerApp.Common.Withdrawal');"use strict";angular.module("getlancerApp.Common.PaypalREST",["ngResource","ngSanitize","satellizer","ngAnimate","ui.bootstrap","ui.bootstrap.datetimepicker","ui.router","angular-growl","google.places","angular.filter","ngCookies","angular-md5","ui.select2","ui.select","http-auth-interceptor","vcRecaptcha","angulartics","pascalprecht.translate","angulartics.google.analytics","tmh.dynamicLocale","ngMap","chieffancypants.loadingBar","payment","builder","builder.components","validator.rules","angularMoment","ngFileUpload","720kb.socialshare","slugifier"]);angular.module('getlancerApp').requires.push('getlancerApp.Common.PaypalREST');"use strict";function checkFileFormat(file,validFormats){if(file){var value=file.name,ext=value.substring(value.lastIndexOf(".")+1).toLowerCase();return-1!==validFormats.indexOf(ext)}return!1}angular.module("getlancerApp.Bidding",["getlancerApp.Bidding.Constant","ngResource","ngSanitize","satellizer","ngAnimate","ui.bootstrap","ui.bootstrap.datetimepicker","ui.router","angular-growl","google.places","angular.filter","ngCookies","angular-md5","ui.select2","http-auth-interceptor","angulartics","pascalprecht.translate","angulartics.google.analytics","tmh.dynamicLocale","ngFileUpload","infinite-scroll","ngTagsInput","angularMoment","bc.Flickity","afkl.lazyImage","angular-loading-bar","ngAnimate","slugifier","checklist-model","angularjs-dropdown-multiselect","rzModule"]).config(function($stateProvider,$urlRouterProvider){var getToken={TokenServiceData:function(TokenService,$q){return $q.all({AuthServiceData:TokenService.promise,SettingServiceData:TokenService.promiseSettings})}};$urlRouterProvider.otherwise("/"),$stateProvider.state("Bid_ProjectAdd",{url:"/projects/add?enable_hide",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/project_add.html",controller:"ProjectAddCtrl",resolve:getToken}).state("Bid_ProjectEdit",{url:"/projects/edit/:id?status",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/project_edit.html",controller:"ProjectEditCtrl",resolve:getToken}).state("Bid_ProjectView",{url:"/projects/view/:id/:slug?placebid&edit&action&error_code",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/project_view.html",controller:"ProjectViewCtrl",resolve:getToken}).state("Bid_Projects",{url:"/projects?search&page&type&project_categories&skills&price_range_min&price_range_max",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/projects.html",controller:"ProjectsListCtrl",resolve:getToken}).state("Bid_MeProjects",{url:"/projects/me?status",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/my_projects.html",controller:"MyProjectsCtrl",resolve:getToken}).state("Bid_MeBids",{url:"/projects/bids/me",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/my_bids.html",controller:"MyBidsCtrl",resolve:getToken}).state("Bid_ProjectPayment",{url:"/projects/order/:id/:slug",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/project_payment.html",controller:"ProjectPaymentController",resolve:getToken})}).filter("date_format",function($filter){return function(input,format){return $filter("date")(new Date(input),format)}}).filter("capitalize",function(){return function(input){return input?input.charAt(0).toUpperCase()+input.substr(1).toLowerCase():""}}).filter("milestone_status",function($filter){return function(input,format){return"Completed"}}).config(function(tagsInputConfigProvider){tagsInputConfigProvider.setDefaults("tagsInput",{placeholder:"",minLength:1,addOnEnter:!1}).setDefaults("autoComplete",{debounceDelay:200,loadOnDownArrow:!0,loadOnEmpty:!0})}),angular.module("getlancerApp.Bidding").controller("MyBidsCtrl",function($scope,$rootScope,$state,$filter,flash,MyBids,BidMilestone,BidRetake,MeMilestone,MilestoneStatusConstant,MeInvoice){$scope.index=function(params){"milestone"===params.type?(delete params.type,(void 0===$state.params.status||"milestone"!==$state.params.status)&&$state.go("Bid_MeBids",{status:"milestone"},{notify:!1}),$scope.MilestoneStatusConstant=MilestoneStatusConstant,$scope.milestones=[],MeMilestone.get(params,function(response){0===parseInt(response.error.code)&&($scope.milestones=response.data)},function(error){})):"invoice"===params.type?((void 0===$state.params.status||"invoice"!==$state.params.status)&&$state.go("Bid_MeBids",{status:"invoice"},{notify:!1}),delete params.type,$scope.invoices=[],MeInvoice.get(params,function(response){0===parseInt(response.error.code)&&($scope.invoices=response.data)},function(error){})):("active"===params.type?(void 0===$state.params.status||"active"!==$state.params.status)&&$state.go("Bid_MeBids",{status:"active"},{notify:!1}):"my_bids"===params.type?(void 0===$state.params.status||"my_bids"!==$state.params.status)&&$state.go("Bid_MeBids",{status:"my_bids"},{notify:!1}):(void 0===$state.params.status||"past_projects"!==$state.params.status)&&$state.go("Bid_MeBids",{status:"past_projects"},{notify:!1}),MyBids.get(params,function(response){0===parseInt(response.error.code)&&($scope.currentPage=response._metadata.current_page,$scope.totalItems=response._metadata.total,$scope.itemsPerPage=response._metadata.per_page,$scope.noOfPages=response._metadata.last_page),0===parseInt(response.error.code)?$scope.mybids=response.data:($scope.mybids=[],$scope.errorMessage="",angular.isDefined(response.error)&&($scope.errorMessage=response.error.message),$scope.currentPage=0,$scope.totalItems=0,$scope.itemsPerPage=0,$scope.noOfPages=0)}))},$state.params.status?(alert("in bddd"),"my_bids"===$state.params.status?$scope.activeStatus=1:"past_projects"===$state.params.status?$scope.activeStatus=2:"milestone"===$state.params.status?$scope.activeStatus=3:"invoice"===$state.params.status?$scope.activeStatus=4:$scope.activeStatus=0,$scope.index({type:$state.params.status})):$scope.activeStatus=0,$scope.paginate=function(){$scope.currentPage=parseInt($scope.currentPage),$scope.index()},$scope.getBidsShow=function(tabType){$scope.params={type:tabType,page:void 0!==$scope.currentPage?$scope.currentPage:1},$scope.index($scope.params)},$scope.bidAction=function(indexVal,atype,bidId){if(parseInt(atype)){var title="",cbuton="";1==parseInt(atype)?(title=$filter("translate")("Are you sure you want to edit this bid?"),cbuton="Edit"):(title=$filter("translate")("Are you sure you want to withdraw this bid?"),cbuton="Withdraw"),swal({title:title,text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){if(isConfirm){var flashMessage="";if(1==parseInt(atype))$state.go("Bid_ProjectView",{id:$scope.mybids[indexVal].project.id,slug:$scope.mybids[indexVal].project.slug,placebid:!0,edit:!0});else{var params={};params.is_freelancer_withdrawn=1,BidRetake.put({id:bidId},params,function(response){if(0===response.error.code){flashMessage=$filter("translate")("Your bid withdrawn successfully."),flash.set(flashMessage,"success",!1);var params=$state.params;params.placebid=!0,$state.go("Bid_ProjectView",params)}else flashMessage=$filter("translate")("Please try again."),flash.set(flashMessage,"error",!1)})}}})}}}),angular.module("getlancerApp.Bidding").controller("ProjectPaymentController",function($rootScope,$scope,$window,countries,states,cities,$stateParams,usersAddresses,wallet,flash,$location,$filter,$state,paymentGateways,userSettings,ConstPaymentGateways,ProjectEditView,UserMeFactory,PaymentOrderFactory,$uibModalStack){$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("Confirm your Payment"),$scope.id=$stateParams.id,$scope.minimum_wallet_amount=$rootScope.settings.WALLET_MIN_WALLET_AMOUNT,$scope.maximum_wallet_amount=$rootScope.settings.WALLET_MAX_WALLET_AMOUNT,$scope.buyer={},$scope.plan={},$scope.paynow_is_disabled=!1,$scope.payment_note_enabled=!1,$scope.payer_form_enabled=!0,$scope.is_wallet_page=!0,$scope.plan_info={},$scope.save_btn=!1,$scope.first_gateway_id="",$scope.plan_info.price_final=10,$scope.index=function(){ProjectEditView.get({id:$state.params.id},function(response){$scope.projectadd=response.data,$scope.total_listing_fee=response.data.total_listing_fee,$scope.projectTitle=response.data.name}),$scope.loader=!0,$scope.payment=!0,UserMeFactory.get({},function(response){$scope.user_available_balance=response.data.available_wallet_amount});$scope.payNowPaytabClick=function(){var flashMessage;$scope.buyer.foreign_id=$state.params.id,$scope.buyer["class"]="Project",$scope.buyer.user_id=$rootScope.user.id,$scope.buyer.amount=$scope.amount,$scope.buyer.payment_gateway_id=ConstPaymentGateways.PayTab,$scope.buyer.gateway_id=$scope.buyer.payment_gateway_id,$scope.buyer.lang=null!==$window.localStorage.getItem("NG_TRANSLATE_LANG_KEY")?$window.localStorage.getItem("NG_TRANSLATE_LANG_KEY"):"en",$scope.paynow_is_disabled=!0,PaymentOrderFactory.create($scope.buyer,function(response){0===response.error.code?void 0!==response.data.payment_url?$window.location.href=response.data.payment_url:(flashMessage=$filter("translate")("Process Failed. Please, try again."),flash.set(flashMessage,"error",!1)):($scope.gatewayError=$filter("translate")(response.payment_response.error.message),flashMessage=$filter("translate")("Payment could not be completed.Please try again..."),flash.set(flashMessage,"error",!1)),$scope.paynow_is_disabled=!1},function(error){(angular.isDefined(error.payment_response.error.message)||null!==error.data.error.message)&&flash.set($filter("translate")(error.payment_response.error.message),"error",!1),$scope.paynow_is_disabled=!1})};var payment_gateways=[];paymentGateways.get(function(payment_response){console.log("6-----");if(payment_response.wallet&&($scope.wallet_enabled=!0,0===parseInt($scope.user_available_balance)?$scope.is_show_wallet_paybtn=!1:$scope.is_show_wallet_paybtn=!0),payment_response.PayTabs){var response=payment_response.PayTabs;response.paytabs_enabled&&($scope.paytabs_enabled=!0)}if(payment_response.PayPalREST){var response=payment_response.PayPalREST;response.paypalrest_enabled&&($scope.paypal_enabled=!0)}if(payment_response.PayTabs){var response=payment_response.PayTabs;response.paytabs_enabled&&($scope.paytabs_enabled=!0)}$scope.is_show_wallet_paybtn?($scope.isPaytabs=!1,$scope.isPayPal=!1):$scope.isPaytabs?($scope.isPaytabs=!0,$scope.isPayPal=!1):($scope.isPaytabs=!1,$scope.isPayPal=!0),$scope.group_gateway_id="",0===payment_response.error.code&&void 0!==payment_response.zazpay&&(angular.forEach(payment_response.zazpay.gateways,function(gateway_group_value,gateway_group_key){0===gateway_group_key&&($scope.group_gateway_id=gateway_group_value.id,$scope.first_gateway_id=gateway_group_value.id),angular.forEach(gateway_group_value.gateways,function(payment_geteway_value,payment_geteway_key){var payment_gateway={},suffix="sp_";0===gateway_group_key&&($scope.sel_payment_gateway="sp_"+payment_geteway_value.id),suffix+=payment_geteway_value.id,payment_gateway.id=payment_geteway_value.id,payment_gateway.payment_id=suffix,payment_gateway.group_id=gateway_group_value.id,payment_gateway.display_name=payment_geteway_value.display_name,payment_gateway.thumb_url=payment_geteway_value.thumb_url,payment_gateway.suffix=payment_geteway_value._form_fields._extends_tpl.join(),payment_gateway.form_fields=payment_geteway_value._form_fields._extends_tpl.join(),payment_gateway.instruction_for_manual=payment_geteway_value.instruction_for_manual,payment_gateways.push(payment_gateway)})}),$scope.gateway_groups=payment_response.zazpay.gateways,$scope.payment_gateways=payment_gateways,$scope.form_fields_tpls=payment_response.zazpay._form_fields_tpls,$scope.show_form=[],$scope.form_fields=[],angular.forEach($scope.form_fields_tpls,function(key,value){"buyer"===value&&($scope.form_fields[value]="views/buyer.html"),"credit_card"===value&&($scope.form_fields[value]="views/credit_card.html"),"manual"===value&&($scope.form_fields[value]="views/manual.html"),$scope.show_form[value]=!0}),$scope.gateway_id=ConstPaymentGateways.ZazPay),$scope.loader=!1})},$scope.applyCoupon=function(){var params={};params.coupon_code=$scope.plan.coupon,params.amount=$scope.project.zazpay_revised_amount,CouponGetStatusFactory.get(params,function(response){if($scope.discountCoupon=response,0===response.error.code)if($scope.discountCoupon.data.discount_type_id==ConstDiscountType.Amount)$scope.plan_info.price_final=parseFloat($scope.project.zazpay_revised_amount)-parseFloat(response.data.discount),$scope.show_discount=$filter("currency")(response.data.discount);else{var discount_amt=response.data.discount/100*$scope.project.zazpay_revised_amount;$scope.plan_info.price_final=$scope.project.zazpay_revised_amount-discount_amt,$scope.show_discount=$filter("translate")(response.data.discount+"%")}else flash.set($filter("translate")(response.error.message),"error",!1),$scope.plan.coupon=""})},$scope.ClearCoupon=function(){$scope.plan_info.price_final=$scope.project.zazpay_revised_amount,$scope.purchase_plan_coupon=!1,$scope.show_discount=!1},$scope.paneChanged=function(pane){"Manual / Offline"===pane&&($scope.payment_note_enabled=!0);var keepGoing=!0;$scope.buyer={},$scope.PaymentForm.$setPristine(),$scope.PaymentForm.$setUntouched(),angular.forEach($scope.form_fields_tpls,function(key,value){$scope.show_form[value]=!1}),$scope.gateway_id=ConstPaymentGateways.ZazPay,angular.forEach($scope.gateway_groups,function(res){if(res.display_name===pane&&"Wallet"!==pane){var selPayment="";angular.forEach($scope.payment_gateways,function(response){keepGoing&&response.group_id===res.id&&(selPayment=response,keepGoing=!1,$scope.rdoclick(selPayment.id,selPayment.form_fields))}),$scope.sel_payment_gateway="sp_"+selPayment.id,$scope.group_gateway_id=selPayment.group_id}}),"Wallet"===pane?$scope.gateway_id=ConstPaymentGateways.Wallet:"paypal"===pane&&($scope.gateway_id=ConstPaymentGateways.PayPal)},$scope.rdoclick=function(res,res1){$scope.paynow_is_disabled=!1,$scope.sel_payment_gateway="sp_"+res,$scope.array=res1.split(","),angular.forEach($scope.array,function(value){$scope.show_form[value]=!0})},$scope.PaymentFormSubmit=function(form){var payment_id="";if($scope.sel_payment_gateway&&$scope.gateway_id===ConstPaymentGateways.ZazPay&&(payment_id=$scope.sel_payment_gateway.split("_")[1]),$scope.buyer.foreign_id=$state.params.id,$scope.buyer["class"]="Project",$scope.buyer.buyer_name=$scope.buyer.credit_card_name_on_card,$scope.buyer.payment_gateway_id=$scope.gateway_id,$scope.buyer.gateway_id=payment_id,$scope.buyer.coupon_code=$scope.plan.coupon,angular.isDefined($scope.buyer.credit_card_expired)&&($scope.buyer.credit_card_expired.month||$scope.buyer.credit_card_expired.year)&&($scope.buyer.credit_card_expire=$scope.buyer.credit_card_expired.month+"/"+$scope.buyer.credit_card_expired.year),form){$scope.paynow_is_disabled=!0;var flashMessage;if(parseFloat($scope.plan_info.price_final)>parseFloat($scope.user_available_balance)&&$scope.gateway_id===ConstPaymentGateways.Wallet)return flashMessage=$filter("translate")("Your wallet has insufficient money."),flash.set(flashMessage,"error",!1),$scope.paynow_is_disabled=!1,!0;PaymentOrderFactory.create($scope.buyer,function(response){0===response.error.code?void 0!==response.redirect_url?$window.location.href=response.redirect_url:void 0!==response.data.gateway_callback_url?$window.location.href=response.data.gateway_callback_url:"Pending"===response.data.status?(flashMessage=$filter("translate")("Your request is in pending."),flash.set(flashMessage,"error",!1),$state.reload()):"Captured"===response.data.status?(flashMessage=$filter("translate")("Amount added successfully."),flash.set(flashMessage,"success",!1),$state.reload()):0===response.error.code?("Captured"===response.payment_response.status&&($scope.my_user.available_wallet_amount=$scope.my_user.available_wallet_amount-parseInt(response.data.total_listing_fee)),flashMessage=$filter("translate")("Payment successfully completed."),flash.set(flashMessage,"success",!1),$state.reload(),$state.go("user_dashboard")):512===response.error.code&&(flashMessage=$filter("translate")("Process Failed. Please, try again."),flash.set(flashMessage,"error",!1)):(flashMessage=$filter("translate")("We are unable to process your request. Please try again."+response.error.message),flash.set(flashMessage,"error",!1)),$scope.paynow_is_disabled=!1,$uibModalStack.dismissAll()},function(error){console.log(error)})}},$scope.payNowPayPalClick=function(){var flashMessage;$scope.buyer.foreign_id=$state.params.id,$scope.buyer["class"]="Project",$scope.buyer.payment_gateway_id=ConstPaymentGateways.PayPal,$scope.buyer.gateway_id=$scope.buyer.payment_gateway_id,$scope.paynow_is_disabled=!0,PaymentOrderFactory.create($scope.buyer,function(response){0===response.error.code?void 0!==response.redirect_url?$window.location.href=response.redirect_url:void 0!==response.data.gateway_callback_url?$window.location.href=response.data.gateway_callback_url:"Pending"===response.data.status?(flashMessage=$filter("translate")("Your request is in pending."),flash.set(flashMessage,"error",!1),$state.reload()):"Captured"===response.data.status?(flashMessage=$filter("translate")("Amount added successfully."),flash.set(flashMessage,"success",!1),$state.reload()):0===response.error.code?("Captured"===response.payment_response.status&&($scope.my_user.available_wallet_amount=$scope.my_user.available_wallet_amount-parseInt(response.data.total_listing_fee)),flashMessage=$filter("translate")("Payment successfully completed."),flash.set(flashMessage,"success",!1),$state.reload(),$state.go("user_dashboard")):512===response.error.code&&(flashMessage=$filter("translate")("Process Failed. Please, try again."),flash.set(flashMessage,"error",!1)):(flashMessage=$filter("translate")("We are unable to process your request. Please try again."+response.error.message),flash.set(flashMessage,"error",!1)),$scope.paynow_is_disabled=!1,$uibModalStack.dismissAll()},function(error){console.log(error)})},countries.get({limit:"all"},function(response){angular.isDefined(response.data)&&($scope.countries=response.data)}),$scope.index()}),angular.module("getlancerApp.Bidding").controller("ProjectAddCtrl",function($scope,$rootScope,$state,$filter,flash,Projects,ProjectStatus,ProjectSkills,ProjectCategory,ProjectRange,FileFormat,Upload,ProjectStatusConstant,$window,$timeout,AutocompleteUsers,ConstUserRole){$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("Post a Project"),$scope.data={},$timeout(function(){$scope.text_box=!0},1e3),$scope.show_custom_range=!1,$scope.project_bidding_fee=parseInt($rootScope.settings.PROJECT_MAX_BID_DURATION)||0,$scope.PROJECT_TOTAL_FEE=$rootScope.settings.PROJECT_LISTING_FEE,$scope.ProjectStatusConstant=ProjectStatusConstant,$scope.index=function(){$scope.data.skill_select=[],$scope.data.category_select=[],ProjectStatus.get(function(response){0===parseInt(response.error.code)?$scope.projectStatus=response.data:console.log("Status Error")},function(error){console.log("ProjectStatus Error",error)});var params={};params.limit="all",ProjectSkills.get(params,function(response){0===parseInt(response.error.code)?($scope.projectSkill=[],$scope.projectSkills=response.data,angular.forEach($scope.projectSkills,function(value){$scope.projectSkill.push({id:value.id,text:value.name}),void 0!==$scope.projectskillsList&&-1!=$scope.projectskillsList.indexOf(value.id)&&$scope.data.skill_select.push({id:value.id,text:value.name})})):console.log("Skills Error")},function(error){console.log("Skills Error",error)}),AutocompleteUsers.get(function(response){0===parseInt(response.error.code)?($scope.employerUser=[],$scope.employerUsers=response.data,angular.forEach($scope.employerUsers,function(value){$scope.employerUser.push({id:value.id,text:value.username}),void 0!==$scope.employerUsersList&&-1!=$scope.employerUsersList.indexOf(value.id)&&$scope.data.user_select.push({id:value.id,text:value.username})})):console.log("Users Error")},function(error){console.log("Users Error",error)}),ProjectRange.get(function(response){0===parseInt(response.error.code)?($scope.projectRanges=[],angular.forEach(response.data,function(value){$scope.projectRanges.push({id:value.id,name:value.name+" ("+$rootScope.settings.CURRENCY_SYMBOL+value.min_amount+" - "+$rootScope.settings.CURRENCY_SYMBOL+ +value.max_amount+")"})}),$scope.projectRanges.push({id:0,name:"Custom Range"})):console.log("Ranges Error")},function(error){console.log("projectRanges Error",error)}),ProjectCategory.get(function(response){0===parseInt(response.error.code)?($scope.projectCategories=response.data,$scope.projectCat=[],angular.forEach($scope.projectCategories,function(value){$scope.projectCat.push({id:value.id,text:value.name}),void 0!==$scope.projectCategoriesList&&-1!=$scope.projectCategoriesList.indexOf(value.id)&&$scope.data.category_select.push({id:value.id,text:value.name})})):console.log("Categories Error")},function(error){console.log("ProjectCategory Error",error)})},$scope.index(),$scope.loadCategories=function(qstr){qstr=qstr.toLowerCase();var items=[];return angular.forEach($scope.projectCat,function(value){name=value.text.toLowerCase(),name.indexOf(qstr)>=0&&items.push({id:value.id,text:value.text})}),items},$scope.loadSkills=function(qstr){qstr=qstr.toLowerCase();var items=[];return angular.forEach($scope.projectSkill,function(value){name=value.text.toLowerCase(),name.indexOf(qstr)>=0&&items.push({id:value.id,text:value.text})}),items},$scope.loadEmployers=function(qstr){qstr=qstr.toLowerCase();var items=[];return angular.forEach($scope.employerUser,function(value){name=value.text.toLowerCase(),name.indexOf(qstr)>=0&&items.push({id:value.id,text:value.text})}),items},$scope.save_btn=!1,$scope.postProject=function($valid,projectFrm,data,type){$valid&&!$scope.error_message?($scope.save_btn=!0,1===type?data.project_status_id=ProjectStatusConstant.Draft:data.project_status_id=ProjectStatusConstant.PaymentPending,'Custom Range"'===data.project_range_id&&($scope.custom_range={}),angular.isDefined(data.skill_select)&&Object.keys(data.skill_select).length>0&&($scope.seperate_skills=[],angular.forEach(data.skill_select,function(value){$scope.seperate_skills.push(value.text)}),data.skills=$scope.seperate_skills.toString()),angular.isDefined(data.category_select)&&Object.keys(data.category_select).length>0&&(data.project_categories=[],angular.forEach(data.category_select,function(value){data.project_categories.push({project_category_id:value.id})})),angular.isUndefined(data.user_id)&&(data.user_id=ConstUserRole.Admin),Projects.post($scope.data,function(response){var flashMessage;0===parseInt(response.error.code)?(1===type?(flashMessage=$filter("translate")("Project stored in draft successfully."),$state.go("user_dashboard",{type:"my_projects",status:"draft_payment_pending"})):(flashMessage=$filter("translate")("Project added successfully."),response.total_listing_fee>0?$state.go("Bid_ProjectPayment",{id:response.id,slug:response.slug}):$state.go("Bid_ProjectView",{id:response.id,slug:response.slug})),flash.set(flashMessage,"success",!1)):($scope.save_btn=!1,flashMessage=1===type?$filter("translate")("Project stored in draft failed."):$filter("translate")("Project added failed."),flash.set(flashMessage,"error",!1))},function(error){console.log("postProject Error",error)})):$timeout(function(){$(".error").each(function(){return $(this).hasClass("ng-hide")?void 0:($scope.scrollvalidate($(this).offset().top-140),!1)})},100)},$scope.scrollvalidate=function(topvalue){$("html, body").animate({scrollTop:topvalue})},$scope.customRange=function(val){0===parseInt(val)?$scope.show_custom_range=!0:$scope.show_custom_range=!1},$scope.upload=function(file){Upload.upload({url:"/api/v1/attachments?class=Project",data:{file:file}}).then(function(response){0===response.data.error.code?($scope.data.image=response.data.attachment,$scope.error_message=""):$scope.error_message=response.data.error.message})},$scope.amount_find=!0,$scope.projectFeatureFeeAdd=function(value){$scope.data.is_featured?($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt(value||0)},100)):($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)-parseInt(value||0)},100))},$scope.projectUrgentFeeAdd=function(value){$scope.data.is_urgent?($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt(value||0)},100)):($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)-parseInt(value||0)},100))},$scope.projectPrivateFeeAdd=function(value){$scope.data.is_private?($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt(value||0)},100)):($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)-parseInt(value||0)},100))},$scope.projectHiddenFeeAdd=function(value){$scope.data.is_hidded_bid?($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt(value||0)},100)):($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)-parseInt(value||0)},100))}}).controller("ProjectEditCtrl",function($scope,$rootScope,$state,$filter,flash,ProjectEditView,ProjectStatus,ProjectSkills,ProjectCategory,ProjectRange,ProjectStatusConstant,md5,$timeout,AutocompleteUsers,ConstUserRole,Upload){$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("Edit Project"),$timeout(function(){$scope.text_box=!0},1e3),$scope.projectRanges=[],$scope.projectRangesId=[],$scope.OpenForBidding=ProjectStatusConstant.OpenForBidding,$scope.PendingApproval=ProjectStatusConstant.PendingForApproval,$scope.Draft=ProjectStatusConstant.Draft,$scope.paymentPending=ProjectStatusConstant.PaymentPending,$scope.projectCustomCheck=0,$scope.PROJECT_TOTAL_FEE=$rootScope.settings.PROJECT_LISTING_FEE,$scope.project_bidding_fee=parseInt($rootScope.settings.PROJECT_MAX_BID_DURATION)||0,$scope.index=function(){function skillCategoriesBack(){var params={};params.limit="all",params.project_id=$state.params.id,ProjectSkills.get(params,function(response){0===parseInt(response.error.code)?($scope.projectSkills=response.data,$scope.projectSkill=[],$scope.data.skill_select=[],angular.forEach($scope.projectSkills,function(value){$scope.projectSkill.push({id:value.id,text:value.name}),""!==selectedSkill&&-1!=selectedSkill.indexOf(value.id)&&$scope.data.skill_select.push({id:value.id,text:value.name})})):console.log("Skills Error")},function(error){console.log("Skills Error",error)}),ProjectCategory.get(function(response){0===parseInt(response.error.code)?($scope.projectCategories=response.data,$scope.projectCat=[],$scope.data.category_select=[],angular.forEach($scope.projectCategories,function(catvalueFinal){$scope.projectCat.push({id:catvalueFinal.id,text:catvalueFinal.name}),-1!=selectedProjectCat.indexOf(catvalueFinal.id)&&$scope.data.category_select.push({id:catvalueFinal.id,text:catvalueFinal.name})})):console.log("Categories Error")},function(error){console.log("ProjectCategory Error",error)}),AutocompleteUsers.get(function(response){0===parseInt(response.error.code)?($scope.employerUser=[],$scope.employerUsers=response.data,$scope.data.user_select=[],angular.forEach($scope.employerUsers,function(value){$scope.employerUser.push({id:value.id,text:value.username})})):console.log("User Error")},function(error){console.log("Users Error",error)})}var selectedSkill=[],selectedProjectCat=[],params={id:$state.params.id};$state.params.status&&(params.status=$state.params.status),$scope.customRange=function(val){$scope.data.custom_range={},parseInt(val)==parseInt($scope.projectCustomCheck)?($scope.show_custom_range=!0,$scope.data.custom_range.min_amount=""):($scope.show_custom_range=!1,delete $scope.data.custom_range)},ProjectEditView.get(params,function(response){response.data.project_status_id<$scope.OpenForBidding?0===parseInt(response.error.code)?($scope.data={},$scope.data.name=response.data.name,$scope.data.description=response.data.description,$scope.data.bid_duration=response.data.bid_duration,$scope.data.additional_descriptions=response.data.additional_descriptions,$scope.data.project_status_id=response.data.project_status_id,$scope.data.is_featured=response.data.is_featured,$scope.data.is_private=response.data.is_private,$scope.data.is_urgent=response.data.is_urgent,$scope.data.is_hidded_bid=response.data.is_hidded_bid,$scope.data.user_id=response.data.user_id,$scope.data.username=response.data.user.username,$scope.accessCard={id:response.data.user_id,username:response.data.user.username},$scope.data.project_range_id=parseInt(response.data.project_range_id),angular.forEach(response.data.skills_projects,function(value){selectedSkill.push(value.skills.id)}),angular.forEach(response.data.projects_project_categories,function(catvalue){selectedProjectCat.push(catvalue.project_categories.id)}),angular.element(document.getElementsByClassName("btn dropdown-toggle")).prop("title",$scope.data.username),angular.element(".filter-option").text($scope.data.username),skillCategoriesBack(),ProjectRange.get(function(response){0===parseInt(response.error.code)?($scope.amount_find=!0,angular.forEach(response.data,function(value){$scope.projectRangesId.push(value.id),$scope.data.project_range_id===value.id&&($scope.project_range=value.id),$scope.projectRanges.push({id:value.id,name:value.name+" ("+$rootScope.settings.CURRENCY_SYMBOL+value.min_amount+" - "+$rootScope.settings.CURRENCY_SYMBOL+ +value.max_amount+")"})})):console.log("Ranges Error"),$scope.data.project_range_id===$scope.project_range?$scope.show_custom_range=!1:($scope.show_custom_range=!0,$scope.custom_id=0,$scope.data.project_range_id=0)},function(error){console.log("projectRanges Error",error)}),$scope.projectRangesId.indexOf(response.data.project_range_id)>-1?($scope.data.project_range_id=response.data.project_range_id,delete $scope.data.custom_range):($scope.range={},$scope.data.custom_range={},$scope.data.custom_range.min_amount=Number(response.data.project_range.min_amount),$scope.data.custom_range.max_amount=Number(response.data.project_range.max_amount)),$scope.projectRangesId.indexOf($scope.data.project_range_id)?$scope.projectRanges.push({id:0,name:"Custom Range"}):($scope.projectRanges.push({id:$scope.data.project_range_id,name:"Custom Range"}),$scope.projectCustomCheck=$scope.data.project_range_id),angular.isDefined(response.data.attachment)&&null!==response.data.attachment&&($scope.project_filename=response.data.attachment.filename),$scope.data.is_featured&&($scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt($rootScope.settings.PROJECT_FEATURED_FEE||0)),$scope.data.is_urgent&&($scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt($rootScope.settings.PROJECT_URGENT_FEE||0)),$scope.data.is_private&&($scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt($rootScope.settings.PROJECT_PRIVATE_PROJECT_FEE||0)),$scope.data.is_hidded_bid&&($scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt($rootScope.settings.PROJECT_HIDDEN_BID_FEE||0))):console.log("Skills Error"):($scope.data={},$scope.data.project_status_id=response.data.project_status_id,$scope.data.name=response.data.name,$scope.data.additional_descriptions=response.data.additional_descriptions,angular.forEach(response.data.skills_projects,function(value){selectedSkill.push(value.skills.id)}),skillCategoriesBack())}),ProjectStatus.get(function(response){0===parseInt(response.error.code)?$scope.projectStatus=response.data:console.log("Status Error")},function(error){console.log("ProjectStatus Error",error)})},$scope.index(),$scope.loadCategories=function(qstr){qstr=qstr.toLowerCase();var items=[];return angular.forEach($scope.projectCat,function(value){name=value.text.toLowerCase(),name.indexOf(qstr)>=0&&items.push({id:value.id,text:value.text})}),items},$scope.loadSkills=function(qstr){qstr=qstr.toLowerCase();var items=[];return angular.forEach($scope.projectSkill,function(value){name=value.text.toLowerCase(),name.indexOf(qstr)>=0&&items.push({id:value.id,text:value.text})}),items},$scope.loadEmployers=function(qstr){qstr=qstr.toLowerCase();var items=[];return angular.forEach($scope.employerUser,function(value){name=value.text.toLowerCase(),name.indexOf(qstr)>=0&&items.push({id:value.id,text:value.text})}),items},$scope.upload=function(file){Upload.upload({url:"/api/v1/attachments?class=Project",data:{file:file}}).then(function(response){0===response.data.error.code?($scope.data.image=response.data.attachment,$scope.error_message=""):$scope.error_message=response.data.error.message})},$scope.save_btn=!1,$scope.showform=!1,$scope.postProject=function($valid,data,type){$valid&&!$scope.error_message?($scope.showform=!0,$scope.save_btn=!0,1===type?data.project_status_id=ProjectStatusConstant.Draft:2===type?data.project_status_id=ProjectStatusConstant.PaymentPending:delete data.project_status_id,"custom"===data.project_range_id&&($scope.custom_range={}),angular.isDefined(data.skill_select)&&Object.keys(data.skill_select).length>0&&($scope.seperate_skills=[],angular.forEach(data.skill_select,function(value){$scope.seperate_skills.push(value.text)}),data.skills=$scope.seperate_skills.toString()),angular.isDefined(data.category_select)&&Object.keys(data.category_select).length>0&&(data.project_categories=[],angular.forEach(data.category_select,function(value){data.project_categories.push({project_category_id:value.id})})),angular.isUndefined(data.user_id)&&(data.user_id=ConstUserRole.Admin),ProjectEditView.put({id:$state.params.id},data,function(response){var flashMessage;0===parseInt(response.error.code)?(1===type?(flashMessage=$filter("translate")("Project stored in draft successfully."),$state.go("user_dashboard",{type:"my_projects",status:"draft_payment_pending"})):(flashMessage=$filter("translate")("Project updated successfully."),
response.total_listing_fee>0&&response.project_status_id!=$scope.OpenForBidding&&response.project_status_id!=$scope.PendingApproval?$state.go("Bid_ProjectPayment",{id:response.id,slug:response.slug}):response.project_status_id==$scope.OpenForBidding?(flashMessage=$filter("translate")("Project updated successfully."),$state.go("Bid_ProjectView",{id:response.id,slug:response.slug})):response.project_status_id==$scope.PendingApproval?(flashMessage=$filter("translate")("Project updated successfully."),$state.go("user_dashboard",{type:"my_projects",status:"open_bidding"})):$state.go("Bid_ProjectView",{id:response.id,slug:response.slug})),flash.set(flashMessage,"success",!1)):(1===type?(flashMessage=$filter("translate")("Project stored in draft failed."),$state.go("Bid_Projects")):flashMessage=$filter("translate")("Project update failed."),flash.set(flashMessage,"error",!1))},function(error){console.log("postProject Error",error)})):$timeout(function(){$(".error").each(function(){return $(this).hasClass("ng-hide")?void 0:($scope.scrollvalidate($(this).offset().top-140),!1)})},100)},$scope.scrollvalidate=function(topvalue){$("html, body").animate({scrollTop:topvalue})},$scope.projectFeatureFeeAdd=function(value){$scope.amount_find=!0,$scope.data.is_featured?($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt(value||0)},100)):($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)-parseInt(value||0)},100))},$scope.projectUrgentFeeAdd=function(value){$scope.data.is_urgent?($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt(value||0)},100)):($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)-parseInt(value||0)},100))},$scope.projectPrivateFeeAdd=function(value){$scope.data.is_private?($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt(value||0)},100)):($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)-parseInt(value||0)},100))},$scope.projectHiddenFeeAdd=function(value){$scope.data.is_hidded_bid?($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)+parseInt(value||0)},100)):($scope.amount_find=!1,$timeout(function(){$scope.amount_find=!0,$scope.PROJECT_TOTAL_FEE=parseInt($scope.PROJECT_TOTAL_FEE||0)-parseInt(value||0)},100))}}).controller("ProjectsListCtrl",function($scope,$rootScope,$state,$filter,$location,flash,Projects,ProjectStatus,ProjectSkills,ProjectCategory,ProjectStatusConstant,$stateParams){$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("Browse Projects"),$scope.data=[],$scope.priceSlider=150,$scope.params={},$scope.sortby=$scope.params.sortby="desc",$scope.created_at="down",$scope.OpenForBidding=ProjectStatusConstant.OpenForBidding,$scope.bookmarked=!0,$scope.data={search:$state.params.search,project_categories:$state.params.categories,skills:$state.params.skills,price_range_min:$state.params.price_range_min,price_range_max:$state.params.price_range_max,project_status_id:$scope.OpenForBidding,page:void 0!==$scope.currentPage?$scope.currentPage:1},$scope.orderPosted=function(sortby){$scope.sort="created_at",$scope.sortby=sortby,"asc"===sortby&&($scope.created_at="down"),$scope.sortby="desc","desc"===sortby&&($scope.sortby="asc",$scope.created_at="up"),$scope.index()},"bookmarked"==$state.params.type?($scope.type="bookmarked",$scope.bookmarked=!1,$scope.skill=!1):"my_skills"==$state.params.type?($scope.type="my_skills",$scope.bookmarked=!1,$scope.skill=!0):($scope.type="price_range",$scope.bookmarked=!0),$scope.index=function(params){$scope.slider={},$scope.getProjects(),$scope.loader=!0,Projects.get({type:$scope.type},function(response){angular.isDefined(response.data)&&($scope.minimum_price=response.data.min_price,$scope.maximum_price=response.data.max_price,null==response.data.min_price&&null==response.data.max_price?($scope.min_price=0,$scope.max_price=1e3):null!=response.data.min_price&&null!=response.data.max_price&&($scope.min_price=$scope.minimum_price,$scope.max_price=$scope.maximum_price),angular.isDefined($state.params.price_range_min)&&angular.isDefined($state.params.price_range_max)&&($scope.min_price=$state.params.price_range_min,$scope.max_price=$state.params.price_range_max),null==response.data.min_price&&null==response.data.max_price?$scope.slider={min:$scope.min_price,max:$scope.max_price,options:{floor:parseInt($scope.min_price),ceil:parseInt($scope.max_price)}}:null!=response.data.min_price&&null!=response.data.max_price&&void 0===$stateParams.price_range_max&&void 0===$stateParams.price_range_max?$scope.slider={min:$scope.minimum_price,max:$scope.maximum_price,options:{floor:parseInt(response.data.min_price),ceil:parseInt(response.data.max_price)}}:$scope.slider={min:$stateParams.price_range_min,max:$stateParams.price_range_max,options:{floor:parseInt(response.data.min_price),ceil:parseInt(response.data.max_price)}})})},$scope.getProjects=function(){var params={};void 0!=$stateParams.search&&(params.search=$stateParams.search),void 0!=$stateParams.project_categories&&(params.project_categories=$stateParams.project_categories),void 0!=$stateParams.skills&&(params.skills=$stateParams.skills),void 0!=$stateParams.price_range_max&&(params.price_range_max=$stateParams.price_range_max),void 0!=$stateParams.price_range_min&&(params.price_range_min=$stateParams.price_range_min),"bookmarked"===$state.params.type&&(params.type="bookmarked",$scope.bookmarked=!1),"my_skills"===$state.params.type&&(params.type="my_skills",$scope.bookmarked=!1),void 0===$state.params.page?params.page=1:params.page=$state.params.page,void 0!==$scope.sort&&(params.sort=$scope.sort,params.sortby=$scope.sortby),Projects.get(params,function(response){angular.isDefined(response._metadata)&&($scope.currentPage=response._metadata.current_page,$scope.totalItems=response._metadata.total,$scope.itemsPerPage=response._metadata.per_page,$scope.noOfPages=response._metadata.last_page),angular.isDefined(response.data)?$scope.projects=response.data:($scope.projects="",$scope.errorMessage="",angular.isDefined(response.error)&&($scope.errorMessage=response.error.message),$scope.currentPage=0,$scope.totalItems=0,$scope.itemsPerPage=0,$scope.noOfPages=0),$scope.loader=!1})},ProjectCategory.get(function(response){if(0===parseInt(response.error.code)){$scope.projectCategories=response.data,$scope.projectCat=[],$scope.data.category_select=[];var selectedProjectCat="";angular.isDefined($state.params.project_categories)&&(selectedProjectCat=$state.params.project_categories.split(",")),angular.forEach($scope.projectCategories,function(value){$scope.projectCat.push({id:value.id,text:value.name}),""!==selectedProjectCat&&-1!=selectedProjectCat.indexOf(value.id.toString())&&$scope.data.category_select.push({id:value.id,text:value.name})})}else console.log("Categories Error")},function(error){console.log("ProjectCategory Error",error)}),$scope.loadCategories=function(qstr){qstr=qstr.toLowerCase();var items=[];return angular.forEach($scope.projectCat,function(value){name=value.text.toLowerCase(),name.indexOf(qstr)>=0&&items.push({id:value.id,text:value.text})}),items};var params={};params.limit="all",ProjectSkills.get(params,function(response){if(0===parseInt(response.error.code)){$scope.projectSkill=[],$scope.projectSkills=response.data,$scope.data.skill_select=[];var selectedSkill="";angular.isDefined($state.params.skills)&&(selectedSkill=$state.params.skills.split(",")),angular.forEach($scope.projectSkills,function(value){$scope.projectSkill.push({id:value.id,text:value.name}),""!==selectedSkill&&-1!=selectedSkill.indexOf(value.id.toString())&&$scope.data.skill_select.push({id:value.id,text:value.name})})}else console.log("Skills Error")},function(error){console.log("Skills Error",error)}),$scope.loadSkills=function(qstr){qstr=qstr.toLowerCase();var items=[];return angular.forEach($scope.projectSkill,function(value){name=value.text.toLowerCase(),name.indexOf(qstr)>=0&&items.push({id:value.id,text:value.text})}),items},$scope.refinesearch=function(data){if(angular.isDefined(data.skill_select)&&Object.keys(data.skill_select).length>0){var skills=[];angular.forEach(data.skill_select,function(value){skills.push(value.id)}),data.skills=skills.toString()}else data.skills="";if(angular.isDefined(data.category_select)&&Object.keys(data.category_select).length>0){var categories=[];angular.forEach(data.category_select,function(value){categories.push(value.id)}),data.categories=categories.toString()}$scope.params={search:data.search,project_categories:data.categories,skills:data.skills,price_range_min:$scope.slider.min,price_range_max:$scope.slider.max},$state.go("Bid_Projects",$scope.params)},$scope.paginate=function(){$scope.currentPage=parseInt($scope.currentPage),$state.go("Bid_Projects",{page:$scope.currentPage}),$scope.getProjects()},$scope.index()}).controller("ProjectViewCtrl",function($scope,$rootScope,$state,$filter,$cookies,flash,ProjectEditView,ProjectStatusConstant,BidStatusConstant,md5,$window,FollowUser,FollowUserDelete,$timeout,$uibModal,$uibModalStack){$scope.ProjectStatusConstant=ProjectStatusConstant,$scope.isprojectcancel=!1,$scope.is_show_follow=!1,$rootScope.projectlike={},$scope.rating_value=0;var flashMessage;0===parseInt($state.params.error_code)&&(flashMessage=$filter("translate")("Payment successfully completed."),flash.set(flashMessage,"success",!1)),$scope.getProjectDetails=function(){ProjectEditView.get({id:$state.params.id,type:"view"},function(response){if(0===parseInt(response.error.code)){$scope.show_response_page=!0,$scope.project=response.data,$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("Project")+" - "+$scope.project.name,angular.isDefined($scope.project.user.attachment)&&null!==$scope.project.user.attachment?$scope.project.user.user_avatar_url="images/large_thumb/UserAvatar/"+$scope.project.user.id+"."+md5.createHash("UserAvatar"+$scope.project.user.id+"pnglarge_thumb")+".png":$scope.project.user.user_avatar_url="images/default.png",angular.isDefined($scope.project.follower)&&$scope.project.follower.length>0?(angular.forEach($scope.project.follower,function(follower){$rootScope.book_id=follower.id}),$scope.is_book=!0):$scope.is_book=!1;var skillsList=[];angular.forEach($scope.project.skills_projects,function(value){skillsList.push(value.skills.id)}),$rootScope.projectlike.skills=skillsList;var categoriesList=[];angular.forEach($scope.project.projects_project_categories,function(value){categoriesList.push(parseInt(value.project_category_id))}),$rootScope.projectlike.categories=categoriesList,($scope.project.is_cancel_request_freelancer != '0'||$scope.project.is_cancel_request_employer != '0')&&($scope.isprojectcancel=!0,$rootScope.broadCastDataempolyer={notes:$scope.project.mutual_cancel_note},$rootScope.broadCastDatafreelancer={notes:$scope.project.mutual_cancel_note},$scope.is_freelancer=!1,$rootScope.broadCastDatafreelancer.is_show_accept=!$scope.is_freelancer&&$scope.project.is_cancel_request_employer?!1:!0,$rootScope.broadCastDatafreelancer.userinfo=$scope.project.project_bid.user.username,$rootScope.broadCastDatafreelancer.userImage=$scope.project.bid_winner.user.attachment,$rootScope.broadCastDatafreelancer.userId=$scope.project.project_bid.user.id,$rootScope.broadCastDatafreelancer.createdAt=$scope.project.created_at,$scope.is_freelancer=!0,$rootScope.broadCastDataempolyer.is_show_accept=$scope.is_freelancer&&$scope.project.is_cancel_request_freelancer?!1:!0,$rootScope.broadCastDataempolyer.userinfo=$scope.project.user.username,$rootScope.broadCastDataempolyer.userImage=$scope.project.user.attachment,$rootScope.broadCastDataempolyer.userId=$scope.project.user.id,$rootScope.broadCastDataempolyer.createdAt=$scope.project.created_at),parseInt($rootScope.user.id)===parseInt(response.data.user_id)?$scope.project_user=!0:($scope.project_user=!1,angular.isDefined($scope.project.owner_bid)&&null!==$scope.project.owner_bid&&Object.keys($scope.project.owner_bid.length>0)&&!$scope.project.owner_bid.is_freelancer_withdrawn?$scope.is_already_bidded=!0:$scope.is_already_bidded=!1,void 0!==$state.params.edit&&($scope.is_already_bidded=!1,$scope.is_bid_edit=!0)),parseInt($scope.project.project_status_id)>$scope.ProjectStatusConstant.OpenForBidding&&(parseInt($rootScope.user.id)===parseInt($scope.project.freelancer_user_id)?$scope.bid_lost=!1:$scope.bid_lost=!0);var listbroadcastData={is_show_lost:parseInt($rootScope.user.id)===parseInt($scope.project.freelancer_user_id)||parseInt($rootScope.user.id)===parseInt($scope.project.user_id)?!1:!0},isbookshow={projectid:$scope.project.id,isbook:$scope.is_book};$timeout(function(){$scope.$broadcast("showlostbids",listbroadcastData),$scope.$broadcast("showisbook",isbookshow),$scope.projectbidcount=response.data.project_bid.bid_count},2e3)}},function(error){console.log(error)})},$scope.getProjectDetails(),$scope.closeInstance=function(){$uibModalStack.dismissAll()},$scope.follow=function(){var flashMessage="";Object.keys($scope.project.user.follower).length>0?FollowUserDelete["delete"]({id:$scope.project.user.follower[0].id},function(response){0===response.error.code?(flashMessage=$filter("translate")("Unfollowed successfully"),flash.set(flashMessage,"success",!1),$scope.followBtn="Follow",$scope.getProjectDetails()):(flashMessage=$filter("translate")("Could not unfollow"),flash.set(flashMessage,"error",!1))}):FollowUser.post({foreign_id:$scope.project.user_id,"class":"User"},function(response){0===response.error.code?(flashMessage=$filter("translate")("Followed successfully."),flash.set(flashMessage,"success",!1),$scope.getProjectDetails(),$scope.followBtn="Unfollow"):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1))})},$scope.$on("is_show_follow",function(event,data){"showfollow"===data&&($scope.followBtn="Follow",Object.keys($scope.project.user.follower).length>0&&($scope.followBtn="Unfollow"),$scope.is_show_follow=!0)})}).controller("MyProjectsCtrl",function($scope,$rootScope,$state,$filter,flash,MyProjects,DelProject,ProjectStatus,ProjectStatusConstant,ProjectStatusUpdate){$scope.projectConstant=ProjectStatusConstant,$scope.index=function(){$scope.GetProjectStatus()},$scope.GetProjectStatus=function(){ProjectStatus.get(function(response){0===parseInt(response.error.code)&&($scope.projectStatus=response.data)},function(error){console.log(error)})},$scope.getProjects=function(tabType){2===tabType?(void 0===$state.params.status||"payment_pending"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"payment_pending"},{notify:!1}):1===tabType?(void 0===$state.params.status||"draft"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"draft"},{notify:!1}):3===tabType?(void 0===$state.params.status||"pending_approval"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"pending_approval"},{notify:!1}):4===tabType?(void 0===$state.params.status||"open_bidding"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"open_bidding"},{notify:!1}):5===tabType?(void 0===$state.params.status||"close_expiry"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"close_expiry"},{notify:!1}):6===tabType?(void 0===$state.params.status||"winner_selected"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"winner_selected"},{notify:!1}):11===tabType?(void 0===$state.params.status||"under_development"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"under_development"},{notify:!1}):14===tabType?(void 0===$state.params.status||"final_review"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"final_review"},{notify:!1}):16===tabType?(void 0===$state.params.status||"closed"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"closed"},{notify:!1}):13===tabType?(void 0===$state.params.status||"admin_cancel"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"admin_cancel"},{notify:!1}):12===tabType?(void 0===$state.params.status||"cancel"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"cancel"},{notify:!1}):(void 0===$state.params.status||"payment_pending"!==$state.params.status)&&$state.go("Bid_MeProjects",{status:"payment_pending"},{notify:!1}),1===parseInt(tabType)?$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("Open Project"):2===parseInt(tabType)?$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("Work in Progress"):$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("Past Project"),$scope.params={project_status_id:tabType},$scope.StatusFilter=function(id){$scope.params={project_status_id:id}},MyProjects.get($scope.params,function(response){0===parseInt(response.error.code)&&($scope.projects=response.data)},function(error){console.log(error)})},$state.params.status?"draft"===$state.params.status?($scope.activeStatus=1,$scope.getProjects(1)):"pending_approval"===$state.params.status?($scope.activeStatus=2,$scope.getProjects(3)):"open_bidding"===$state.params.status?($scope.activeStatus=3,$scope.getProjects(4)):"close_expiry"===$state.params.status?($scope.activeStatus=4,$scope.getProjects(5)):"winner_selected"===$state.params.status?($scope.activeStatus=5,$scope.getProjects(6)):"under_development"===$state.params.status?($scope.activeStatus=6,$scope.getProjects(11)):"final_review"===$state.params.status?($scope.activeStatus=7,$scope.getProjects(14)):"closed"===$state.params.status?($scope.activeStatus=8,$scope.getProjects(16)):"admin_cancel"===$state.params.status?($scope.activeStatus=9,$scope.getProjects(13)):"cancel"===$state.params.status?($scope.activeStatus=10,$scope.getProjects(10)):($scope.activeStatus=0,$scope.getProjects(2)):$scope.getProjects(2),$scope.deleteProject=function(project_id){swal({title:$filter("translate")("Are you sure you want to delete?"),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel!",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){DelProject["delete"]({id:project_id},function(response){0===response.error.code?(flashMessage=$filter("translate")("Your project has been deleted successfully."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Your project couldn't deleted. Please try again."),flash.set(flashMessage,"error",!1),$state.reload())})})},$scope.cancelProject=function(project_id){swal({title:$filter("translate")("Are you sure you want to cancel this project?"),type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){ProjectStatusUpdate.put({id:project_id,project_status_id:$scope.projectConstant.EmployerCanceled},function(response){0===response.error.code?(flashMessage=$filter("translate")("Your project has been cancelled successfully."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Your project couldn't cancelled. Please try again."),flash.set(flashMessage,"error",!1),$state.reload())})})},$scope.index()}),angular.module("getlancerApp.Bidding.Constant",[]).constant("DateFormat",{view:"MMM dd",created_12:"yyyy-MM-dd HH:mm",created_24:"yyyy-MM-dd hh:mma",created:"yyyy-MM-dd",title:"MMMM dd, yyyy hh:mma (EEEE)"}).constant("ClassName",{invoice:"Invoice",milestone:"Milestone",project:"Project"}).constant("FileFormat",{image:["jpg","gif","png","jpeg","bmp"],resume:["doc","docx","pdf","rtf","odt","docm","dot","txt"],project:["doc","docx","pdf","rtf","odt","docm","dot","txt","jpg","gif","png","jpeg"]}).constant("BidStatusConstant",{Pending:1,Won:2,Lost:3}).constant("BiddingMsgClass",{"class":"Bid",type:"inbox"}).constant("BiddingfileClass",{"class":"Project"}).constant("ExamStatusConstant",{Inprogress:1,Incomplete:2,Passed:3,Failed:4,ExamFeePaymentPending:5,FeePaidNotStarted:6,SuspendedDuetoTakingOvertime:7}).constant("PerDayExam",{NumOfTime:"2"}).constant("DisputeMsgClass",{"class":"ProjectDispute"}).constant("DisputeStatusConstant",{Open:1,UnderDiscussion:2,WaitingforAdministratorDecision:3,Closed:4}),angular.module("getlancerApp.Bidding").directive("fileDownload",function(md5,$location,$timeout){var directive={restrict:"EA",template:'',scope:{attachment:"@",downloadlable:"@"},link:function(scope,element,attrs){scope.attachment=JSON.parse(scope.attachment);var download_file=md5.createHash(scope.attachment["class"]+scope.attachment.foreign_id+"docdownload")+".doc";scope.downloadUrl=$location.protocol()+"://"+$location.host()+"/download/"+scope.attachment["class"]+"/"+scope.attachment.foreign_id+"/"+download_file+"/"+scope.attachment.id,void 0===scope.downloadlable&&(scope.downloadlable='')}};return directive}).directive("numberOnly",function(){return{restrict:"EA",link:function(scope,elem,attr,ctrl){elem.bind("keyup",function(e){var text=this.value;this.value=text.replace(/[a-zA-Z]/g,"")})}}}).directive("biddingList",function(){return{restrict:"EA",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_list.html",scope:{project:"@",projectuser:"@",projectstatus:"@",hiddienbid:"@",isbid:"@",projectbidid:"@",isprojectcancel:"@",isdispute:"@"},controller:function($rootScope,$scope,$filter,$state,$timeout,ProjectBids,ProjectStatusConstant,BidStatusConstant,AwardedBids,md5,$cookies,ProjectEditView,anchorSmoothScroll,ConstUserRole,$anchorScroll,$uibModal,flash){$scope.ConstUserRole=ConstUserRole,$scope.ProjectStatusConstant=ProjectStatusConstant,$scope.project_is_dispute=($scope.isdispute == "0")?false:true,$scope.auth=JSON.parse($cookies.get("auth")),parseInt($scope.auth.id)!==parseInt($scope.projectuser)?$scope.is_freelancer=!0:$scope.is_freelancer=!1,"withdraw"===$state.params.action?$rootScope.withdrawthisfreelancer=!0:$rootScope.withdrawthisfreelancer=!1,$scope.focusPortfolio=function(profile_user_id,profile_user_name){$state.go("user_profiles",{id:profile_user_id,slug:profile_user_name,portfolio:"portfolios"})},$scope.contactFreelancer=function(projectbidid,messagecount){$rootScope.message_bid_id=projectbidid,$scope.modalInstance=$uibModal.open({templateUrl:"scripts/plugins/Bidding/Bidding/views/default/contact_freelancer.html",animation:!1,controller:function($scope,$rootScope,$window,$stateParams,$filter,md5,$state,Upload,$timeout,$uibModal,$uibModalStack,Messages,biduser,authuser,ProjectBids){var flashMessage="";$scope.MessagePage=1,$rootScope.closemodel=function(){$uibModalStack.dismissAll()},$scope.contact_freelancer=!1,$scope.data={},$scope.ContactMessages=[];({id:$stateParams.id,is_freelancer_withdrawn:!1});$rootScope.messagecount=messagecount,$scope.submit=function($valid){if($valid){$scope.contact_freelancer=!0;var contactData={};contactData.foreign_id=projectbidid,contactData.to_user_id=biduser,contactData.message=$scope.data.message,contactData["class"]="Bid",contactData.subject=$state.params.slug,Messages.post(contactData,function(response){$scope.contact_freelancer=!1,0===response.error.code?(flashMessage=$filter("translate")("Message sent successfully."),flash.set(flashMessage,"success",!1),$scope.data.message="",$scope.Contactfrm.$setPristine(),$scope.Contactfrm.$setUntouched(),$scope.ContactMessages=[],"0"===$rootScope.messagecount&&$state.reload(),$scope.MessagePage=1,$scope.GetConactMessage(),$scope.contact_freelancer=!1):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1))})}},$scope.GetConactMessage=function(){var conactparams={};conactparams.foreign_id=$rootScope.message_bid_id,conactparams.limit=5,conactparams.sortby="desc",conactparams["class"]="Bid",conactparams.page=$scope.MessagePage,Messages.get(conactparams,function(response){angular.isDefined(response.data)&&(angular.isDefined(response._metadata)&&($scope.messageNoOfPages=response._metadata.last_page,$scope.ConactmessageTotal=response._metadata.total-response._metadata.current_page*response._metadata.per_page),0===parseInt(response.error.code)?angular.forEach(response.data,function(value){angular.isDefined(value.user.attachment)&&null!==value.user.attachment?value.user.user_avatar_url="images/big_thumb/UserAvatar/"+value.user.id+"."+md5.createHash("UserAvatar"+value.user.id+"pngbig_thumb")+".png":value.user.user_avatar_url="images/default.png",$scope.ContactMessages.push(value)}):$scope.ContactMessages=[])})},$scope.contactmessage_pagination=function(){$scope.MessagePage=parseInt($scope.MessagePage)+1,$scope.GetConactMessage()},$scope.GetConactMessage()},size:"lg",resolve:{biduser:function(){return $scope.biduser},authuser:function(){return $scope.auth.id}}})},$scope.showLoader=!0,$scope.awardLoader=!0,$scope.is_awarded=!1,$scope.biddings=[],$scope.mutual_cancel=!1,$scope.project_dispute=!1,$scope.project_review=!1,"mutual_cancel"===$state.params.action?($scope.mutual_cancel=!0,$timeout(function(){$anchorScroll("mutual-cancel")},2500)):"dispute"===$state.params.action?($scope.project_dispute=!0,$timeout(function(){$anchorScroll("dispute-block")},2500)):"review-form"===$state.params.action&&($scope.project_review=!0,$timeout(function(){$anchorScroll("update")},2500)),$timeout(function(){if(parseInt($scope.projectstatus)>=parseInt(ProjectStatusConstant.WinnerSelected))$scope.is_awarded=!0,$rootScope.getData=function(){if($scope.is_show_lost||ProjectStatusConstant.Closed){var params={id:$scope.project};parseInt($scope.auth.id)!==parseInt($scope.projectuser)?"false"===$scope.hiddienbid?($scope.otherBids(),$scope.userbids(params),$scope.hiddienbidShow=!0):($scope.biddings=[],$scope.hiddienbidShow=!1):($scope.hiddienbidShow=!0,$scope.otherBids(),$scope.userbids(params))}},$rootScope.getData(),AwardedBids.get({id:$scope.project,status:BidStatusConstant.Won,project_bid_id:$scope.projectbidid},function(response){0===parseInt(response.error.code)?($scope.awarded=response.data,angular.forEach($scope.awarded,function(value){angular.isDefined(value.user.attachment)&&null!==value.user.attachment?value.user.user_avatar_url="images/big_thumb/UserAvatar/"+value.user.id+"."+md5.createHash("UserAvatar"+value.user.id+"pngbig_thumb")+".png":value.user.user_avatar_url="images/default.png",$scope.project_failed_count=Number(value.user.project_failed_count||0),$scope.project_completed_count=Number(value.user.project_completed_count||0),$scope.total_count=$scope.project_failed_count+$scope.project_completed_count,$scope.mul=$scope.project_completed_count/$scope.total_count,value.completetion_rate=100*$scope.mul,value.rating_count=Number(Math.round(value.user.total_rating_as_freelancer/value.user.review_count_as_freelancer)||0)}),void 0!==$scope.awarded[0]&&parseInt($scope.auth.id)===parseInt($scope.awarded[0].user_id)?$rootScope.bid_awarded=!1:$rootScope.bid_awarded=!0,!$rootScope.bid_awarded&&$scope.is_freelancer&&$scope.$emit("is_show_follow","showfollow")):$scope.awarded=[],$scope.awardLoader=!1},function(error){console.log("Bidding List Directive",error)});else{var params={};"false"!==$scope.hiddienbid?parseInt($scope.auth.id)===parseInt($scope.projectuser)?(params={id:$scope.project,is_freelancer_withdrawn:!1},$scope.userbids(params),$scope.hiddienbidShow=!0):($scope.isbid?(params={id:$scope.project,user_id:$scope.auth.id,is_freelancer_withdrawn:!1},$scope.userbids(params)):($scope.biddings=[],params={id:$scope.project,user_id:$scope.auth.id,is_freelancer_withdrawn:!1},$scope.userbids(params)),$scope.hiddienbidShow=!0):($scope.hiddienbidShow=!0,params={id:$scope.project,is_freelancer_withdrawn:!1},$scope.userbids(params))}},2e3),$scope.$on("showlostbids",function(event,data){$scope.is_show_lost=data.is_show_lost}),$scope.userbids=function(params){params.project_id=$state.params.id,ProjectBids.get(params,function(response){0===parseInt(response.error.code)?($scope.biddings=response.data,angular.forEach($scope.biddings,function(value){void 0!==value.exams_users&&(0!=value.exams_users.length&&($scope.exam_users=value.exams_users,angular.forEach($scope.exam_users,function(exams){if($scope.total_mark=Number(exams.total_mark||0),$scope.total_question_count=Number(exams.total_question_count||0),$scope.average=$scope.total_mark/$scope.total_question_count,exams.exam_user_per=parseInt(100*$scope.average),angular.isDefined(exams.exam.attachment)&&null!==exams.exam.attachment){md5.createHash("Exam"+exams.exam.attachment.foreign_id+"pngsmall_normal_thumb");exams.exam_image="images/small_normal_thumb/Exam/"+exams.exam.attachment.foreign_id+"."+md5.createHash("Exam"+exams.exam.attachment.foreign_id+"pngsmall_normal_thumb")+".png"}else exams.exam_image="images/no-image.png"})),angular.isDefined(value.user.attachment)&&null!==value.user.attachment?value.user.user_avatar_url="images/big_thumb/UserAvatar/"+value.user.id+"."+md5.createHash("UserAvatar"+value.user.id+"pngbig_thumb")+".png":value.user.user_avatar_url="images/default.png",value.rating_count=Number(Math.round(value.user.total_rating_as_freelancer/value.user.review_count_as_freelancer)||0),$scope.project_failed_count=Number(value.user.project_failed_count||0),$scope.project_completed_count=Number(value.user.project_completed_count||0),$scope.total_count=$scope.project_failed_count+$scope.project_completed_count,$scope.mul=$scope.project_completed_count/$scope.total_count,value.completetion_rate=100*$scope.mul)}),$rootScope.scrollBids===!0&&$timeout(function(){$anchorScroll("bidsAll")},100)):$scope.biddings=[],$scope.showLoader=!1},function(error){console.log("Bidding List Directive",error)})},$scope.otherBids=function(){AwardedBids.get({id:$scope.project,status:BidStatusConstant.Lost,project_bid_id:$scope.projectbidid},function(response){0===parseInt(response.error.code)?($scope.biddings=response.data,angular.forEach($scope.biddings,function(value){angular.isDefined(value.user.attachment)&&null!==value.user.attachment?value.user.user_avatar_url="images/big_thumb/UserAvatar/"+value.user.id+"."+md5.createHash("UserAvatar"+value.user.id+"pngbig_thumb")+".png":value.user.user_avatar_url="images/default.png"})):$scope.biddings=[],$scope.showLoader=!1},function(error){console.log("Bidding List Directive",error)})},$scope.$on("choosenewfreelancer",function(event,data){$scope.choosenewfreelancer=!0}),$scope.showhideSkills=function(id,is_show){var skillId="skills-"+id;1===parseInt(is_show)?$("#"+skillId).attr("style","display:block"):$(".user-certificate-skills").attr("style","display:none")};var getParams={id:$state.params.id,fields:"id,project_status_id,is_dispute,is_cancel_request_freelancer,is_cancel_request_employer,user_id"};ProjectEditView.get(getParams,function(response){null!=response.data.bid_winner&&($scope.AwardedUserId=response.data.bid_winner.user_id,$rootScope.other_user_reviews=response.data.other_user_reviews),$rootScope.project_is_dispute=response.data.is_dispute,$scope.projectbidcount=response.data.project_bid.bid_count,$scope.projectbidcount>"1"&&($rootScope.newFreelancerSelect=!0),response.data.project_status_id==ProjectStatusConstant.FinalReviewPending&&ProjectStatusConstant.Closed?$rootScope.reviewShow=!0:$rootScope.reviewShow=!1,$scope.reviewsLists=response.data.reviews,$rootScope.userReview=!0;var sucesscount=0;angular.forEach($scope.reviewsLists,function(reviewList){angular.isDefined(reviewList.user.attachment)&&null!==reviewList.user.attachment?reviewList.user.user_avatar_url="images/big_thumb/UserAvatar/"+reviewList.user.id+"."+md5.createHash("UserAvatar"+reviewList.user.id+"pngbig_thumb")+".png":reviewList.user.user_avatar_url="images/default.png",1>sucesscount&&(reviewList.user_id==$rootScope.user.id?($rootScope.userReview=!1,sucesscount++):$rootScope.userReview=!0);
})}),"withdraw"===$state.params.action&&$timeout(function(){$anchorScroll("withdaw_scroll")},1e3)}}}).directive("biddingPost",function(){return{restrict:"EA",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_add.html",scope:{project:"@"},controller:function($rootScope,$scope,$state,$filter,$timeout,$location,flash,BidPost,BidUpdate,EditBid,$cookies,UserFactory){$scope.buttonText="Place Bid",$scope.showInfo=!0;var absUrl=$location.absUrl().split("?");$state.params.placebid?($rootScope.is_bid_enable=!0,$scope.is_bid_enable=!0):($rootScope.is_bid_enable=!1,$scope.is_bid_enable=!1),$rootScope.bidProject=function(){$rootScope.is_bid_enable=!0,$scope.is_bid_enable=!0;var params=$state.params;params.placebid=!0,$state.go("Bid_ProjectView",params)},$scope.cancleBid=function(){$rootScope.is_bid_enable=!1,$scope.is_bid_enable=!1,window.location.href=absUrl[0]},UserFactory.get({},function(response){$scope.available_credit_count=parseInt(response.data.available_credit_count)}),$timeout(function(){void 0!==$state.params.edit?($scope.buttonText="Update Bid",$scope.showInfo=!1,$scope.auth=JSON.parse($cookies.get("auth")),$scope.data={},EditBid.get({id:$scope.project,user:$scope.auth.id},function(response){$scope.showLoader=!1,0===parseInt(response.error.code)&&($scope.editBidId=parseInt(response.data[0].id),$scope.data={amount:parseInt(response.data[0].amount),duration:parseInt(response.data[0].duration),description:response.data[0].description})},function(error){console.log("Bidding List Directive",error)})):$scope.buttonText="Place Bid"},1e3),$scope.data={},$scope.save_btn=!1,$scope.postBid=function($valid,data){$valid&&($scope.save_btn=!0,data.project_id=$scope.project,void 0===$state.params.edit?BidPost.post(data,function(response){$scope.save_btn=!1;var flashMessage="";0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Bid posted successfully."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1),$scope.save_btn=!1)},function(error){console.log("Bidding Directive",error)}):BidUpdate.put({id:$scope.editBidId},data,function(response){var flashMessage="";0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Bid updated successfully."),flash.set(flashMessage,"success",!1),$state.go("Bid_ProjectView",{id:$state.params.id,slug:$state.params.slug,placebid:"",edit:""},{notify:!0})):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1))}))}}}}).directive("biddingActions",function(){return{restrict:"EA",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_actions.html",scope:{bidid:"@",project:"@",biduser:"@",projectuser:"@",projectstatus:"@",reopenbid:"@"},controller:function($rootScope,$scope,$state,$filter,$location,flash,$timeout,$cookies,BidRetake,UpdateBidStatus,BidStatusConstant,ProjectStatusConstant,$uibModal){$scope.project_closed=ProjectStatusConstant.Closed,$scope.auth=JSON.parse($cookies.get("auth")),$state.params.placebid?$scope.is_bid_enable=!0:$scope.is_bid_enable=!1,parseInt($scope.projectstatus)>parseInt(ProjectStatusConstant.WinnerSelected)?($scope.is_disable_select_winner=!0,$rootScope.bid_awarded=!0,$rootScope.contact_winner=!0):parseInt($scope.projectstatus)===parseInt(ProjectStatusConstant.WinnerSelected)?($scope.is_disable_select_winner=!1,$rootScope.bid_awarded=!1,$rootScope.contact_winner=!1):($scope.is_disable_select_winner=!1,$rootScope.bid_awarded=!1,$rootScope.contact_winner=!0),parseInt($scope.auth.id)!==parseInt($scope.projectuser)?$scope.is_freelancer=!0:$scope.is_freelancer=!1,$scope.editBid=function(){$scope.is_bid_enable=!0;var params=$state.params;params.placebid=!0,params.edit=!0,$state.go("Bid_ProjectView",params)},$scope.data={},$scope.retakeBid=function(){swal({title:$filter("translate")("Are you sure you want to withdraw this bid?"),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){if(isConfirm){var flashMessage="",params={};params.is_freelancer_withdrawn=1,BidRetake.put({id:$scope.bidid},params,function(response){if(0===response.error.code){flashMessage=$filter("translate")("Your bid withdrawn successfully."),flash.set(flashMessage,"success",!1);var params=$state.params;params.placebid=!0,$state.go("Bid_ProjectView",params)}else flashMessage=$filter("translate")("Please try again."),flash.set(flashMessage,"error",!1)})}})},$scope.selectWinner=function(){swal({title:$filter("translate")("Are you sure you want to select this expert as a winner?"),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){if(isConfirm){var flashMessage="";if(void 0!==$scope.reopenbid)var updateParams={id:$scope.bidid,bid_status_id:BidStatusConstant.Won,new_winer_bid_id:$scope.bidid};else var updateParams={id:$scope.bidid,bid_status_id:BidStatusConstant.Won};UpdateBidStatus.put(updateParams,function(response){0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Winner selected successfully"),flash.set(flashMessage,"success",!1),$state.go("Bid_ProjectView",{id:$state.params.id,slug:$state.params.slug,action:""},{reload:!0})):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1))},function(error){console.log(error)})}})}}}}).directive("biddingAwarded",function(){return{restrict:"EA",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_awarded.html",replace:"true",scope:{bidid:"@",project:"@",projectuser:"@",projectstatus:"@",windate:"@"},controller:function($scope,$rootScope,$state,$timeout,$cookies,$filter,flash,UpdateProjectStatus,ProjectStatusConstant,UpdateBidStatus,ProjectEditView){$scope.auth=JSON.parse($cookies.get("auth")),$scope.choosenewfreelancer=!1,parseInt($scope.projectstatus)===ProjectStatusConstant.WinnerSelected&&(moment($scope.windate).add($rootScope.settings.PROJECT_WITHDRAW_FREELANCER_DAYS,"days").unix()<=moment().unix()?$scope.is_hide_action=!1:$scope.is_hide_action=!0),parseInt($scope.projectuser)===parseInt($scope.auth.id)?$scope.is_freelancer=!1:$scope.is_freelancer=!0,$scope.awardedprocess=function(ftype){var alertTitle="";1===parseInt(ftype)?alertTitle=$filter("translate")("Are you sure you want to accept this project?"):2===parseInt(ftype)&&(alertTitle=$filter("translate")("Are you sure you want to reject this project?")),swal({title:alertTitle,text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){if(isConfirm){var flashMessage="";if(1===parseInt(ftype))UpdateProjectStatus.put({id:$scope.project,project_status_id:ProjectStatusConstant.UnderDevelopment},function(response){0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Project successfully accepted and moved under developement status."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Check your wallet"),flash.set(flashMessage,"error",!1))},function(error){console.log(error)});else{var params={};params.id=$scope.bidid,UpdateBidStatus.put(params,{is_offered_rejected:1},function(response){0===parseInt(response.error.code)?(flashMessage=$filter("translate")("You are successfully ignore this project request."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Project couldn't rejected. Please try again."),flash.set(flashMessage,"error",!1))},function(error){console.log("BiddingAwardDirective",error)})}}})},ProjectEditView.get({id:$state.params.id},function(response){$scope.biddinglist=response.data,$scope.bidEndDate=$scope.biddinglist.bid_winner.is_reached_response_end_date_for_freelancer}),$scope.reopen=function(rtype){swal({title:1===parseInt(rtype)?$filter("translate")("Are you sure you want to choose a new expert?"):$filter("translate")("Are you sure you want to reopen this project?"),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){isConfirm&&(1===parseInt(rtype)?($state.go("Bid_ProjectView",{id:$state.params.id,slug:$state.params.slug,action:"withdraw"},{reload:!0}),$scope.choosenewfreelancer=!0,$scope.$emit("choosenewfreelancer","true")):UpdateProjectStatus.put({id:$scope.project,project_status_id:ProjectStatusConstant.OpenForBidding,withdraw_bid_id:$scope.bidid},function(response){0===parseInt(response.error.code)?(flash.set($filter("translate")("Project reopen successfully"),"success",!1),$state.reload()):flash.set($filter("translate")("Project reopen failed"),"error",!1)}))})}}}}).directive("biddingAwardedTabs",function(){return{restrict:"EA",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_awarded_tabs.html",scope:{bidid:"@",project:"@",projectuser:"@",projectstatus:"@",isdispute:"@"},controller:function($scope,$rootScope,$timeout,$state,$cookies,$filter,flash,md5,ProjectStatusConstant,Messages,Upload,Invoice,BiddingMsgClass,FileFormat,BiddingfileClass,Files,MilestoneStatusConstant,biddingProjectTransactions,TransactionUserMessage){$scope.TransactionUserMessage=TransactionUserMessage,$scope.project_is_dispute=($scope.isdispute == "0")?false:true,$scope.ProjectStatusConstant=ProjectStatusConstant,$scope.BiddingMsgClass=BiddingMsgClass,$scope.FileFormat=FileFormat,$scope.messages=[],$scope.MessagePage=1,$scope.projectBid={id:$state.params.id,slug:$state.params.slug,action:$state.params.action},$scope.renderpage="",$scope.auth=JSON.parse($cookies.get("auth")),parseInt($scope.projectuser)===parseInt($scope.auth.id)?$scope.is_freelancer=!1:$scope.is_freelancer=!0,$scope.selectedTab=function(tabSelected){if($scope.projectBid.action=tabSelected,$scope.is_show_loader=!0,$scope.buttonName=$scope.is_freelancer===!0?"Request Milestone":"Create Milestone","messages"===tabSelected)$scope.MessagePage=1,$scope.renderpage="scripts/plugins/Bidding/Bidding/views/default/bidding_message.html",(void 0===$state.params.action||"messages"!==$state.params.action)&&$state.go("Bid_ProjectView",$scope.projectBid,{notify:!1}),$scope.data={},$scope.message_Frm=!1,$scope.PostMessages=function(messageFrm,$valid){var msgparams={"class":$scope.BiddingMsgClass["class"],foreign_id:$scope.bidid};$valid&&($scope.message_Frm=!0,msgparams.parent_id=0,msgparams.subject="Project Bidding Message",msgparams.message=$scope.data.message,msgparams.image=$scope.file,delete msgparams.type,Messages.post(msgparams,function(response){var flashMessage="";0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Message sent successfully."),flash.set(flashMessage,"success",!1),$scope.data.message="",$scope.messages=[],$scope.MessagePage=1,$scope.GetMessages(),messageFrm.$setPristine(),messageFrm.$setUntouched()):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1),$scope.message_Frm=!1)}))},$scope.GetMessages=function(){var msgparams={"class":$scope.BiddingMsgClass["class"],foreign_id:$scope.bidid,limit:10,page:$scope.MessagePage,sortby:"desc"};$scope.message_Frm=!1,Messages.get(msgparams,function(response){angular.isDefined(response.data)&&(angular.isDefined(response._metadata)&&($scope.messageNoOfPages=response._metadata.last_page,$scope.messageTotal=response._metadata.total-response._metadata.current_page*response._metadata.per_page),0===parseInt(response.error.code)?($scope.loadmore===!1&&($scope.messages=[]),angular.forEach(response.data,function(value){angular.isDefined(value.user.attachment)&&null!==value.user.attachment?value.user.user_avatar_url="images/big_thumb/UserAvatar/"+value.user.id+"."+md5.createHash("UserAvatar"+value.user.id+"pngbig_thumb")+".png":value.user.user_avatar_url="images/default.png",$scope.messages.push(value)})):$scope.messages=[])})},$scope.message_pagination=function(){$scope.loadmore=!0,$scope.MessagePage=parseInt($scope.MessagePage)+1,$scope.GetMessages()},$scope.GetMessages();else if("invoices"===tabSelected)$scope.loadmore=!1,$scope.renderpage="scripts/plugins/Bidding/Invoice/views/default/bidding_invoice.html",(void 0===$state.params.action||"invoices"!==$state.params.action)&&$state.go("Bid_ProjectView",$scope.projectBid,{notify:!1}),$scope.invoiceparams={bid_id:$scope.bidid};else if("files"===tabSelected)$scope.loadmore=!1,$scope.renderpage="scripts/plugins/Bidding/Bidding/views/default/bidding_files.html",$scope.is_show_upload_form=!1,$scope.showUpload=function(val){val===!1?$scope.is_show_upload_form=!0:$scope.is_show_upload_form=!1},(void 0===$state.params.action||"files"!==$state.params.action)&&$state.go("Bid_ProjectView",$scope.projectBid,{notify:!1}),$scope.BiddingfileClass=BiddingfileClass,$scope.GetFiles=function(){Files.get({project_id:$scope.project},function(response){0===parseInt(response.error.code)?$scope.ProjectFiles=response.data:$scope.ProjectFiles=[]})},$scope.uploadFile=function(file){Upload.upload({url:"/api/v1/attachments?class=Project",data:{file:file}}).then(function(response){0===response.data.error.code?($scope.uploadfile=response.data.attachment,$scope.error_message=""):$scope.error_message=response.data.error.message})},$scope.file_Frm=!1,$scope.PostFiles=function($fileValid,fileFrm){if($fileValid&!$scope.error_message){$scope.file_Frm=!0;var flashMessage="";$scope.projectfile={},$scope.projectfile.files=[{file:$scope.uploadfile}],$scope.projectfile["class"]=$scope.BiddingfileClass["class"],$scope.projectfile.project_id=$scope.project,Files.post($scope.projectfile,function(response){if($scope.response=response,0===parseInt($scope.response.error.code)){$scope.file_Frm=!1,flashMessage=$filter("translate")("File added successfully."),flash.set(flashMessage,"success",!1),fileFrm.$setPristine(),fileFrm.$setUntouched(),$scope.GetFiles(),$scope.is_show_upload_form=!1;var myEl=angular.element(document.querySelector("#resetAttr")),myFileName=angular.element(document.querySelector("#resetFile"));myFileName.empty(),myEl.removeAttr("src"),myEl.removeAttr("title"),myEl.removeAttr("alt")}else flashMessage=$filter("translate")($scope.response.error.message),flash.set(flashMessage,"error",!1),fileFrm.$setPristine(),fileFrm.$setUntouched(),$scope.file_Frm=!1})}},$scope.GetFiles();else if("activities"===tabSelected)$scope.loadmore=!1,$scope.renderpage="scripts/plugins/Bidding/Bidding/views/default/bidding_activities.html",$scope.is_show_upload_form=!1,$scope.showUpload=function(val){val===!1?$scope.is_show_upload_form=!0:$scope.is_show_upload_form=!1},(void 0===$state.params.action||"activities"!==$state.params.action)&&$state.go("Bid_ProjectView",$scope.projectBid,{notify:!1});else if("transactions"===tabSelected)$scope.loadmore=!1,$scope.renderpage="scripts/plugins/Bidding/Bidding/views/default/bidding_transactions.html",$scope.is_show_upload_form=!1,$scope.showUpload=function(val){val===!1?$scope.is_show_upload_form=!0:$scope.is_show_upload_form=!1},(void 0===$state.params.action||"transactions"!==$state.params.action)&&$state.go("Bid_ProjectView",$scope.projectBid,{notify:!1}),$scope.currentPageTransaction=1,$scope.GetTransactions=function(){var params={};biddingProjectTransactions.get({user_id:$rootScope.user.id,model_id:$state.params.id,model_class:"Project",page:$scope.currentPageTransaction,limit:10},function(response){$scope.currentPage=params.page,angular.isDefined(response._metadata)&&($scope.totalItems=response._metadata.total,$scope.itemsPerPage=response._metadata.per_page,$scope.noOfPages=response._metadata.last_page,$scope.currentPageTransaction=response._metadata.current_page),angular.forEach(response.data,function(value){var trans=value.transaction_type,exam={},project={},job={},commission={},subscription={},payment_gateway={};if($rootScope.isAuth===!0&&1===$rootScope.user.id?($scope.transaction_messages=$scope.TransactionAdminMessage[parseInt(trans)],value.transactionAmount={credit:value.amount,debit:"--"}):$rootScope.isAuth===!0&&("5"===trans&&$rootScope.Freelancer&&"0"!==value.site_revenue_from_freelancer?$scope.transaction_messages=$scope.TransactionUserMessage[22]:"7"===trans&&$rootScope.Freelancer&&"0"===value.site_revenue_from_freelancer?$scope.transaction_messages=$scope.TransactionUserMessage[parseInt(24)]:"6"===trans&&$rootScope.Freelancer&&"0"===value.site_revenue_from_freelancer?$scope.transaction_messages=$scope.TransactionUserMessage[parseInt(25)]:"5"===trans&&$rootScope.Freelancer&&"0"===value.site_revenue_from_freelancer?$scope.transaction_messages=$scope.TransactionUserMessage[23]:"7"===trans&&$rootScope.Employer&&"0"===value.site_revenue_from_employer?$scope.transaction_messages=$scope.TransactionUserMessage[24]:"7"===trans&&$rootScope.Employer&&"0"!==value.site_revenue_from_employer?$scope.transaction_messages=$scope.TransactionUserMessage[parseInt(trans)]:"5"===trans&&$rootScope.Employer&&"0"===value.site_revenue_from_employer?$scope.transaction_messages=$scope.TransactionUserMessage[parseInt(23)]:"7"===trans&&$rootScope.Freelancer&&"0"===value.site_revenue_from_employer?$scope.transaction_messages=$scope.TransactionUserMessage[parseInt(24)]:$scope.transaction_messages=$scope.TransactionUserMessage[parseInt(trans)],value.user.id===$rootScope.user.id?"Wallet"===value["class"]?value.transactionAmount={credit:value.amount,debit:"--"}:value.transactionAmount={credit:"--",debit:value.amount}:value.other_user.id===$rootScope.user.id&&("UserCashWithdrawal"===value["class"]?value.transactionAmount={credit:"--",debit:value.amount}:value.transactionAmount={credit:value.amount,debit:"--"})),value.user.id===$rootScope.user.id&&"7"===trans?commission=value.site_revenue_from_employer:value.user.id!==$rootScope.user.id&&"7"===trans&&(commission=value.site_revenue_from_freelancer),value.user.id===$rootScope.user.id&&"22"===trans&&(commission=value.site_revenue_from_employer),value.user.id===$rootScope.user.id&&"6"===trans&&(commission=value.site_revenue_from_employer),value.user.id!==$rootScope.user.id&&"6"===trans&&(commission=value.site_revenue_from_freelancer),value.user.id===$rootScope.user.id&&"5"===trans&&(commission=value.site_revenue_from_employer),value.user.id!==$rootScope.user.id&&"5"===trans&&(commission=value.site_revenue_from_freelancer),angular.isDefined(value.exam)&&(exam=""+value.exam.title+""),angular.isDefined(value.project)&&(project=""+value.project.name+""),angular.isDefined(value.job)&&(job=""+value.job.name+""),angular.isDefined(value.creditPurchasePlan)&&(subscription=value.creditPurchasePlan.name),angular.isDefined(value.payment_gateway)&&(payment_gateway=value.payment_gateway.display_name),value.user.id===$rootScope.user.id&&(value.user.username="You have"),value.user.id!==$rootScope.user.id&&(value.user.username=""+value.user.username+" has"),null!==value.foreign_transaction&&"Project"===value["class"]&&!value.project)var project_name=""+value.foreign_transaction.name+"";if(null!==value.foreign_transaction&&value.foreign_transaction.site_commision)var site_fee=$scope.settings.CURRENCY_SYMBOL+value.foreign_transaction.site_commision;var name={"##USER##":value.user.username,"##EXAM##":exam,"##PROJECT##":project,"##JOB##":job,"##SUBSCRIPTION##":subscription,"##PAYMENTGATEWAY##":payment_gateway,"##PROJECT_NAME##":project_name,"##SITE_FEE##":site_fee,"##OTHERUSER##":""+value.other_user.username+"","##COMMISSION##":commission};value.transaction_message=$scope.transaction_messages.replace(/##CONTEST##|##CONTEST_AMOUNT##|##USER##|##SITE_FEE##|##OTHERUSER##|##EXAM##|##PROJECT##|##PROJECT_NAME##|##PAYMENTGATEWAY##|##SUBSCRIPTION##|##JOB##|##COMMISSION##/gi,function(matched){return name[matched]})}),$scope.transactions=response.data,$scope.from_date=$scope.temp_from_date,$scope.to_date=$scope.temp_to_date})},$scope.paginateTransaction=function(page){$scope.currentPageTransaction=page,$scope.GetTransactions()},$scope.GetTransactions();else if("milestones"===tabSelected){$scope.renderpage="scripts/plugins/Bidding/Milestone/views/default/bidding_milestone.html",$scope.loadmore=!1;(void 0===$state.params.action||"milestones"!==$state.params.action)&&"mutual_cancel"!==$state.params.action&&"dispute"!==$state.params.action&&$state.go("Bid_ProjectView",$scope.projectBid,{notify:!1})}else $scope.selectedTab("messages")},$scope.is_file_error=!1,$scope.upload=function(file){checkFileFormat(file,FileFormat.project)?($scope.is_file_error=!1,Upload.upload({url:"/api/v1/attachments?class=Project",data:{file:file}}).then(function(response){$scope.uploadfile=response.data.attachment})):$scope.is_file_error=!0},$state.params.action?$scope.selectedTab($state.params.action):$scope.selectedTab("messages")}}}).directive("biddingProjectAction",function(){return{restrict:"EA",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_project_actions.html",scope:{bidid:"@",project:"@",projectstatus:"@",biduser:"@",projectuser:"@",isprojectcancel:"@",isdispute:"@"},controller:function($scope,$rootScope,$cookies,$state,$filter,flash,ProjectStatusConstant,UpdateProjectStatus,ProjectEditView,$location,$anchorScroll,$timeout,$uibModal,$uibModalStack){function updateprojectstatus(acceptparams){var flashMessage="";UpdateProjectStatus.put(acceptparams,function(response){var msgStr="";0===parseInt(response.error.code)?(msgStr=acceptparams.project_status_id===ProjectStatusConstant.Completed?"Project marked as completed successfully.":acceptparams.project_status_id===ProjectStatusConstant.MutuallyCanceled?"Your reject cancel request has been sended successfully.":acceptparams.project_status_id===ProjectStatusConstant.UnderDevelopment?"Project moved to under developement successfully":"Project is successfully completed",flashMessage=$filter("translate")(msgStr),flash.set(flashMessage,"success",!1),$state.reload(),$rootScope.Employer===!0&&acceptparams.project_status_id===ProjectStatusConstant.FinalReviewPending&&$rootScope.settings.SITE_ENABLED_PLUGINS.indexOf("Bidding/Dispute")>-1&&$state.go("Bid_ProjectView",{id:$state.params.id,slug:$state.params.slug,action:"messages"},{reload:!0})):1===parseInt(response.error.code)?(msgStr=acceptparams.project_status_id===ProjectStatusConstant.FinalReviewPending?"Clear all the milestone payment and complete the project":"",flashMessage=$filter("translate")(msgStr),flash.set(flashMessage,"error",!1)):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1))},function(error){console.log(error)})}if($scope.auth=JSON.parse($cookies.get("auth")),$scope.ProjectStatusConstant=ProjectStatusConstant,$scope.is_show_actions={mutual:!0,dispute:!0,review:!0},"mutual_cancel"===$state.params.action?$scope.is_show_actions.mutual=!1:"dispute"===$state.params.action||$rootScope.settings.SITE_ENABLED_PLUGINS.indexOf("Bidding/BiddingReview")>-1&&($scope.projectstatus===$scope.ProjectStatusConstant.FinalReviewPending||$scope.projectstatus===$scope.ProjectStatusConstant.Closed)&&angular.isDefined($rootScope.other_user_reviews)&&null!==$rootScope.other_user_reviews?$scope.is_show_actions.dispute=!1:"review-form"===$state.params.action&&($scope.is_show_actions.review=!1),parseInt($scope.projectuser)===parseInt($scope.auth.id)?$scope.is_freelancer=!1:$scope.is_freelancer=!0,"false"!==$scope.isprojectcancel){var getParams={id:$scope.project,fields:"id,project_status_id,is_dispute,is_cancel_request_freelancer,is_cancel_request_employer,user_id"};ProjectEditView.get(getParams,function(response){0===parseInt(response.error.code)&&($rootScope.projectmutual=response.data,$scope.is_freelancer?response.data.is_cancel_request_freelancer!==!0?$scope.show_request=$rootScope.show_request=!0:$scope.show_request=$rootScope.show_request=!1:response.data.is_cancel_request_employer!==!0?$scope.show_request=$rootScope.show_request=!0:$scope.show_request=$rootScope.show_request=!1)},function(error){console.log(error)})}$scope.projectstatuschange=function(statusType){var alerttitle="";8!==statusType&&9!==statusType?($scope.is_freelancer&&1===statusType?alerttitle="Are you sure you completed this project?":2===statusType?alerttitle="Are you sure you accept this project as completed?":3===statusType?alerttitle="Are you sure you want to request to cancel this project?":4===statusType?alerttitle="Are you sure you accept the cancel request of this project?":5===statusType?alerttitle="Are you sure you reject the cancel request of this project?":6===statusType?alerttitle="Are you sure you raise the dispute for this project?":7===statusType?alerttitle="Are you sure reject this dispute request?":10===statusType&&(alerttitle="Are you sure you want to cancel this request?"),swal({title:$filter("translate")(alerttitle),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){if(isConfirm)if($scope.is_freelancer&&1===statusType){var acceptparams={id:$scope.project,project_status_id:ProjectStatusConstant.Completed};updateprojectstatus(acceptparams)}else if(2===statusType){var acceptparams={id:$scope.project,project_status_id:ProjectStatusConstant.FinalReviewPending};updateprojectstatus(acceptparams)}else if(3===statusType)$scope.mutual_cancel=$rootScope.mutual_cancel=!0,$state.go("Bid_ProjectView",{id:$state.params.id,slug:$state.params.slug,action:"mutual_cancel"},{reload:!0}),$timeout(function(){$anchorScroll("cancel_scroll")},2500);else if(4===statusType){var acceptparams={id:$scope.project,project_status_id:ProjectStatusConstant.MutuallyCanceled,is_accept_mutual_cancel:1,mutual_cancel_note:$scope.mutual_canceled_note};updateprojectstatus(acceptparams)}else if(5===statusType){var acceptparams={id:$scope.project,project_status_id:ProjectStatusConstant.MutuallyCanceled,is_accept_mutual_cancel:0,mutual_cancel_note:$scope.mutual_canceled_note};updateprojectstatus(acceptparams)}else if(6===statusType)$scope.project_dispute=$rootScope.project_dispute=!0,$state.go("Bid_ProjectView",{id:$state.params.id,slug:$state.params.slug,action:"dispute"},{reload:!0}),$timeout(function(){$anchorScroll("dispute_scroll")},3500);else if(10===statusType){var acceptparams={id:$scope.project,project_status_id:ProjectStatusConstant.UnderDevelopment};updateprojectstatus(acceptparams)}})):8===statusType?($state.go("Bid_ProjectView",{id:$state.params.id,slug:$state.params.slug,action:"review-form"},{reload:!0}),$timeout(function(){$anchorScroll("add_review_scroll")},2500)):9===statusType&&($state.go("Bid_ProjectView",{id:$state.params.id,slug:$state.params.slug,action:"review-form"},{reload:!0}),$timeout(function(){$anchorScroll("update_review_scroll")},3500))},$scope.contactFreelancer=function(projectid){$rootScope.message_bid_id=projectid,$scope.modalInstance=$uibModal.open({templateUrl:"scripts/plugins/Bidding/Bidding/views/default/contact_freelancer.html",animation:!1,controller:function($scope,$rootScope,$window,$stateParams,$filter,md5,$state,Upload,$timeout,$uibModal,$uibModalStack,Messages,biduser,authuser){var flashMessage="";$scope.MessagePage=1,$rootScope.closemodel=function(){$uibModalStack.dismissAll()},$scope.contact_freelancer=!1,$scope.data={},$scope.ContactMessages=[],$scope.submit=function($valid){if($valid){$scope.contact_freelancer=!0;var contactData={};contactData.foreign_id=projectid,contactData.to_user_id=biduser,contactData.message=$scope.data.message,contactData["class"]="Bid",contactData.subject=$state.params.slug,Messages.post(contactData,function(response){0===response.error.code?(flashMessage=$filter("translate")("Message sent successfully."),flash.set(flashMessage,"success",!1),$scope.data.message="",$scope.Contactfrm.$setPristine(),$scope.Contactfrm.$setUntouched(),$scope.ContactMessages=[],$scope.MessagePage=1,$scope.GetConactMessage(),$scope.contact_freelancer=!1):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1))})}},$scope.GetConactMessage=function(){var conactparams={};conactparams.foreign_id=$rootScope.message_bid_id,conactparams.limit=5,conactparams.sortby="desc",conactparams.page=$scope.MessagePage,conactparams["class"]="Bid",Messages.get(conactparams,function(response){angular.isDefined(response.data)&&(angular.isDefined(response._metadata)&&($scope.messageNoOfPages=response._metadata.last_page,$scope.ConactmessageTotal=response._metadata.total-response._metadata.current_page*response._metadata.per_page),0===parseInt(response.error.code)?angular.forEach(response.data,function(value){angular.isDefined(value.user.attachment)&&null!==value.user.attachment?value.user.user_avatar_url="images/big_thumb/UserAvatar/"+value.user.id+"."+md5.createHash("UserAvatar"+value.user.id+"pngbig_thumb")+".png":value.user.user_avatar_url="images/default.png",$scope.ContactMessages.push(value)}):$scope.ContactMessages=[])})},$scope.contactmessage_pagination=function(){$scope.MessagePage=parseInt($scope.MessagePage)+1,$scope.GetConactMessage()},$scope.GetConactMessage()},size:"lg",resolve:{biduser:function(){return $scope.biduser},authuser:function(){return $scope.auth.id}}})},$rootScope.cancelresp=!1,$rootScope.$watch("cancelresp",function(newValue,oldValue){newValue!==!1&&($scope.projectstatuschange(parseInt(newValue)),$rootScope.cancelresp=!1)}),$scope.$on("mutualcancel",function(event,data){$scope.is_show_accept=data.is_show_accept})}}}).directive("biddingHomeSkills",function(ProjectSkills){return{restrict:"EA",replace:!0,templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_home_skills.html",link:function(scope,element,attrs){var params={limit:30,sort:"name",sortby:"DSC",field:"id,name,slug,description"};ProjectSkills.get(params,function(response){scope.project_skills=response.data})}}}).directive("biddingHomeCategories",function(ProjectCategory){return{restrict:"EA",replace:!0,templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_home_categories.html",link:function(scope,element,attrs){var params={limit:8,sort:"name",sortby:"DSC",field:"id,name,slug,description"};ProjectCategory.get(params,function(response){scope.project_categories=response.data})}}}).directive("biddingCategories",function(ProjectCategory,$filter){return{restrict:"EA",replace:!0,templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_categories.html",link:function(scope,element,attrs){var params={limit:8,sort:"name",sortby:"DSC",field:"id,name,slug,description"};ProjectCategory.get(params,function(response){scope.project_categories=response.data,scope.project_categories=$filter("orderBy")(response.data,"id")})}}}),angular.module("getlancerApp.Bidding").directive("biddingMutualCancel",function(){return{restrict:"EA",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_project_mutual_cancel.html",scope:{bidid:"@",isfreelancercancel:"@",isemployercancel:"@",project:"@",biduser:"@",projectuser:"@",isprojectcancel:"@",projectstatus:"@"},controller:function($scope,$rootScope,$cookies,$state,$filter,flash,ProjectStatusConstant,UpdateProjectStatus,md5){function updateprojectstatus(acceptparams){var flashMessage="";UpdateProjectStatus.put(acceptparams,function(response){0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Cancel request has been rejected successfully."),flash.set(flashMessage,"success",!1),$state.go("Bid_ProjectView",{id:$state.params.id,slug:$state.params.slug,action:"messages"},{reload:!0})):(flashMessage=$filter("translate")("Please Try again"),
flash.set(flashMessage,"success",!1))})}if($scope.show_request=$rootScope.show_request,$scope.ProjectStatusConstant=ProjectStatusConstant,angular.isDefined($rootScope.broadCastDataempolyer))if("true"===$scope.isemployercancel)if($rootScope.broadCastDataempolyer,$scope.mutualcancelnote=$rootScope.broadCastDataempolyer.notes,$scope.userinfo=$rootScope.broadCastDataempolyer.userinfo,$scope.is_show_accept=$rootScope.broadCastDataempolyer.is_show_accept,$scope.userid=$rootScope.broadCastDataempolyer.userId,$scope.created_at=$rootScope.broadCastDatafreelancer.createdAt,angular.isDefined($rootScope.broadCastDataempolyer.userImage)&&null!==$rootScope.broadCastDataempolyer.userImage){var c=new Date,hash=md5.createHash($rootScope.broadCastDataempolyer.userImage["class"]+$rootScope.broadCastDataempolyer.userImage.foreign_id+"pngbig_thumb");$scope.user_image="images/big_thumb/"+$rootScope.broadCastDataempolyer.userImage["class"]+"/"+$rootScope.broadCastDataempolyer.userImage.foreign_id+"."+hash+".png?"+c.getTime()}else $scope.user_image="images/default.png";else if($rootScope.broadCastDatafreelancer,$scope.mutualcancelnote=$rootScope.broadCastDatafreelancer.notes,$scope.userinfo=$rootScope.broadCastDatafreelancer.userinfo,$scope.is_show_accept=$rootScope.broadCastDatafreelancer.is_show_accept,$scope.userid=$rootScope.broadCastDataempolyer.userId,$scope.created_at=$rootScope.broadCastDataempolyer.createdAt,angular.isDefined($rootScope.broadCastDatafreelancer.userImage)&&null!==$rootScope.broadCastDatafreelancer.userImage){var c=new Date,hash=md5.createHash($rootScope.broadCastDatafreelancer.userImage["class"]+$rootScope.broadCastDatafreelancer.userImage.foreign_id+"pngbig_thumb");$scope.user_image="images/big_thumb/"+$rootScope.broadCastDatafreelancer.userImage["class"]+"/"+$rootScope.broadCastDatafreelancer.userImage.foreign_id+"."+hash+".png?"+c.getTime()}else $scope.user_image="images/default.png";$scope.closefrm=function(){$state.go("Bid_ProjectView",{id:$state.params.id,slug:$state.params.slug,action:"messages"},{reload:!0})},$scope.mutual_Cancel=!1,$scope.mutualCancel=function($valid,data){if($valid){$scope.mutual_Cancel=!0;var params={id:$scope.project,project_status_id:ProjectStatusConstant.MutuallyCanceled,mutual_cancel_note:data.mutual_cancel_note};swal({title:$filter("translate")("Are you sure you want to request to cancel this project?"),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){if(isConfirm){var flashMessage="";UpdateProjectStatus.put(params,function(response){$scope.mutual_canceled_note=response.data.mutual_cancel_note,0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Your cancel request has been rejected successfully."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Your cancel request sending failed."),$scope.mutual_Cancel=!1,flash.set(flashMessage,"error",!1))},function(error){console.log(error)})}else $scope.mutual_Cancel=!1})}},$scope.cancelreponse=function(statusType){var alerttitle="";4===statusType?alerttitle="Are you sure you accept the cancel request of this project?":5===statusType&&(alerttitle="Are you sure you reject the cancel request of this project?"),swal({title:$filter("translate")(alerttitle),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){if(isConfirm)if(4===statusType){var acceptparams={id:$scope.project,project_status_id:ProjectStatusConstant.MutuallyCanceled,is_accept_mutual_cancel:1,mutual_cancel_note:$scope.mutual_canceled_note};updateprojectstatus(acceptparams)}else if(5===statusType){var acceptparams={id:$scope.project,project_status_id:ProjectStatusConstant.MutuallyCanceled,is_accept_mutual_cancel:0,mutual_cancel_note:$scope.mutual_canceled_note};updateprojectstatus(acceptparams)}})}}}}),angular.module("getlancerApp.Bidding").directive("biddingProjectDashboard",function(){return{restrict:"E",replace:!0,templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_project_dashboard.html",controller:"biddingProjectDashboardCtrl"}}).controller("biddingProjectDashboardCtrl",function($rootScope,$scope,$state,$filter,flash,$window,$cookies,MyProjects,DelProject,ProjectStatsCount,ProjectStatusConstant,ProjectStatusUpdate,MyBids,UpdateProjectStatus,UpdateBidStatus,projectMilestone,projectInvoice,MilestoneStatusChange,MyMilestone,MyInvoices,MilestoneStatusConstant,BidStatusConstant,BidRetake,EmployerStatsCount,FreelancerStatusCount,$uibModal,$stateParams){$rootScope.header=$rootScope.settings.SITE_NAME+" | "+$filter("translate")("My Projects"),$scope.projectConstant=ProjectStatusConstant,$scope.portal=$window.localStorage.getItem("portal"),$scope.auth=JSON.parse($cookies.get("auth")),$scope.renderSubPage="scripts/plugins/Bidding/Bidding/views/default/my_bids_current_projects.html",$scope.MilestoneStatusConstant=MilestoneStatusConstant,$scope.BidStatusConstant=BidStatusConstant,$scope.milestonePage=function(id,project_name,action,type){1==type?$state.go("Bid_ProjectView",{id:id,slug:project_name,action:"milestones"}):2==type?$state.go("Bid_ProjectView",{id:id,slug:project_name,action:"invoices"}):3==type?$state.go("Bid_ProjectView",{id:id,slug:project_name,action:"dispute"},{reload:!0}):4==type&&$state.go("Bid_ProjectView",{id:id,slug:project_name,action:"review-form"})},$scope.milestoneStatueChange=function(milestoneId,statusId,status){$scope.milestoneid=milestoneId,"pay"!==statusId?swal({title:$filter("translate")("Are you sure you want to do this action?"),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){isConfirm&&("workcompleted"===status?MilestoneStatusChange.put({id:milestoneId,milestone_status_id:$scope.MilestoneStatusConstant.Completed},function(response){0===response.error.code?MilestoneStatusChange.put({id:milestoneId,milestone_status_id:statusId},function(response){var flashMessage="";0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Milestone status changed"),flash.set(flashMessage,"success",!1),$scope.$emit("isupdated","true")):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1))}):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1))}):MilestoneStatusChange.put({id:milestoneId,milestone_status_id:statusId},function(response){var flashMessage="";0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Milestone status changed"),flash.set(flashMessage,"success",!1),$scope.$emit("isupdated","true")):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1))}))}):$state.go("Bidding_MilestonePayment",{id:milestoneId,name:"milestone"})},$scope.$on("isupdated",function(event,data){$state.reload()}),$scope.bidcount=function(){$rootScope.scrollBids=!0},$scope.CancelProject=function(project_id){swal({title:$filter("translate")("Are you sure you want to cancel this project?"),type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){isConfirm&&ProjectStatusUpdate.put({id:project_id,project_status_id:$scope.projectConstant.EmployerCanceled},function(response){0===response.error.code?(flashMessage=$filter("translate")("Your project has been cancelled successfully."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Your project couldn't cancelled. Please try again."),flash.set(flashMessage,"error",!1),$state.reload())})})},$scope.reopen=function(projid){swal({title:$filter("translate")("Are you sure you want to reopen this project?"),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){isConfirm&&UpdateProjectStatus.put({id:projid,project_status_id:ProjectStatusConstant.OpenForBidding},function(response){0===parseInt(response.error.code)?(flash.set($filter("translate")("Project reopen successfully"),"success",!1),$state.reload()):flash.set($filter("translate")("Project reopen failed"),"error",!1)})})},$scope.AcceptCompleted=function(project_id,type){var alertTitle;alertTitle="accept"===type?"Are you sure you completed this project?":"Are you sure you want to cancel this request?",swal({title:$filter("translate")(alertTitle),type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){if(isConfirm){var params={};"accept"===type?(params.id=project_id,params.project_status_id=$scope.projectConstant.Completed):(params.id=project_id,params.project_status_id=$scope.projectConstant.UnderDevelopment),ProjectStatusUpdate.put(params,function(response){if(0===response.error.code){var flgmsg="";flgmsg=params.project_status_id===$scope.projectConstant.Completed?"Your project has been Completed successfully.":"Project moved to under developement successfully.",flashMessage=$filter("translate")(flgmsg),flash.set(flashMessage,"success",!1),$state.reload()}else flashMessage=response.error.message,flash.set(flashMessage,"error",!1),$state.reload()})}})},$scope.endpoint="projects",$scope.GetProjectStatus=function(){$scope.loader=!0,ProjectStatsCount.get({id:$scope.auth.id},function(response){$scope.loader=!1,0===parseInt(response.error.code)&&($scope.projectStatus=$filter("orderBy")(response.data,"id"))},function(error){console.log(error)})},$rootScope.Employer===!0&&($scope.EmployerMilestoneCount=function(){EmployerStatsCount.get(function(response){$scope.employer_count=response.data})}),$scope.FreelancerMilestoneCount=function(){FreelancerStatusCount.get(function(response){$scope.freelancer_count=response.data})},$scope.getProjects=function(tabType){if($scope.loader=!0,$scope.tabType=tabType,$scope.GetProjectStatus(),$rootScope.Employer===!0)$scope.EmployerMilestoneCount(),isNaN(tabType)||(1===tabType?($scope.project_status="Draft",(void 0===$state.params.status||"draft_payment_pending"!==$state.params.status)&&$state.go("user_dashboard",{status:"draft_payment_pending",type:"my_projects"},{notify:!1})):3===tabType?($scope.project_status="waiting for approval ",(void 0===$state.params.status||"waiting_for_approval"!==$state.params.status)&&$state.go("user_dashboard",{status:"waiting_for_approval",type:"my_projects"},{notify:!1})):5===tabType?($scope.project_status="Bidding Expired",(void 0===$state.params.status||"close_expiry"!==$state.params.status)&&$state.go("user_dashboard",{status:"close_expiry",type:"my_projects"},{notify:!1})):6===tabType?($scope.project_status="Winner Selected",(void 0===$state.params.status||"winner_selected"!==$state.params.status)&&$state.go("user_dashboard",{status:"winner_selected",type:"my_projects"},{notify:!1})):11===tabType?($scope.project_status="Under Development",(void 0===$state.params.status||"under_development"!==$state.params.status)&&$state.go("user_dashboard",{status:"under_development",type:"my_projects"},{notify:!1})):14===tabType?($scope.project_status="Pending Review",(void 0===$state.params.status||"final_review"!==$state.params.status)&&$state.go("user_dashboard",{status:"final_review",type:"my_projects"},{notify:!1})):16===tabType?($scope.project_status="Closed",(void 0===$state.params.status||"closed"!==$state.params.status)&&$state.go("user_dashboard",{status:"closed",type:"my_projects"},{notify:!1})):9===tabType?($scope.project_status="Closed / Expired",(void 0===$state.params.status||"bid_closed"!==$state.params.status)&&$state.go("user_dashboard",{status:"bid_closed",type:"my_projects"},{notify:!1})):13===tabType?($scope.project_status="Canceled",(void 0===$state.params.status||"admin_cancel"!==$state.params.status)&&$state.go("user_dashboard",{status:"admin_cancel",type:"my_projects"},{notify:!1})):12===tabType?($scope.project_status="Mutually Canceled",(void 0===$state.params.status||"cancel"!==$state.params.status)&&$state.go("user_dashboard",{status:"cancel",type:"my_projects"},{notify:!1})):($scope.project_status="Open for Bidding",(void 0===$state.params.status||"open_bidding"!==$state.params.status)&&$state.go("user_dashboard",{status:"open_bidding",type:"my_projects"},{notify:!1})),$scope.params={},parseInt(tabType)===ProjectStatusConstant.Draft?$scope.params.project_status_id=ProjectStatusConstant.Draft+","+ProjectStatusConstant.PaymentPending:parseInt(tabType)===ProjectStatusConstant.CanceledByAdmin?$scope.params.project_status_id=ProjectStatusConstant.EmployerCanceled+","+ProjectStatusConstant.MutuallyCanceled+","+ProjectStatusConstant.CanceledByAdmin:parseInt(tabType)===ProjectStatusConstant.BiddingClosed?$scope.params.project_status_id=ProjectStatusConstant.BiddingClosed+","+ProjectStatusConstant.BiddingExpired:parseInt(tabType)===ProjectStatusConstant.UnderDevelopment?$scope.params.project_status_id=ProjectStatusConstant.UnderDevelopment+","+ProjectStatusConstant.Completed:$scope.params.project_status_id=-1===tabType?ProjectStatusConstant.OpenForBidding:tabType,$scope.params.page=$scope.projectcurrentPage,MyProjects.get($scope.params,function(response){angular.isDefined(response._metadata)&&($scope.projectcurrentPage=response._metadata.current_page,$scope.totalItems=response._metadata.total,$scope.itemsPerPage=response._metadata.per_page,$scope.noOfPages=response._metadata.last_page),angular.isDefined(response.data)&&($scope.projects=response.data,angular.forEach($scope.projects,function(value){$rootScope.dispute_project=value.is_dispute})),$scope.loader=!1,0===parseInt(response.error.code)&&($scope.endpoint="projects")},function(error){console.log(error)})),"milestone"===tabType?($scope.project_status="Milestones",(void 0===$state.params.status||"milestone"!==$state.params.status)&&$state.go("user_dashboard",{status:"milestone",type:"projects"},{reload:!0}),projectMilestone.get({id:$scope.auth.id},function(response){$scope.loader=!1,0===parseInt(response.error.code)&&($scope.milestones=response.data,$scope.endpoint="milestone",$scope.GetProjectStatus())},function(error){})):"invoice"===tabType&&($scope.project_status="Invoices",(void 0===$state.params.status||"invoice"!==$state.params.status)&&$state.go("user_dashboard",{status:"invoice",type:"projects"},{reload:!0}),$scope.invoices=[],projectInvoice.get({id:$scope.auth.id},function(response){$scope.GetProjectStatus(),$scope.loader=!1,0===parseInt(response.error.code)&&($scope.invoices=response.data,$scope.endpoint="invoice")},function(error){}));else{"my_bids"===tabType?($scope.project_status="Current Projects",$scope.renderSubPage="scripts/plugins/Bidding/Bidding/views/default/my_bids_current_projects.html",(void 0===$state.params.status||"my_bids"!==$state.params.status)&&$state.go("user_dashboard",{status:"my_bids",type:"projects"},{notify:!1})):"active"===tabType?($scope.project_status="Active Bids",$scope.renderSubPage="scripts/plugins/Bidding/Bidding/views/default/my_bids_active.html",(void 0===$state.params.status||"active_bids"!==$state.params.status)&&$state.go("user_dashboard",{status:"active_bids",type:"projects"},{notify:!1})):"past_projects"===tabType&&($scope.renderSubPage="scripts/plugins/Bidding/Bidding/views/default/my_bids_past_projects.html",$scope.project_status="Past Projects",(void 0===$state.params.status||"past_projects"!==$state.params.status)&&$state.go("user_dashboard",{status:"past_projects",type:"projects"},{notify:!1}));var params={};params.page=void 0!==$scope.currentPage?$scope.currentPage:1,"my_bids"===$state.params.status&&(params.type="current_work"),"active_bids"===$state.params.status&&(params.type="active"),"past_projects"===$state.params.status&&(params.type="past_projects"),MyBids.get(params,function(response){$scope.FreelancerMilestoneCount(),$scope.loader=!1,0===parseInt(response.error.code)&&($scope.currentPage=response._metadata.current_page,$scope.totalItems=response._metadata.total,$scope.itemsPerPage=response._metadata.per_page,$scope.noOfPages=response._metadata.last_page),0===parseInt(response.error.code)?$scope.mybids=response.data:($scope.mybids=[],$scope.errorMessage="",angular.isDefined(response.error)&&($scope.errorMessage=response.error.message),$scope.currentPage=0,$scope.totalItems=0,$scope.itemsPerPage=0,$scope.noOfPages=0)}),"milestones"===tabType?($scope.project_status="Milestones",$scope.renderSubPage="scripts/plugins/Bidding/Bidding/views/default/milestone_supplier_portal.html",(void 0===$state.params.status||"milestone"!==$state.params.status)&&$state.go("user_dashboard",{status:"milestones",type:"projects"},{notify:!1}),MyMilestone.get({id:$scope.auth.id,page:$scope.currentPageMilestone},function(response){0===parseInt(response.error.code)&&($scope.my_milestones=response.data,$scope.currentPageMilestone=response._metadata.current_page,$scope.totalItemsMilestone=response._metadata.total,$scope.itemsPerPageMilestone=response._metadata.per_page,$scope.noOfPagesMilestone=response._metadata.last_page,$scope.endpoint="milestone")},function(error){})):"invoices"===tabType&&($scope.renderSubPage="scripts/plugins/Bidding/Bidding/views/default/supplier_portal_invoice.html",$scope.project_status="Invoices",(void 0===$state.params.status||"invoice"!==$state.params.status)&&$state.go("user_dashboard",{status:"invoices",type:"projects"},{notify:!1}),MyInvoices.get({id:$scope.auth.id},function(response){0===parseInt(response.error.code)&&($scope.my_invoices=response.data,$scope.endpoint="milestone")},function(error){}))}},$scope.paginate=function(page){$scope.currentPageMilestone=parseInt(page),$scope.getProjects("milestone")},$scope.pagination=function(page){$scope.projectcurrentPage=parseInt(page),$state.params.status?"draft_payment_pending"===$state.params.status?$scope.getProjects(1):"waiting_for_approval"===$state.params.status?$scope.getProjects(3):"open_bidding"===$state.params.status?$scope.getProjects(4):"close_expiry"===$state.params.status?$scope.getProjects(5):"winner_selected"===$state.params.status?$scope.getProjects(6):"under_development"===$state.params.status?$scope.getProjects(11):"final_review"===$state.params.status?$scope.getProjects(14):"closed"===$state.params.status?$scope.getProjects(16):"milestone"===$state.params.status?$scope.getProjects("milestone"):"invoice"===$state.params.status?$scope.getProjects("invoice"):"bid_closed"===$state.params.status?$scope.getProjects(9):"admin_cancel"===$state.params.status?$scope.getProjects(13):"cancel"===$state.params.status?$scope.getProjects(10):"my_bids"===$state.params.status?$scope.getProjects("my_bids"):"past_projects"===$state.params.status?$scope.getProjects("past_projects"):"milestones"===$state.params.status?$scope.getProjects("milestones"):"invoices"===$state.params.status?$scope.getProjects("invoices"):"active_bids"===$state.params.status?$scope.getProjects("active"):"past_projects"===$state.params.status?$scope.getProjects("past_projects"):'"Employer"'===$scope.portal?$scope.getProjects(4):$scope.getProjects("my_bids"):'"Employer"'===$scope.portal?$scope.getProjects(4):$scope.getProjects("my_bids")},$state.params.status?"draft_payment_pending"===$state.params.status?$scope.getProjects(1):"waiting_for_approval"===$state.params.status?$scope.getProjects(3):"open_bidding"===$state.params.status?$scope.getProjects(4):"close_expiry"===$state.params.status?$scope.getProjects(5):"winner_selected"===$state.params.status?$scope.getProjects(6):"under_development"===$state.params.status?$scope.getProjects(11):"final_review"===$state.params.status?$scope.getProjects(14):"closed"===$state.params.status?$scope.getProjects(16):"milestone"===$state.params.status?$scope.getProjects("milestone"):"invoice"===$state.params.status?$scope.getProjects("invoice"):"bid_closed"===$state.params.status?$scope.getProjects(9):"admin_cancel"===$state.params.status?$scope.getProjects(13):"cancel"===$state.params.status?$scope.getProjects(10):"my_bids"===$state.params.status?$scope.getProjects("my_bids"):"past_projects"===$state.params.status?$scope.getProjects("past_projects"):"milestones"===$state.params.status?$scope.getProjects("milestones"):"invoices"===$state.params.status?$scope.getProjects("invoices"):"active_bids"===$state.params.status?$scope.getProjects("active"):"past_projects"===$state.params.status?$scope.getProjects("past_projects"):'"Employer"'===$scope.portal?$scope.getProjects(4):$scope.getProjects("my_bids"):'"Employer"'===$scope.portal?$scope.getProjects(4):$scope.getProjects("my_bids");var flashMessage;$scope.deleteProject=function(project_id){swal({title:$filter("translate")("Are you sure you want to delete?"),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){isConfirm&&DelProject["delete"]({id:project_id},function(response){0===response.error.code?(flashMessage=$filter("translate")("Your project has been deleted successfully."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Your project couldn't deleted. Please try again."),flash.set(flashMessage,"error",!1),$state.reload())})})},$scope.withdrawfreelancer=function(rtype,projectid){swal({title:1===parseInt(rtype)?$filter("translate")("Are you sure you want to choose a new expert?"):$filter("translate")("Are you sure you want to reopen this project?"),text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){isConfirm&&1===parseInt(rtype)&&UpdateProjectStatus.put({id:projectid,project_status_id:ProjectStatusConstant.OpenForBidding,withdraw_bid_id:$scope.bidid},function(response){0===parseInt(response.error.code)?(flash.set($filter("translate")("Project reopen successfully"),"success",!1),$state.reload()):flash.set($filter("translate")("Project reopen failed"),"error",!1)})})},$scope.cancelProject=function(project_id){swal({title:$filter("translate")("Are you sure you want to cancel this project?"),type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){ProjectStatusUpdate.put({id:project_id,project_status_id:$scope.projectConstant.EmployerCanceled},function(response){0===response.error.code?(flashMessage=$filter("translate")("Your project has been cancelled successfully."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Your project couldn't cancelled. Please try again."),flash.set(flashMessage,"error",!1),$state.reload())})})},$scope.contactFreelancer=function(projectbidid,projectname,projectbidusername,disputestatus){$scope.modalInstance=$uibModal.open({templateUrl:"scripts/plugins/Bidding/Bidding/views/default/contact_freelancer.html",animation:!1,controller:function($scope,$rootScope,$window,$stateParams,$filter,md5,$state,Upload,$timeout,$uibModal,$uibModalStack,Messages,biduser,authuser){$rootScope.project_dispute=disputestatus;var flashMessage="";$rootScope.closemodel=function(){$uibModalStack.dismissAll()},$scope.contact_freelancer=!1,$scope.data={},$scope.ContactMessages=[],$scope.submit=function($valid){if($valid){$scope.contact_freelancer=!0;var contactData={};contactData.foreign_id=projectbidid,contactData.to_user_id=projectbidusername,contactData.message=$scope.data.message,contactData["class"]="Bid",contactData.subject=projectname,Messages.post(contactData,function(response){$scope.contact_freelancer=!1,0===response.error.code?(flashMessage=$filter("translate")("Message sent successfully."),flash.set(flashMessage,"success",!1),$scope.ContactMessages=[],$scope.GetConactMessage(),$scope.data.message="",$scope.contact_freelancer=!1,$scope.Contactfrm.$setPristine(),$scope.Contactfrm.$setUntouched()):(flashMessage=$filter("translate")(response.error.message),flash.set(flashMessage,"error",!1))})}},$scope.GetConactMessage=function(){var conactparams={};conactparams.foreign_id=projectbidid,conactparams.limit=5,conactparams.sortby="desc",conactparams["class"]="Bid",conactparams.page=$scope.MessagePage,Messages.get(conactparams,function(response){angular.isDefined(response.data)&&(angular.isDefined(response._metadata)&&($scope.messageNoOfPages=response._metadata.last_page,$scope.ConactmessageTotal=response._metadata.total-response._metadata.current_page*response._metadata.per_page),0===parseInt(response.error.code)?angular.forEach(response.data,function(value){angular.isDefined(value.user.attachment)&&null!==value.user.attachment?value.user.user_avatar_url="images/big_thumb/UserAvatar/"+value.user.id+"."+md5.createHash("UserAvatar"+value.user.id+"pngbig_thumb")+".png":value.user.user_avatar_url="images/default.png",$scope.ContactMessages.push(value)}):$scope.ContactMessages=[])})},$scope.MessagePage=1,$scope.contactmessage_pagination=function(){$scope.MessagePage=parseInt($scope.MessagePage)+1,$scope.GetConactMessage()},$scope.GetConactMessage()},size:"lg",resolve:{biduser:function(){return $scope.biduser},authuser:function(){return $scope.auth.id}}})},$scope.awardedprocess=function(ftype,projectbidid,bidid){var alertTitle="";1===parseInt(ftype)?alertTitle=$filter("translate")("Are you sure you want to accept this project?"):2===parseInt(ftype)&&(alertTitle=$filter("translate")("Are you sure you want to reject this project?")),swal({title:alertTitle,text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){if(isConfirm){var flashMessage="";if(1===parseInt(ftype))UpdateProjectStatus.put({id:projectbidid,project_status_id:ProjectStatusConstant.UnderDevelopment},function(response){0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Project successfully accepted and moved under developement status."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Check your wallet"),flash.set(flashMessage,"error",!1))},function(error){console.log(error)});else{var params={};params.id=bidid,UpdateBidStatus.put(params,{is_offered_rejected:1},function(response){0===parseInt(response.error.code)?(flashMessage=$filter("translate")("You are successfully ignore this project request."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Project couldn't rejected. Please try again."),flash.set(flashMessage,"error",!1))},function(error){console.log("BiddingAwardDirective",error)})}}})},$scope.bidAction=function(indexVal,atype,bidId){if(parseInt(atype)){var title="";1===parseInt(atype)?title=$filter("translate")("Are you sure you want to edit this bid?"):2===parseInt(atype)?title=$filter("translate")("Are you sure you want to withdraw this bid?"):3===parseInt(atype)?title=$filter("translate")("Are you sure you want to accept this project?"):4===parseInt(atype)?title=$filter("translate")("Are you sure you want to reject this project?"):5===parseInt(atype)&&(title=$filter("translate")("Are you sure you want to withdraw this bid?")),swal({title:title,text:"",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"OK",cancelButtonText:"Cancel",closeOnConfirm:!0,animation:!1}).then(function(isConfirm){if(isConfirm){var flashMessage="";if(1===parseInt(atype))$state.go("Bid_ProjectView",{id:$scope.mybids[indexVal].project.id,slug:$scope.mybids[indexVal].project.slug,placebid:!0,edit:!0});else if(2===parseInt(atype)){var params={};params.is_freelancer_withdrawn=1,BidRetake.put({id:$scope.mybids[indexVal].id},params,function(response){0===response.error.code?(flashMessage=$filter("translate")("Your bid withdrawn successfully."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Please try again."),flash.set(flashMessage,"error",!1),$state.reload())})}else 3===parseInt(atype)?$scope.activeBidChange(3,indexVal):4===parseInt(atype)&&$scope.activeBidChange(4,indexVal)}})}},$scope.activeBidChange=function(tval,indexVal){var flashMessage="";3===parseInt(tval)?UpdateProjectStatus.put({id:$scope.mybids[indexVal].project.id,project_status_id:ProjectStatusConstant.UnderDevelopment},function(response){0===parseInt(response.error.code)?(flashMessage=$filter("translate")("Project successfully accepted and moved under developement status."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("Check your wallet"),flash.set(flashMessage,"error",!1))},function(error){console.log(error)}):4===parseInt(tval)&&UpdateBidStatus.put({id:$scope.mybids[indexVal].id,is_offered_rejected:1},function(response){0===parseInt(response.error.code)?(flashMessage=$filter("translate")("You have successfully rejected this project."),flash.set(flashMessage,"success",!1),$state.reload()):(flashMessage=$filter("translate")("You have successfully rejected this project."),flash.set(flashMessage,"error",!1))},function(error){console.log("BiddingAwardDirective",error)})}}).directive("biddingActiveBids",function($rootScope,$state,$filter,flash,MyBids,BidMilestone,BidRetake,MeMilestone,MilestoneStatusConstant,MeInvoice){return{restrict:"E",templateUrl:""}}).directive("biddingDashboarProjectAction",function(){return{restrict:"EA",templateUrl:"scripts/plugins/Bidding/Bidding/views/default/bidding_dasboard_project_action.html",scope:{projstatus:"@",projid:"@",projname:"@",projbidid:"@",projectstatusid:"@",projisreachedresponseenddateforfreelancer:"@",bidusername:"@",disputestatus:"@"},controller:"biddingProjectDashboardCtrl"}}),angular.module("getlancerApp.Bidding").directive("biddingStars",[function(){function link(scope,element,attrs,ngModelCtrl){var computed={get readonly(){return"false"!=attrs.readonly&&(attrs.readonly||""===attrs.readonly)},get fullIcon(){return attrs.iconFull||"fa-star"},get emptyIcon(){return attrs.iconEmpty||"fa-star-o"},get iconBase(){return attrs.iconBase||"fa fa-fw"},get iconHover(){return attrs.iconHover||"angular-input-stars-hover"}};scope.items=new Array(+attrs.max),scope.listClass=attrs.listClass||"angular-input-stars",ngModelCtrl.$render=function(){scope.lastValue=ngModelCtrl.$viewValue||0},scope.getClass=function(index){var icon=index>=scope.lastValue?computed.iconBase+" "+computed.emptyIcon:computed.iconBase+" "+computed.fullIcon+" active ";return computed.readonly?icon+" readonly":icon},scope.unpaintStars=function($index,hover){scope.paintStars(scope.lastValue-1,hover)},scope.paintStars=function($index,hover){if(!computed.readonly){for(var items=element.find("li").find("i"),index=0;index=index?($star.removeClass(computed.emptyIcon),$star.addClass(computed.fullIcon),$star.addClass("active"),$star.addClass(computed.iconHover)):($star.removeClass(computed.fullIcon),$star.removeClass("active"),$star.removeClass(computed.iconHover),$star.addClass(computed.emptyIcon))}hover||items.removeClass(computed.iconHover)}},scope.setValue=function(index,e){if(!computed.readonly){var newValue,star=e.target;newValue=e.pageX
{{\'Currently you dont have enough credit point to send your quote\'|translate}}. {{\'Please\'|translate}} {{\'click here\'|translate}} {{\'to purchase the plan and continue your business\'|translate}}.
{{\'Your current available credit points\'|translate}}: {{available_credit_count}}
{{\'You need to pay\' | translate }} {{$root.settings.CREDIT_POINT_FOR_BIDDING_A_PROJECT }} {{\'credit point to send your quote. System will get required points from your current available credit points\' | translate}}.
{{\'Your current available credit points\'|translate}}: {{available_credit_count}}
{{message.user.username}} , {{ message.created_at | timeago}}
{{"Project under dispute. So you can\'t send message." | translate}}
{{"Project Mutually Cancelled. So you can\'t send message." | translate}}