public function init($params) { $this->setBuyPopupTemplate('buy_popup_masssending.tpl.php'); $promoCodes = new PromoCodes(); $options = array('popup_title_class_bg' => 'b-fon b-fon_bg_soap', 'popup_title_class_icon' => 'b-icon__soap', 'popup_title' => 'Покупка рассылки по разделам', 'popup_subtitle' => 'Параметры рассылки', 'popup_id' => $this->ID, 'unic_name' => $this->UNIC_NAME, 'payments_title' => 'Сумма и способ оплаты', 'payments_exclude' => array(self::PAYMENT_TYPE_BANK, self::PAYMENT_TYPE_PLATIPOTOM), 'ac_sum' => round($_SESSION['ac_sum'], 2), 'payment_account' => self::PAYMENT_TYPE_ACCOUNT, 'count' => $params['count'], 'count_pro' => $params['count_pro'], 'price' => $params['price'], 'send_id' => $params['send_id'], 'promo_code' => $promoCodes->render(PromoCodes::SERVICE_MASSSENDING)); //Обязательно передаем родителю parent::init($options); //Добавляем свойство к одному способу оплаты $this->options['payments'][self::PAYMENT_TYPE_CARD]['wait'] = 'Ждите ....'; }
public function init($options) { parent::init($options); $this->setBuyPopupTemplate('buy_popup_frlbindup.tpl.php'); $promoCodes = new PromoCodes(); $buffer = new buffer(); $options = array('popup_title_class_bg' => 'b-fon_bg_po', 'popup_title_class_icon' => 'b-icon__po', 'popup_title' => 'Поднятие закрепления на 1 место', 'popup_id' => $this->ID, 'unic_name' => $this->UNIC_NAME, 'payments_title' => 'Сумма и способ оплаты', 'payments_exclude' => array(self::PAYMENT_TYPE_BANK), 'ac_sum' => round($_SESSION['ac_sum'], 2), 'payment_account' => self::PAYMENT_TYPE_ACCOUNT, 'is_show' => $options['autoshow'], 'buffer' => $buffer->getSum(), 'promo_code' => $promoCodes->render(PromoCodes::SERVICE_FRLBIND)); //Обязательно передаем родителю parent::init($options); //Добавляем свойство к одному способу оплаты $this->options['payments'][self::PAYMENT_TYPE_CARD]['wait'] = 'Ждите ....'; $this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'] = sprintf($this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'], 'закрепление'); }
public function init() { //@todo: здесь можно получить список //услуг для данной бизнес модели $this->setBuyPopupTemplate('buy_popup_autoresponse.tpl.php'); $input_id = $this->ID . '_service'; $promoCodes = new PromoCodes(); $options = array('popup_title_class_bg' => 'b-fon_bg_po', 'popup_title_class_icon' => 'b-icon__po', 'popup_title' => 'Купить услуги автоответов', 'popup_subtitle' => '', 'items_title' => 'Подзаголовок тут', 'popup_id' => $this->ID, 'unic_name' => $this->UNIC_NAME, 'payments_title' => 'Сумма и способ оплаты', 'payments_exclude' => array(self::PAYMENT_TYPE_BANK), 'ac_sum' => round($_SESSION['ac_sum'], 2), 'payment_account' => self::PAYMENT_TYPE_ACCOUNT, 'promo_code' => $promoCodes->render(PromoCodes::SERVICE_AUTORESPONSE)); //Обязательно передаем родителю parent::init($options); //Добавляем свойство к одному способу оплаты $this->options['payments'][self::PAYMENT_TYPE_CARD]['wait'] = 'Ждите ....'; $this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'] = sprintf($this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'], 'автоответы'); }
/** * возвращает отзывы сервису в промоблок Безопасной Сделки. */ function checkPromoCode($popup, $code, $service_id, $type = 'id') { $objResponse = new xajaxResponse(); $promoCodes = new PromoCodes(); $services = strpos($service_id, '|') ? explode('|', $service_id) : $service_id; $codeInfo = $promoCodes->check($code, $services); $classAction = $codeInfo['success'] ? 'remove' : 'add'; $inputSelector = ''; switch ($type) { case 'pro': $scriptSelector = "info_block = \$('quick_pro_win_main').getElement('.promo_code_info');"; $inputSelector = "code_input = \$('quick_pro_win_main').getElement('.promo_code_input');"; $scriptRecalc = 'quickPRO_applyPromo();'; break; case 'prj': $scriptSelector = "info_block = \$('quick_pro_win_main').getElement('.promo_code_info');"; $inputSelector = "code_input = \$('quick_pro_win_main').getElement('.promo_code_input');"; $scriptRecalc = ''; $projectServices = array('contest' => PromoCodes::SERVICE_CONTEST, 'vacancy' => PromoCodes::SERVICE_VACANCY, 'project' => PromoCodes::SERVICE_PROJECT); foreach ($projectServices as $key => $value) { $use_discount = (int) (is_array($codeInfo['services']) && in_array($value, $codeInfo['services'])); $scriptRecalc .= "info_block.set('data-service-{$key}', {$use_discount});\n "; } $scriptRecalc .= 'quickPRJ_applyPromo();'; break; case 'mas': $scriptSelector = "info_block = \$('quick_mas_win_main').getElement('.promo_code_info');"; $inputSelector = "code_input = \$('quick_mas_win_main').getElement('.promo_code_input');"; $scriptRecalc = 'quickMAS_applyPromo();'; break; case 'autoresponse': $scriptSelector = "info_block = \$('quick_payment_autoresponse').getElement('.promo_code_info');"; $inputSelector = "code_input = \$('quick_payment_autoresponse').getElement('.promo_code_input');"; $scriptRecalc = 'autoresponseApplyPromo();'; break; case 'ext': $scriptSelector = " var qp = window.quick_ext_payment_factory.getQuickPayment('" . $popup . "');\n if(qp) {\n info_block = qp.promo_code_info;\n code_input = qp.promo_code_input;\n }"; $scriptRecalc = 'qp.applyPromo();'; break; default: $scriptSelector = " var qp = window.quick_payment_factory.getQuickPayment('" . $popup . "');\n if(qp) {\n info_block = qp.promo_code_info;\n code_input = qp.promo_code_input;\n }"; $scriptRecalc = 'qp.applyPromo();'; break; } if ($popup == 'tservicebind') { $scriptSelector = "var qp = window.quick_payment_factory.getQuickPaymentById('tservicebind', '" . $type . "');\n if(qp) {\n info_block = qp.promo_code_info;\n code_input = qp.promo_code_input;\n }"; } $objResponse->script("\n var info_block;\n var code_input;\n {$scriptSelector}\n {$inputSelector}\n if (code_input.get('value') == '{$code}') {\n info_block.set('text', '{$codeInfo['message']}');\n info_block.set('data-discount-percent', '{$codeInfo['discount_percent']}');\n info_block.set('data-discount-price', '{$codeInfo['discount_price']}');\n info_block.{$classAction}Class('b-layout__txt_color_c10600');\n {$scriptRecalc}\n }\n "); return $objResponse; }
public function init($options) { parent::init($options); $this->setBuyPopupTemplate('buy_popup_frlbind.tpl.php'); $input_id = $this->ID . '_service'; $is_prolong = (bool) $options['date_stop']; $promoCodes = new PromoCodes(); $options = array('popup_title_class_bg' => 'b-fon_bg_po', 'popup_title_class_icon' => 'b-icon__po', 'popup_title' => $is_prolong ? 'Продление закрепления в каталоге' : 'Закрепление в каталоге', 'popup_subtitle' => $is_prolong ? 'Срок продления закрепления' : 'Срок закрепления профиля', 'popup_id' => $this->ID, 'unic_name' => $this->UNIC_NAME, 'payments_title' => 'Сумма и способ оплаты', 'payments_exclude' => array(self::PAYMENT_TYPE_BANK), 'ac_sum' => round($_SESSION['ac_sum'], 2), 'payment_account' => self::PAYMENT_TYPE_ACCOUNT, 'profession' => $this->getProfessionText(), 'date_stop' => $options['date_stop'], 'is_show' => $options['autoshow'], 'addprof' => $options['addprof'], 'promo_code' => $promoCodes->render(PromoCodes::SERVICE_FRLBIND)); //Обязательно передаем родителю parent::init($options); //Добавляем свойство к одному способу оплаты $this->options['payments'][self::PAYMENT_TYPE_CARD]['wait'] = 'Ждите ....'; $this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'] = sprintf($this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'], 'закрепление'); }
public function init($uid, $type_place = 0) { $promoCodes = new PromoCodes(); $options = array('popup_title' => 'Размещение в Карусели', 'items_title' => 'Параметры объявления', 'payments_exclude' => array(self::PAYMENT_TYPE_BANK), 'price' => pay_place::getPrice(), 'promo_code' => $promoCodes->render(PromoCodes::SERVICE_CARUSEL)); $this->addWaitMessageForAll(); $form = new CaruselForm(); //Если уже размещался то поумолчанию заполняем тексты $payPlace = new pay_place($type_place); $data = $payPlace->getUserRequest($uid); if ($data) { $form->setDefaults(array('title' => $data['ad_header'], 'description' => $data['ad_text'])); } $this->setContent($form->render()); parent::init($options); $this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'] = sprintf($this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'], 'карусель'); }
public function init($params) { $kind = $params['kind'] ?: tservices_binds::KIND_LANDING; //По умолчанию ставим лендинг $prof_id = (int) $params['prof_id']; $this->setBuyPopupTemplate('buy_popup_tservicebindup.tpl.php'); $tservices_binds = new tservices_binds($kind); $promoCodes = new PromoCodes(); $buffer = new buffer(); $options = array('popup_title_class_bg' => 'b-fon_bg_po', 'popup_title_class_icon' => 'b-icon__po', 'popup_title' => 'Поднятие закрепления на 1 место', 'popup_id' => $this->getPopupId(0), 'unic_name' => $this->UNIC_NAME, 'payments_title' => 'Сумма и способ оплаты', 'payments_exclude' => array(self::PAYMENT_TYPE_BANK), 'ac_sum' => round($_SESSION['ac_sum'], 2), 'payment_account' => self::PAYMENT_TYPE_ACCOUNT, 'kind' => $kind, 'profession' => $tservices_binds->getProfessionText(false, $prof_id), 'buffer' => $buffer->getSum(), 'ammount' => round($tservices_binds->getPrice(true, @$params['uid'], $prof_id), 2), 'disable_tservices' => false, 'prof_id' => $prof_id, 'promo_code' => $promoCodes->render(PromoCodes::SERVICE_TSERVICEBIND)); //Обязательно передаем родителю parent::init($options); //Добавляем свойство к одному способу оплаты $this->options['payments'][self::PAYMENT_TYPE_CARD]['wait'] = 'Ждите ....'; $this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'] = sprintf($this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'], 'закрепление'); $this->inited = true; }
function initQuery($params) { $id = $params['id']; $tables = PromoCodes::getTables(); $c = $tables['promo_codes_coupons_table']['columns']; $this->addSelectField($c['products_affected'], 'prods'); $this->addSelectField($c['categories_affected'], 'cats'); $this->WhereValue($c['id'], DB_EQ, $id); }
public function init($params) { $kind = $params['kind'] ?: 1; //По умолчанию ставим лендинг $prof_id = (int) $params['prof_id']; $profs = array(); if ($kind == tservices_binds::KIND_SPEC) { $profs[] = $prof_id; } elseif ($kind == tservices_binds::KIND_GROUP) { $tservices_categories = new tservices_categories(); $categories = $tservices_categories->getCategoriesByParent($prof_id); foreach ($categories as $category) { $profs[] = $category['id']; } } $tservices = new tservices($params['uid']); $data = $tservices->getNotBindedList($kind, $profs); $tservices_text = $tservices_cur_text = ''; $tservices_cur = 0; if ($data) { foreach ($data as $tservice) { if (!$tservices_cur) { $tservices_cur = $tservice['id']; } if (!$tservices_cur_text) { $tservices_cur_text = $tservice['title']; } $tservices_list[] = $tservice['id'] . ": '" . addslashes($tservice['title']) . "'"; } $tservices_text = '{' . implode(', ', $tservices_list) . '}'; } else { $tservices_text = '{}'; } $this->setBuyPopupTemplate('buy_popup_tservicebind.tpl.php'); $tservices_binds = new tservices_binds($kind); $promoCodes = new PromoCodes(); $options = array('popup_title_class_bg' => 'b-fon_bg_po', 'popup_title_class_icon' => 'b-icon__po', 'popup_title' => $is_prolong ? 'Продление закрепления' : 'Закрепление услуги', 'popup_subtitle' => $is_prolong ? 'Срок продления закрепления' : 'Срок закрепления услуги', 'popup_id' => $this->getPopupId(0), 'unic_name' => $this->UNIC_NAME, 'payments_title' => 'Сумма и способ оплаты', 'payments_exclude' => array(self::PAYMENT_TYPE_BANK), 'ac_sum' => round($_SESSION['ac_sum'], 2), 'payment_account' => self::PAYMENT_TYPE_ACCOUNT, 'kind' => $kind, 'profession' => $tservices_binds->getProfessionText(false, $prof_id), 'tservices' => $tservices_text, 'tservices_cur' => $tservices_cur, 'tservices_cur_text' => $tservices_cur_text, 'ammount' => $tservices_binds->getPrice(false, $params['uid'], $prof_id), 'disable_tservices' => false, 'prof_id' => $prof_id, 'promo_code' => $promoCodes->render(PromoCodes::SERVICE_TSERVICEBIND)); //Обязательно передаем родителю parent::init($options); //Добавляем свойство к одному способу оплаты $this->options['payments'][self::PAYMENT_TYPE_CARD]['wait'] = 'Ждите ....'; $this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'] = sprintf($this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'], 'закрепление'); $this->inited = true; }
public function saveUserRequestTrip() { Session::forget('skipReview'); $latitude = Input::get('latitude'); $longitude = Input::get('longitude'); $d_latitude = Input::get('d_latitude'); $d_longitude = Input::get('d_longitude'); $type = Input::get('type'); $owner_id = Session::get('user_id'); $payment_type = Input::get('payment_type'); if ($type == "") { $message = "Please Select the Service Type"; $type = "warning"; return Redirect::route('userrequestTrip')->with('message', $message)->with('type', $type); } else { if (Input::has('promo_code')) { $promo_code = Input::get('promo_code'); $code_check = PromoCodes::where('coupon_code', $promo_code)->first(); if ($code_check == NULL) { $message = "Invalid Promo Code"; $type = "error"; return Redirect::route('userrequestTrip')->with('message', $message)->with('type', $type); } else { if ($code_check->state == 1 && date('Y-m-d H:i:s', strtotime($code_check->expiry)) > date('Y-m-d H:i:s')) { $code_id = $code_check->id; } else { $message = "Invalid Promo Code"; $type = "error"; return Redirect::route('userrequestTrip')->with('message', $message)->with('type', $type); } } } else { $code_id = NULL; } $owner_data = Owner::find($owner_id); $settings = Settings::where('key', 'default_search_radius')->first(); $distance = $settings->value; if (Input::has('type')) { $type = Input::get('type'); if (!$type) { // choose default type $provider_type = ProviderType::where('is_default', 1)->first(); if (!$provider_type) { $type = 1; } else { $type = $provider_type->id; } } } $typequery = "SELECT distinct provider_id from walker_services where type IN({$type})"; $typewalkers = DB::select(DB::raw($typequery)); /* $var = Keywords::where('id', 1)->first(); */ if (empty($typewalkers)) { /* $message = "No " . $var->keyword . " found matching the service type."; */ $message = "No " . Config::get('app.generic_keywords.Provider') . " found matching the service type."; } else { Log::info('typewalkers = ' . print_r($typewalkers, true)); foreach ($typewalkers as $key) { $types[] = $key->provider_id; } $typestring = implode(",", $types); Log::info('typestring = ' . print_r($typestring, true)); if ($typestring == '') { /* $message = "No " . $var->keyword . " found matching the service type."; */ $message = "No " . Config::get('app.generic_keywords.Provider') . " found matching the service type."; } $settings = Settings::where('key', 'default_search_radius')->first(); $distance = $settings->value; $settings = Settings::where('key', 'default_distance_unit')->first(); $unit = $settings->value; if ($unit == 0) { $multiply = 1.609344; } elseif ($unit == 1) { $multiply = 1; } $query = "SELECT walker.*, ROUND(" . $multiply . " * 3956 * acos( cos( radians('{$latitude}') ) * cos( radians(latitude) ) * cos( radians(longitude) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians(latitude) ) ) ,8) as distance from walker where is_available = 1 and is_active = 1 and is_approved = 1 and ROUND((" . $multiply . " * 3956 * acos( cos( radians('{$latitude}') ) * cos( radians(latitude) ) * cos( radians(longitude) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians(latitude) ) ) ) ,8) <= {$distance} and walker.deleted_at IS NULL and walker.id IN({$typestring}) order by distance"; $walkers = DB::select(DB::raw($query)); $walker_list = array(); $owner = Owner::find($owner_id); $owner->latitude = $latitude; $owner->longitude = $longitude; $owner->save(); $user_timezone = $owner->timezone; $default_timezone = Config::get('app.timezone'); $offset = $this->get_timezone_offset($default_timezone, $user_timezone); $request = new Requests(); $request->owner_id = $owner_id; if ($d_longitude != '' && $d_latitude != '') { $request->D_latitude = $d_latitude; $request->D_longitude = $d_longitude; } $request->request_start_time = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $offset); $request->save(); $request_service = new RequestServices(); $request_service->type = $type; $request_service->request_id = $request->id; $request_service->save(); $i = 0; $first_walker_id = 0; foreach ($walkers as $walker) { $request_meta = new RequestMeta(); $request_meta->request_id = $request->id; $request_meta->walker_id = $walker->id; if ($i == 0) { $first_walker_id = $walker->id; $i++; } $request_meta->save(); } $req = Requests::find($request->id); $req->current_walker = $first_walker_id; $req->confirmed_walker = 0; $req->payment_mode = $payment_type; $req->promo_code = $code_id; $req->save(); $settings = Settings::where('key', 'provider_timeout')->first(); $time_left = $settings->value; /* $var = Keywords::where('id', 1)->first(); $message = "Your Request is successful. Please wait while we are finding a nearest " . $var->keyword . " for you."; */ $message = "Your Request is successful. Please wait while we are finding a nearest " . Config::get('app.generic_keywords.Provider') . " for you."; $type = "success"; } return Redirect::to('/user/request-trip')->with('message', $message)->with('type', $type); // Send Notification $walker = Walker::find($first_walker_id); if ($walker) { $msg_array = array(); $msg_array['unique_id'] = 1; $msg_array['request_id'] = $request->id; $msg_array['time_left_to_respond'] = $time_left; $owner = Owner::find($owner_id); $request_data = array(); $request_data['owner'] = array(); $request_data['owner']['name'] = $owner->first_name . " " . $owner->last_name; $request_data['owner']['picture'] = $owner->picture; $request_data['owner']['phone'] = $owner->phone; $request_data['owner']['address'] = $owner->address; $request_data['owner']['latitude'] = $owner->latitude; $request_data['owner']['longitude'] = $owner->longitude; /* $request_data['owner']['rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->avg('rating') ? : 0; */ $request_data['owner']['rating'] = $owner->rate; /* $request_data['owner']['num_rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->count(); */ $request_data['owner']['num_rating'] = $owner->rate_count; $request_data['dog'] = array(); if ($dog = Dog::find($owner->dog_id)) { $request_data['dog']['name'] = $dog->name; $request_data['dog']['age'] = $dog->age; $request_data['dog']['breed'] = $dog->breed; $request_data['dog']['likes'] = $dog->likes; $request_data['dog']['picture'] = $dog->image_url; } $msg_array['request_data'] = $request_data; $title = "New Request"; $message = json_encode($msg_array); send_notifications($first_walker_id, "walker", $title, $message); } // Send SMS $settings = Settings::where('key', 'sms_request_created')->first(); $pattern = $settings->value; $pattern = str_replace('%user%', $owner_data->first_name . " " . $owner_data->last_name, $pattern); $pattern = str_replace('%id%', $request->id, $pattern); $pattern = str_replace('%user_mobile%', $owner_data->phone, $pattern); sms_notification(1, 'admin', $pattern); // send email /* $settings = Settings::where('key', 'email_new_request')->first(); $pattern = $settings->value; $pattern = str_replace('%id%', $request->id, $pattern); $pattern = str_replace('%url%', web_url() . "/admin/request/map/" . $request->id, $pattern); $subject = "New Request Created"; email_notification(1, 'admin', $pattern, $subject); */ $settings = Settings::where('key', 'admin_email_address')->first(); $admin_email = $settings->value; $follow_url = web_url() . "/user/signin"; $pattern = array('admin_eamil' => $admin_email, 'trip_id' => $request->id, 'follow_url' => $follow_url); $subject = "Ride Booking Request"; email_notification(1, 'admin', $pattern, $subject, 'new_request', null); return Redirect::to('/user/request-trip')->with('message', $message)->with('type', $type); } }
?> </td> <td> <?php echo sprintf2($walk->ledger_payment, 2); ?> </td> <td> <?php echo sprintf2($walk->card_payment, 2); ?> </td> <td> <?php if ($walk->promo_id !== NULL) { $promo = PromoCodes::where('id', $walk->promo_id)->first(); if ($promo) { if ($promo->type == 2) { echo sprintf2($promo->value, 2); } elseif ($promo->type == 1) { echo sprintf2($promo->value * $walk->total / 100, 2); } else { echo "<span class='badge bg-red'>" . Config::get('app.blank_fiend_val') . "</span>"; } } else { echo "<span class='badge bg-red'>" . Config::get('app.blank_fiend_val') . "</span>"; } } else { echo "<span class='badge bg-red'>" . Config::get('app.blank_fiend_val') . "</span>"; } ?>
<?php define('IS_SITE_ADMIN', 1); require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stdf.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/template.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/PromoCodes.php'; session_start(); $no_banner = 1; $rpath = '../../'; $uid = get_uid(); //if(!hasPermissions('sbr') && !hasPermissions('sbr_finance')) // header_location_exit('/404.php'); $promoCodes = new PromoCodes(); $content = '../content2.php'; $template = 'template2.php'; $services = array(10 => 'ПРО', 15 => 'платные опции в проектах', 20 => 'публикация конкурса', 25 => 'публикация вакансии', 30 => 'закрепление профиля', 35 => 'закрепление услуг', 40 => 'карусель', 45 => 'предложения фрилансеров', 55 => 'автоответы', 60 => 'рассылка по каталогу'); $action = __paramInit('string', 'action', null, 'add'); $id = __paramInit('int', 'id'); $card = null; switch ($action) { case 'edit': case 'add': $form = __paramInit('bool', null, 'formname'); if ($form) { $error = ''; $code = trim(__paramInit('string', null, 'code')); if (!$code) { $error .= 'Не указан код<br />'; } $date_s = __paramInit('string', null, 'date_s_eng_format'); $date = new DateTime($date_s);
/** * Совершить покупку * * @param integer $id возвращает id покупки * @param integer $transaction_id идентификатор текущей транзакции * @param integer $op_code идентификатор операции * @param integer $uid UID * @param string $descr описание для системы * @param string $comments описание для истории юзера * @param integer $ammount количество товара * @param integer $commit завершать ли транзакцию? * @param integer $promo_code ИД промо-кода * * @return integer 0 */ function Buy(&$id, $transaction_id, $op_code, $uid, $descr = "", $comments = "", $ammount = 1, $commit = 1, $promo_code = 0, $payment_sys = 0, $trs_sum = 0) { global $DB; if (!$transaction_id || $transaction_id != $this->check_transaction($transaction_id, $uid)) { return "Невозможно завершить транзакцию"; } else { $res = $DB->query("SELECT op_codes.sum as op_sum, account.sum, account.id FROM op_codes, account WHERE op_codes.id=? AND account.uid=?", $op_code, $uid); if (pg_errormessage()) { return "Ошибка при получении информации о счете!"; } list($op_sum, $ac_sum, $bill_id) = pg_fetch_row($res); $sum = $op_sum * $ammount; if ($promo_code) { $promoCodes = new PromoCodes(); $sum = $sum - $promoCodes->getDiscount($promo_code, $sum); } $ac_sum = round($ac_sum, 2); $sum = round($sum, 2); //@todo: зачем мемкеш? если занос денег deposit и покупка в отдной сессии php //можно было старое значение передать глобальной переменной или реестром $memBuff = new memBuff(); $ac_sum_old = round($memBuff->get("ac_sum_old_" . $uid), 2); $memBuff->delete("ac_sum_old_" . $uid); $new_ac_sum = $ac_sum_old < 0 ? $ac_sum - $ac_sum_old : $ac_sum; if ($sum > 0 && $sum > $new_ac_sum) { return "Недостаточно средств на счету!"; } if ($sum < 0) { return "Покупка на отрицательную сумму!"; } $id = $DB->insert('account_operations', array('billing_id' => $bill_id, 'op_code' => $op_code, 'ammount' => -$sum, 'descr' => $descr, 'comments' => $comments, 'payment_sys' => $payment_sys, 'trs_sum' => $trs_sum), 'id'); if ($DB->error) { return "Ошибка при записи счета!"; } else { if ($uid == get_uid(false)) { $_SESSION['ac_sum'] = $_SESSION['ac_sum'] - $sum; } } if ($promo_code) { $promoCodes->markUsed($promo_code); } // количество операций $_SESSION['account_operations'] = intval($_SESSION['account_operations']) + 1; // для счетчика everesttech.net (см. engine/templates/footer.tpl) if ($sum > 0) { $_SESSION['everesttech_conter'] = 1; } if ($commit) { $this->commit_transaction($transaction_id, $uid, $id); } } return 0; }
public function searchpromo() { $valu = $_GET['valu']; $type = $_GET['type']; $success = Input::get('success'); Session::put('valu', $valu); Session::put('type', $type); if ($type == 'promo_id') { $promo_codes = PromoCodes::where('id', $valu)->paginate(10); } elseif ($type == 'promo_name') { $promo_codes = PromoCodes::where('coupon_code', 'like', '%' . $valu . '%')->paginate(10); } elseif ($type == 'promo_type') { if ($valu == '%') { $promo_codes = PromoCodes::where('type', 1)->paginate(10); } elseif ($val = '$') { $promo_codes = PromoCodes::where('type', 2)->paginate(10); } } elseif ($type == 'promo_state') { if ($valu == 'active' || $valu == 'Active') { $promo_codes = PromoCodes::where('state', 1)->paginate(10); } elseif ($val = 'Deactivated' || ($val = 'deactivated')) { $promo_codes = PromoCodes::where('state', 2)->paginate(10); } } $title = ucwords(trans('customize.promo_codes') . " | Search Result"); /* 'Promo Codes | Search Result' */ return View::make('list_promo_codes')->with('title', $title)->with('page', 'promo_code')->with('success', $success)->with('promo_codes', $promo_codes); }
public function providerTripChangeState() { $date = date("Y-m-d H:i:s"); $time_limit = date("Y-m-d H:i:s", strtotime($date) - 3 * 60 * 60); $walker_id = Session::get('walker_id'); $state = $request_id = Request::segment(4); $current_request = Requests::where('confirmed_walker', $walker_id)->where('is_cancelled', 0)->where('is_dog_rated', 0)->where('created_at', '>', $time_limit)->orderBy('created_at', 'desc')->where(function ($query) { $query->where('status', 0)->orWhere(function ($query_inner) { $query_inner->where('status', 1)->where('is_dog_rated', 0); }); })->first(); if ($current_request && $state) { if ($state == 2) { $current_request->is_walker_started = 1; $owner = Owner::find($current_request->owner_id); $walker = Walker::find($walker_id); $location = get_location($owner->latitude, $owner->longitude); $latitude = $location['lat']; $longitude = $location['long']; $angle = get_angle($walker->latitude, $walker->longitude, $latitude, $longitude); $walker->old_latitude = $walker->latitude; $walker->old_longitude = $walker->longitude; $walker->latitude = $latitude; $walker->longitude = $longitude; $walker->bearing = $angle; $walker->save(); $walk_location = new WalkLocation(); $walk_location->request_id = $current_request->id; $walk_location->latitude = $latitude; $walk_location->longitude = $longitude; $walk_location->distance = 0; $walk_location->save(); } if ($state == 3) { $current_request->is_walker_arrived = 1; } if ($state == 4) { $current_request->is_started = 1; } if ($state == 6) { $rating = 0; if (Input::has('rating')) { $rating = Input::get('rating'); } $current_request->is_dog_rated = 1; $current_request->save(); $review_dog = new DogReview(); $review_dog->walker_id = $current_request->confirmed_walker; $review_dog->comment = Input::get('review'); $review_dog->rating = $rating; $review_dog->owner_id = $current_request->owner_id; $review_dog->request_id = $current_request->id; $review_dog->save(); if ($rating) { if ($owner = Owner::find($current_request->owner_id)) { $old_rate = $owner->rate; $old_rate_count = $owner->rate_count; $new_rate_counter = $owner->rate_count + 1; $new_rate = ($owner->rate * $owner->rate_count + $rating) / $new_rate_counter; $owner->rate_count = $new_rate_counter; $owner->rate = $new_rate; $owner->save(); } } $message = "You has successfully rated the owner."; $type = "success"; return Redirect::to('/provider/trips')->with('message', $message)->with('type', $type); } if ($state == 5) { $request_services = RequestServices::where('request_id', $current_request->id)->first(); $request_typ = ProviderType::where('id', '=', $request_services->req_typ)->first(); $address = urlencode(Input::get('address')); $end_address = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address={$address}"), TRUE); $end_location = $end_address['results'][0]['geometry']; $latitude = $end_location['location']['lat']; $longitude = $end_location['location']['lng']; $location = get_location($latitude, $longitude); $latitude = $location['lat']; $longitude = $location['long']; $request_id = $current_request->id; $walk_location_last = WalkLocation::where('request_id', $request_id)->orderBy('created_at', 'desc')->first(); if ($walk_location_last) { $distance_old = $walk_location_last->distance; $distance_new = distanceGeoPoints($walk_location_last->latitude, $walk_location_last->longitude, $latitude, $longitude); $distance = $distance_old + $distance_new; $settings = Settings::where('key', 'default_distance_unit')->first(); //$unit = $settings->value; $distance = $distance; } else { $distance = 0; } $walker = Walker::find($walker_id); $angle = get_angle($walker->latitude, $walker->longitude, $latitude, $longitude); $walker->old_latitude = $walker->latitude; $walker->old_longitude = $walker->longitude; $walker->latitude = $latitude; $walker->longitude = $longitude; $walker->bearing = $angle; $walker->save(); $walk_location = new WalkLocation(); $walk_location->request_id = $request_id; $walk_location->latitude = $latitude; $walk_location->longitude = $longitude; $walk_location->distance = $distance; $walk_location->save(); Walker::where('id', '=', $walker_id)->update(array('is_available' => 1)); // Calculate Rerquest Stats $time = 0; $time_query = "SELECT TIMESTAMPDIFF(SECOND,MIN(created_at),MAX(created_at)) as diff\n\t\t\t\tFROM walk_location where request_id = {$current_request->id}\n\t\t\t\tGROUP BY request_id limit 1 "; $time_data = DB::select(DB::raw($time_query)); foreach ($time_data as $time_diff) { $time = $time_diff->diff; } $time = $time / 60; /* TIME CALCULATION REDIRECTED */ $time = 0; /* TIME CALCULATION REDIRECTED END */ $walker_data = Walker::find($current_request->confirmed_walker); $provider_type = ProviderServices::where('type', $walker_data->type)->where('provider_id', $walker_id)->first(); if ($provider_type == NULL) { /* $settings = Settings::where('key', 'price_per_unit_distance')->first(); $price_per_unit_distance = $settings->value; $settings = Settings::where('key', 'price_per_unit_time')->first(); $price_per_unit_time = $settings->value; $settings = Settings::where('key', 'base_price')->first(); $base_price = $settings->value; */ $setbase_distance = $request_typ->base_distance; $base_price = $request_typ->base_price; $price_per_unit_distance = $request_typ->price_per_unit_distance; $price_per_unit_time = $request_typ->price_per_unit_time; } else { // $setbase_distance = $request_typ->base_distance; $setbase_distance = ""; $provider_type = ProviderServices::where('type', $walker_data->type)->where('provider_id', $walker_id)->first(); $base_price = $provider_type->base_price; $price_per_unit_distance = $provider_type->price_per_unit_distance; $price_per_unit_time = $provider_type->price_per_unit_time; } $settings = Settings::where('key', 'default_charging_method_for_users')->first(); $pricing_type = $settings->value; $settings = Settings::where('key', 'default_distance_unit')->first(); //$unit = $settings->value; $distance = convert($distance); if ($pricing_type == 1) { if ($distance <= $setbase_distance) { $distance_cost = 0; } else { $distance_cost = $price_per_unit_distance * ($distance - $setbase_distance); } $time_cost = $price_per_unit_time * $time; $total = $base_price + $distance_cost + $time_cost; } else { $distance_cost = 0; $time_cost = 0; $total = $base_price; } $current_request->is_completed = 1; $current_request->distance = $distance; $current_request->time = $time; $request_services->base_price = $base_price; $request_services->distance_cost = $distance_cost; $request_services->time_cost = $time_cost; $request_services->total = $total; $current_request->total = $total; $request_services->save(); // charge client // charge client $ledger = Ledger::where('owner_id', $current_request->owner_id)->first(); if ($ledger) { $balance = $ledger->amount_earned - $ledger->amount_spent; if ($balance > 0) { if ($total > $balance) { $ledger_temp = Ledger::find($ledger->id); $ledger_temp->amount_spent = $ledger_temp->amount_spent + $balance; $ledger_temp->save(); $total = $total - $balance; } else { $ledger_temp = Ledger::find($ledger->id); $ledger_temp->amount_spent = $ledger_temp->amount_spent + $total; $ledger_temp->save(); $total = 0; } } } $promo_discount = 0; if ($pcode = PromoCodes::where('id', $current_request->promo_code)->where('type', 1)->first()) { $discount = $pcode->value / 100; $promo_discount = $total * $discount; $total = $total - $promo_discount; if ($total < 0) { $total = 0; } } $current_request->total = $total; $current_request->save(); $cod_sett = Settings::where('key', 'cod')->first(); $allow_cod = $cod_sett->value; if ($current_request->payment_mode == 1 and $allow_cod == 1) { // Pay by Cash $current_request->is_paid = 1; Log::info('allow_cod'); } elseif ($current_request->payment_mode == 2) { // paypal Log::info('paypal payment'); } else { Log::info('normal payment. Stored cards'); // stored cards if ($total == 0) { $current_request->is_paid = 1; } else { $payment_data = Payment::where('owner_id', $current_request->owner_id)->where('is_default', 1)->first(); if (!$payment_data) { $payment_data = Payment::where('owner_id', $current_request->owner_id)->first(); } if ($payment_data) { $customer_id = $payment_data->customer_id; $setransfer = Settings::where('key', 'transfer')->first(); $transfer_allow = $setransfer->value; if (Config::get('app.default_payment') == 'stripe') { //dd($customer_id); Stripe::setApiKey(Config::get('app.stripe_secret_key')); try { $charge = Stripe_Charge::create(array("amount" => ceil($total * 100), "currency" => "usd", "customer" => $customer_id)); Log::info($charge); } catch (Stripe_InvalidRequestError $e) { // Invalid parameters were supplied to Stripe's API $ownr = Owner::find($current_request->owner_id); $ownr->debt = $total; $ownr->save(); $message = array('error' => $e->getMessage()); $type = "success"; Log::info($message); return Redirect::to('/provider/tripinprogress')->with('message', $message)->with('type', $type); } $current_request->is_paid = 1; $settng = Settings::where('key', 'service_fee')->first(); $settng_mode = Settings::where('key', 'payment_mode')->first(); if ($settng_mode->value == 2 and $transfer_allow == 1) { $transfer = Stripe_Transfer::create(array("amount" => ($total - $settng->value * $total / 100) * 100, "currency" => "usd", "recipient" => $walker_data->merchant_id)); $current_request->transfer_amount = $total - $settng->value * $total / 100; } } else { try { Braintree_Configuration::environment(Config::get('app.braintree_environment')); Braintree_Configuration::merchantId(Config::get('app.braintree_merchant_id')); Braintree_Configuration::publicKey(Config::get('app.braintree_public_key')); Braintree_Configuration::privateKey(Config::get('app.braintree_private_key')); if ($settng_mode->value == 2 and $transfer_allow == 1) { $sevisett = Settings::where('key', 'service_fee')->first(); $service_fee = $sevisett->value * $total / 100; $result = Braintree_Transaction::sale(array('amount' => $total - $service_fee, 'paymentMethodNonce' => $customer_id, 'merchantAccountId' => $walker_data->merchant_id, 'options' => array('submitForSettlement' => true, 'holdInEscrow' => true), 'serviceFeeAmount' => $service_fee)); } else { $result = Braintree_Transaction::sale(array('amount' => $total, 'paymentMethodNonce' => $customer_id)); } if ($result->success) { $request->is_paid = 1; } else { $request->is_paid = 0; } } catch (Exception $e) { $message = "Something went wrong in the payment. Please try again."; $type = "success"; return Redirect::to('/provider/tripinprogress')->with('message', $message)->with('type', $type); } } $current_request->card_payment = $total; $current_request->ledger_payment = $current_request->total - $total; } } } $current_request->save(); } $current_request->save(); } return Redirect::to('/provider/tripinprogress'); }
/** * Uninstall the module. * . * * uninstall() . * * , , * PromoCodes::getTables() $this->getTables() */ function uninstall() { $query = new DB_Table_Delete(PromoCodes::getTables()); global $application; $application->db->getDB_Result($query); }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/payed.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/platipotom.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/PromoCodes.php"; if (isset($quickPRO_type) && $quickPRO_type == 'profi') { $quickPRO_proList = payed::getPayedPROFIList(); } else { $quickPRO_proList = payed::getPayedPROList(is_emp() ? 'emp' : 'frl'); } $promoCodes = new PromoCodes(); $quickPRO_redirect = ''; $quickpro_ok_default = 'quickpro_ok'; switch ($quickPRO_type) { case 'profi': $quickPRO_title = 'Покупка аккаунта PROFI'; $quickPRO_ok_close_btn = 'Закрыть'; $quickpro_ok_default = 'quickprofi_ok'; $quickpro_ok_title = 'Вы успешно купили аккаунт PROFI'; $quickpro_ok_subtitle = ''; break; case 'project': $quickPRO_title = 'Покупка аккаунта Pro для ответа на проект'; $quickPRO_ok_close_btn = 'Закрыть и ответить на проект'; $quickPRO_redirect = getFriendlyUrl('project', $project['id']); break; case 'promotion': $quickPRO_redirect = '/promotion/'; default: $quickPRO_title = 'Покупка аккаунта Pro'; $quickPRO_ok_close_btn = 'Закрыть';
public function get_completed_requests() { $token = Input::get('token'); $owner_id = Input::get('id'); $from = Input::get('from_date'); // 2015-03-11 07:45:01 $to_date = Input::get('to_date') . ' 23:59:59'; //2015-03-11 07:45:01 $validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id), array('token' => 'required', 'owner_id' => 'required|integer')); if ($validator->fails()) { $error_messages = $validator->messages()->all(); $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages); $response_code = 200; } else { $is_admin = $this->isAdmin($token); if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) { // check for token validity if (is_token_active($owner_data->token_expiry) || $is_admin) { // Do necessary operations if ($from != "" && $to_date != "") { $request_data = DB::table('request')->where('request.owner_id', $owner_id)->where('is_completed', 1)->where('is_cancelled', 0)->whereBetween('request_start_time', array($from, $to_date))->leftJoin('walker', 'request.confirmed_walker', '=', 'walker.id')->leftJoin('walker_services', 'walker.id', '=', 'walker_services.provider_id')->leftJoin('walker_type', 'walker_type.id', '=', 'walker_services.type')->leftJoin('request_services', 'request_services.request_id', '=', 'request.id')->select('request.*', 'request.request_start_time', 'request.promo_code', 'walker.first_name', 'walker.id as walker_id', 'walker.last_name', 'walker.phone', 'walker.email', 'walker.picture', 'walker.bio', 'walker.rate', 'walker_type.name as type', 'walker_type.icon', 'request.distance', 'request.time', 'request_services.base_price as req_base_price', 'request_services.distance_cost as req_dis_cost', 'request_services.time_cost as req_time_cost', 'request_services.type as req_typ', 'request.total')->get(); } else { $request_data = DB::table('request')->where('request.owner_id', $owner_id)->where('is_completed', 1)->where('is_cancelled', 0)->leftJoin('walker', 'request.confirmed_walker', '=', 'walker.id')->leftJoin('walker_services', 'walker.id', '=', 'walker_services.provider_id')->leftJoin('walker_type', 'walker_type.id', '=', 'walker_services.type')->leftJoin('request_services', 'request_services.request_id', '=', 'request.id')->select('request.*', 'request.request_start_time', 'request.promo_code', 'walker.first_name', 'walker.id as walker_id', 'walker.last_name', 'walker.phone', 'walker.email', 'walker.picture', 'walker.bio', 'walker.rate', 'walker_type.name as type', 'walker_type.icon', 'request.distance', 'request.time', 'request_services.base_price as req_base_price', 'request_services.distance_cost as req_dis_cost', 'request_services.time_cost as req_time_cost', 'request_services.type as req_typ', 'request.total')->get(); } $requests = array(); $settings = Settings::where('key', 'default_distance_unit')->first(); $unit = $settings->value; if ($unit == 0) { $unit_set = 'kms'; } elseif ($unit == 1) { $unit_set = 'miles'; } /* $currency_selected = Keywords::find(5); */ foreach ($request_data as $data) { $request_typ = ProviderType::where('id', '=', $data->req_typ)->first(); /* $setbase_price = Settings::where('key', 'base_price')->first(); $setdistance_price = Settings::where('key', 'price_per_unit_distance')->first(); $settime_price = Settings::where('key', 'price_per_unit_time')->first(); */ $setbase_distance = $request_typ->base_distance; $setbase_price = $request_typ->base_price; $setdistance_price = $request_typ->price_per_unit_distance; $settime_price = $request_typ->price_per_unit_time; $locations = WalkLocation::where('request_id', $data->id)->orderBy('id')->get(); $start = $end = $map = ""; $id = $data->id; if (count($locations) >= 1) { $start = WalkLocation::where('request_id', $id)->orderBy('id')->first(); $end = WalkLocation::where('request_id', $id)->orderBy('id', 'desc')->first(); $map = "https://maps-api-ssl.google.com/maps/api/staticmap?size=249x249&scale=2&markers=shadow:true|scale:2|icon:http://d1a3f4spazzrp4.cloudfront.net/receipt-new/marker-start@2x.png|{$start->latitude},{$start->longitude}&markers=shadow:false|scale:2|icon:http://d1a3f4spazzrp4.cloudfront.net/receipt-new/marker-finish@2x.png|{$end->latitude},{$end->longitude}&path=color:0x2dbae4ff|weight:4"; foreach ($locations as $location) { $map .= "|{$location->latitude},{$location->longitude}"; } /* $map.="&key=" . Config::get('app.gcm_browser_key'); */ } $request['start_lat'] = ""; if (isset($start->latitude)) { $request['start_lat'] = $start->latitude; } $request['start_long'] = ""; if (isset($start->longitude)) { $request['start_long'] = $start->longitude; } $request['end_lat'] = ""; if (isset($end->latitude)) { $request['end_lat'] = $end->latitude; } $request['end_long'] = ""; if (isset($end->longitude)) { $request['end_long'] = $end->longitude; } $request['map_url'] = $map; $walker = Walker::where('id', $data->walker_id)->first(); if ($walker != NULL) { $user_timezone = $walker->timezone; } else { $user_timezone = 'UTC'; } $default_timezone = Config::get('app.timezone'); $date_time = get_user_time($default_timezone, $user_timezone, $data->request_start_time); $dist = number_format($data->distance, 2, '.', ''); $request['id'] = $data->id; $request['date'] = $date_time; $request['distance'] = (string) $dist; $request['unit'] = $unit_set; $request['time'] = $data->time; $discount = 0; if ($data->promo_code != "") { if ($data->promo_code != "") { $promo_code = PromoCodes::where('id', $data->promo_code)->first(); if ($promo_code) { $promo_value = $promo_code->value; $promo_type = $promo_code->type; if ($promo_type == 1) { // Percent Discount $discount = $data->total * $promo_value / 100; } elseif ($promo_type == 2) { // Absolute Discount $discount = $promo_value; } } } } $request['promo_discount'] = currency_converted($discount); $is_multiple_service = Settings::where('key', 'allow_multiple_service')->first(); if ($is_multiple_service->value == 0) { if ($data->req_base_price) { $request['base_price'] = currency_converted($data->req_base_price); } else { /* $request['base_price'] = currency_converted($setbase_price->value); */ $request['base_price'] = currency_converted($setbase_price); } if ($data->req_dis_cost) { $request['distance_cost'] = currency_converted($data->req_dis_cost); } else { /* $request['distance_cost'] = currency_converted($setdistance_price->value * $data->distance); */ if ($data->distance <= $setbase_distance) { $request['distance_cost'] = 0; } else { $request['distance_cost'] = currency_converted($setdistance_price->value * ($data->distance - $setbase_distance)); } } if ($data->req_time_cost) { $request['time_cost'] = currency_converted($data->req_time_cost); } else { /* $request['time_cost'] = currency_converted($settime_price->value * $data->time); */ $request['time_cost'] = currency_converted($settime_price * $data->time); } $request['setbase_distance'] = $setbase_distance; $request['total'] = currency_converted($data->total); $request['actual_total'] = currency_converted($data->total + $data->ledger_payment + $discount); $request['type'] = $data->type; $request['type_icon'] = $data->icon; $rserv = RequestServices::where('request_id', $data->id)->get(); $typs = array(); $typi = array(); $typp = array(); $total_price = 0; foreach ($rserv as $typ) { $typ1 = ProviderType::where('id', $typ->type)->first(); $typ_price = ProviderServices::where('provider_id', $data->confirmed_walker)->where('type', $typ->type)->first(); if ($typ_price->base_price > 0) { $typp1 = 0.0; $typp1 = $typ_price->base_price; } elseif ($typ_price->price_per_unit_distance > 0) { $typp1 = 0.0; foreach ($rserv as $key) { $typp1 = $typp1 + $key->distance_cost; } } else { $typp1 = 0.0; } $typs['name'] = $typ1->name; $typs['price'] = currency_converted($typp1); $total_price = $total_price + $typp1; array_push($typi, $typs); } $request['type'] = $typi; } else { $rserv = RequestServices::where('request_id', $data->id)->get(); $typs = array(); $typi = array(); $typp = array(); $total_price = 0; foreach ($rserv as $typ) { $typ1 = ProviderType::where('id', $typ->type)->first(); $typ_price = ProviderServices::where('provider_id', $data->confirmed_walker)->where('type', $typ->type)->first(); if ($typ_price->base_price > 0) { $typp1 = 0.0; $typp1 = $typ_price->base_price; } elseif ($typ_price->price_per_unit_distance > 0) { $typp1 = 0.0; foreach ($rserv as $key) { $typp1 = $typp1 + $key->distance_cost; } } else { $typp1 = 0.0; } $typs['name'] = $typ1->name; $typs['price'] = currency_converted($typp1); $total_price = $total_price + $typp1; array_push($typi, $typs); } $request['type'] = $typi; $base_price = 0; $distance_cost = 0; $time_cost = 0; foreach ($rserv as $key) { $base_price = $base_price + $key->base_price; $distance_cost = $distance_cost + $key->distance_cost; $time_cost = $time_cost + $key->time_cost; } $request['base_price'] = currency_converted($base_price); $request['distance_cost'] = currency_converted($distance_cost); $request['time_cost'] = currency_converted($time_cost); $request['total'] = currency_converted($total_price); } $rate = WalkerReview::where('request_id', $data->id)->where('walker_id', $data->confirmed_walker)->first(); if ($rate != NULL) { $request['walker']['rating'] = $rate->rating; } else { $request['walker']['rating'] = '0.0'; } /* $request['currency'] = $currency_selected->keyword; */ $request['base_price'] = currency_converted($data->req_base_price); $request['distance_cost'] = currency_converted($data->req_dis_cost); $request['time_cost'] = currency_converted($data->req_time_cost); $request['total'] = currency_converted($data->total - $data->ledger_payment - $data->promo_payment); $request['main_total'] = currency_converted($data->total); $request['referral_bonus'] = currency_converted($data->ledger_payment); $request['promo_bonus'] = currency_converted($data->promo_payment); $request['payment_type'] = $data->payment_mode; $request['is_paid'] = $data->is_paid; $request['promo_id'] = $data->promo_id; $request['promo_code'] = $data->promo_code; $request['currency'] = Config::get('app.generic_keywords.Currency'); $request['walker']['first_name'] = $data->first_name; $request['walker']['last_name'] = $data->last_name; $request['walker']['phone'] = $data->phone; $request['walker']['email'] = $data->email; $request['walker']['picture'] = $data->picture; $request['walker']['bio'] = $data->bio; $request['walker']['type'] = $data->type; /* $request['walker']['rating'] = $data->rate; */ array_push($requests, $request); } $response_array = array('success' => true, 'requests' => $requests); $response_code = 200; } else { $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405); $response_code = 200; } } else { if ($is_admin) { /* $var = Keywords::where('id', 2)->first(); $response_array = array('success' => false, 'error' => '' . $var->keyword . ' ID not Found', 'error_code' => 410); */ $response_array = array('success' => false, 'error' => '' . Config::get('app.generic_keywords.User') . ' ID not Found', 'error_code' => 410); } else { $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406); } $response_code = 200; } } $response = Response::json($response_array, $response_code); return $response; }
public function check_promo_code() { $promo_code = Input::get('promo_code'); $token = Input::get('token'); $owner_id = Input::get('id'); $validator = Validator::make(array('promo_code' => $promo_code, 'token' => $token, 'owner_id' => $owner_id), array('promo_code' => 'required', 'token' => 'required', 'owner_id' => 'required|integer')); if ($validator->fails()) { $error_messages = $validator->messages()->all(); $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages); $response_code = 200; } else { $is_admin = $this->isAdmin($token); if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) { // check for token validity if (is_token_active($owner_data->token_expiry) || $is_admin) { $settings = Settings::where('key', 'promotional_code_activation')->first(); $prom_act = $settings->value; if ($prom_act) { // check promo code $check_code = PromoCodes::where('coupon_code', $promo_code)->where('uses', '>', 0)->first(); if ($check_code != NULL) { if ($check_code->state == 1 && date('Y-m-d H:i:s', strtotime($check_code->expiry)) > date('Y-m-d H:i:s') && date('Y-m-d H:i:s', strtotime($check_code->start_date)) <= date('Y-m-d H:i:s')) { if ($check_code->type == 1) { $discount = $check_code->value . " %"; } elseif ($check_code->type == 2) { $discount = "\$ " . $check_code->value; } $response_array = array('success' => true, 'discount' => $discount); } else { $response_array = array('success' => false, 'error' => 'Invalid Promo Code', 'error_code' => 418); } } else { $response_array = array('success' => false, 'error' => 'Invalid Promo Code', 'error_code' => 419); } } else { $response_array = array('success' => false, 'error' => 'Promotion feature is not active.', 'error_code' => 419); } } else { $response_array = array('success' => false, 'error' => 'Request ID Not Found', 'error_code' => 408); } } else { $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405); } $response_code = 200; } $response = Response::json($response_array, $response_code); return $response; }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/PromoCodes.php'; $promoCodes = new PromoCodes(); ?> <div id="quick_mas_win_main" class="b-shadow b-shadow_center b-shadow_width_520 b-shadow_pad_15_20 b-shadow_zindex_11 b-shadow_hide" style="display:block;"> <div class="b-fon b-fon_bg_soap"> <div class="b-layout__title b-layout__title_padbot_5"><span class="b-icon b-icon__soap b-icon_float_left b-icon_top_4"></span>Покупка рассылки по фрилансерам <div class="b-layout__txt b-layout__txt_fontsize_11 b-layout__txt_lineheight_1">с поиском и привлечением лучших исполнителей</div> </div> </div> <div id="quick_mas_div_main" class="b-layout"> <div class="b-layout__txt b-layout__txt_fontsize_15 b-layout__txt_padbot_20">Параметры рассылки</div> <div class="b-layout__txt b-layout__txt_padleft_20 b-layout__txt_bold">Количество получателей — <span class="b-layout__txt b-layout__txt_color_6db335" id="quickmas_f_mas_u_count">0</span></div> <div class="b-layout__txt b-layout__txt_padleft_20 b-layout__txt_fontsize_11 b-layout__txt_padbot_20"><span id="quickmas_f_mas_u_count_pro_txt">из них с аккаунтом PRO</span> — <span id="quickmas_f_mas_u_count_pro">0</span></div> <div id="quickmas_f_mas_subcat_m" class="b-layout__txt b-layout__txt_padleft_20 b-layout__txt_bold">Выбранных разделов/специализаций — <span class="b-layout__txt b-layout__txt_color_6db335" id="quickmas_f_mas_c_count">0</span></div> <div id="quickmas_f_mas_subcat" class="b-layout__txt b-layout__txt_padleft_20 b-layout__txt_fontsize_11 b-layout__txt_padbot_20"></div> <input type="hidden" id="quick_mas_f_account_sum" value="<?php echo round($_SESSION['ac_sum'], 2) < 0 ? 0 : round($_SESSION['ac_sum'], 2); ?> "/>
/** * Обработка входящей операции помещения услуги в "Список услуг" согласно входящей op_code. * * @param int $op_code ИД операции * @param array $code Данные операции (если есть на момент вызова функции) * * @return array */ public function prepareOperationCode($op_code, $code = null) { $code = $code == null ? current(op_codes::getCodes($op_code)) : $code; $_op_code = self::getOpCodeByDiscount($op_code); $data = array(); switch ($_op_code) { // Конкурс case 9: case 106: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: case 130: //Платный конкурс //Платный конкурс case 86: //Платный проект (вакансия, устаревший опкод) //Платный проект (вакансия, устаревший опкод) case 53: //Покупка вакансии //Покупка вакансии case 113: //пользователь не PRO //пользователь не PRO case 192: //пользователь PRO //Платные услуги проектов //пользователь PRO //Платные услуги проектов case 138: case 139: case 140: case 141: if (is_emp($this->user['role'])) { $data = array('ammount' => 0, 'pro_ammount' => 0, 'descr' => '', 'comment' => 'Платный проект / ', 'service' => 'projects'); if (!empty($this->_option)) { $i = 0; if ($this->_option['items']['bold'] > 0) { $data['option'] = 'bold'; $data['comment'] .= ($i++ ? ', ' : '') . 'жирный шрифт'; $data['ammount'] += $this->_option['items']['bold']; } if ($this->_option['items']['color'] > 0) { $data['option'] = 'color'; $data['comment'] .= ($i++ ? ', ' : '') . 'подсветка фоном'; $data['ammount'] += $this->_option['items']['color']; } if ($this->_option['items']['urgent'] > 0) { $data['option'] = 'urgent'; $data['comment'] .= ($i++ ? ', ' : '') . 'срочный'; $data['ammount'] += $this->_option['items']['urgent']['no_pro']; $data['pro_ammount'] += (int) $this->_option['items']['urgent']['pro']; } if ($this->_option['items']['hide'] > 0) { $data['option'] = 'hide'; $data['comment'] .= ($i++ ? ', ' : '') . 'скрытый'; $data['ammount'] += $this->_option['items']['hide']['no_pro']; $data['pro_ammount'] += (int) $this->_option['items']['hide']['pro']; } if ($this->_option['items']['logo'] > 0) { $data['option'] = 'logo'; $data['descr'] = $this->_option['logo_link']; $data['src_id'] = $this->_option['logo_id']; $data['comment'] .= ($i++ ? ', ' : '') . 'логотип'; $data['ammount'] += $this->_option['items']['logo']['no_pro']; $data['pro_ammount'] += (int) $this->_option['items']['logo']['pro']; } if ($this->_option['items']['office'] > 0) { $data['option'] = 'office'; $data['comment'] .= ($i++ ? ', ' : '') . 'в офис'; $data['ammount'] += $this->_option['items']['office']; } if ($this->_option['items']['top'] > 0) { $data['option'] = 'top'; $data['op_count'] = $this->_option['addTop']; $topDays = $this->_option['addTop']; $data['comment'] .= ($i++ ? ', ' : '') . 'закрепление наверху на ' . $topDays . ' ' . getTermination($topDays, array(0 => 'день', 1 => 'дня', 2 => 'дней')); $data['ammount'] += $this->_option['items']['top']['no_pro']; $data['pro_ammount'] += (int) $this->_option['items']['top']['pro']; } if ($this->_option['items']['contest'] > 0) { $data['option'] = 'contest'; $data['comment'] = 'Публикация конкурса'; $data['ammount'] += is_pro() ? $this->_option['items']['contest']['pro'] : $this->_option['items']['contest']['no_pro']; $data['pro_ammount'] += $this->_option['items']['contest']['pro']; } $data['parent_id'] = $this->_option['prj_id']; if ($this->_option['is_edit']) { $data['parent_table'] = 'projects'; } else { $data['parent_table'] = 'draft_projects'; } } } break; // Поднятие платных мест // Поднятие платных мест case 21: if (!is_emp($this->user['role'])) { $data = array('ammount' => round($code['sum'], 2), 'descr' => '', 'comment' => $code['op_name'], 'service' => 'first_page_up'); if (!empty($this->_option)) { $data['descr'] = $this->_option['prof_id']; $data['src_id'] = $this->_option['prof_id']; $data['ammount'] = $this->_option['sum']; if ($this->_option['prof_id'] == -1) { $data['comment'] = 'Поднятие платного места на главной'; } else { $data['comment'] = 'Поднятие платного места в каталоге'; } } } break; // Поднятие на первое место в платных местах // Поднятие на первое место в платных местах case 145: case 146: case 154: if (!is_emp($this->user['role'])) { $data = array('ammount' => $code['sum'], 'descr' => '', 'comment' => $code['op_name'], 'service' => 'first_page_top'); if (!empty($this->_option)) { $data['descr'] = $this->_option['prof_id']; $data['src_id'] = $this->_option['prof_id']; $data['comment'] = $this->_option['comment']; } } break; // Пополнение счета // Пополнение счета case 135: $data = array('ammount' => $this->_option['acc_sum'], 'descr' => '', 'comment' => 'Погашение задолженности - ' . $this->_option['acc_sum']); break; //Резервирование средств //Резервирование средств case 136: require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/reserves/ReservesModelFactory.php'; $reserve_data = @$this->_option['reserve_data']; if (!$reserve_data) { break; } $comment = ReservesModelFactory::getInstance($reserve_data['type'])->getBillComment($reserve_data['src_id']); $data = array('ammount' => $this->_option['acc_sum'], 'parent_id' => $reserve_data['id'], 'parent_table' => 'reserves', 'comment' => $comment); break; // Автоответы // Автоответы case 137: $data = array('ammount' => $this->_option['acc_sum'], 'comment' => 'Покупка автоответа', 'parent_id' => $this->_option['autoresponse_id'], 'parent_table' => 'autoresponse'); break; // Платное место в карусели // Платное место в карусели case 65: // На главной странице // На главной странице case 73: // В каталоге if (!is_emp($this->user['role'])) { $data = array('ammount' => round($code['sum'], 2), 'descr' => 'Оплачено', 'comment' => 'Оплата новых платных мест', 'service' => 'pay_place'); if (!empty($this->_option)) { $data['option'] = serialize($this->_option); //поддержка старого режима где небыло возможности //приобрести несколько размещений if (isset($this->_option['num'])) { $data['ammount'] = $data['ammount'] * $this->_option['num']; $data['op_count'] = $this->_option['num']; } } } break; // Аккаунт PROFI для фрилансера // Аккаунт PROFI для фрилансера case 164: // Аккаунт PROFI на 1 месяц $to = 'на 1 месяц'; if (!is_emp($this->user['role'])) { $data = array('ammount' => round($code['sum'] * 10, 2), 'descr' => 'Все разделы', 'comment' => "Аккаунт PROFI {$to}", 'service' => 'pro'); } break; // Аккаунт ПРО для фрилансера // Аккаунт ПРО для фрилансера case 47: // Тестовый аккаунт ПРО if ($this->IsUserWasPro()) { break; } $to = 'на 1 неделю'; case 132: // Аккаунт ПРО на 1 день $to = !$to ? 'на 1 день' : $to; case 131: // Аккаунт ПРО на 1 неделю $to = !$to ? 'на 1 неделю' : $to; case 163: //Тестовый ПРО на месяц //Тестовый ПРО на месяц case 48: // Аккаунт ПРО на 1 месяц $to = !$to ? 'на 1 месяц' : $to; case 49: // Аккаунт ПРО на 3 месяца $to = !$to ? 'на 3 месяца' : $to; case 50: // Аккаунт ПРО на 6 месяцев $to = !$to ? 'на 6 месяцев' : $to; case 51: // Аккаунт ПРО на 12 месяцев $to = !$to ? 'на 1 год' : $to; if (!is_emp($this->user['role'])) { $data = array('ammount' => round($code['sum'] * 10, 2), 'descr' => 'Все разделы', 'comment' => "Аккаунт PRO {$to}", 'service' => 'pro'); } break; // Аккаунт ПРО для работодателей // Аккаунт ПРО для работодателей case 15: // Аккаунт ПРО на 1 месяц $code['sum'] = $code['sum'] * payed::PRICE_EMP_PRO / 10; $to = 'на 1 месяц'; case 118: // Аккаунт ПРО на 3 месяца $to = !$to ? 'на 3 месяца' : $to; case 119: // Аккаунт ПРО на 6 месяцев $to = !$to ? 'на 6 месяцев' : $to; case 120: // Аккаунт ПРО на 12 месяцев $to = !$to ? 'на 1 год' : $to; if (is_emp($this->user['role'])) { $data = array('ammount' => round($code['sum'] * 10, 2), 'descr' => 'Все разделы', 'comment' => "Аккаунт PRO {$to}", 'service' => 'pro'); } break; case 45: $data = array('ammount' => round($this->_option['amount'], 2), 'parent_id' => $this->_option['masssending_id'], 'parent_table' => 'mass_sending', 'descr' => 'Рассылка по каталогу', 'comment' => 'Рассылка по каталогу', 'service' => 'massending'); break; case 117: // Оплата верификации $data = array('option' => serialize($this->_option['data']), 'src_id' => $this->_option['prev']['id'], 'ammount' => round($code['sum'], 2), 'descr' => 'Верификация через сервис FF.RU', 'comment' => 'Верификация через сервис FF.RU', 'service' => 'verify_ff'); break; case 133: $data = array('ammount' => round($code['sum'] * 10, 2), 'descr' => 'Верификация WebMoney', 'comment' => 'Верификация WebMoney', 'service' => 'verify_webmoney'); break; //Верификация банковской картой через ЯКассу //Верификация банковской картой через ЯКассу case 191: $data = array('ammount' => round($code['sum'], 2), 'descr' => 'Верификация банковской картой', 'comment' => 'Верификация банковской картой', 'option' => serialize($this->_option)); break; // Закрепление в каталоге фрилансеров // Закрепление в каталоге фрилансеров case 142: // Корневой каталог // Корневой каталог case 143: // Раздел // Раздел case 144: // Подраздел // Подраздел case 148: // Продление в корневом каталоге // Продление в корневом каталоге case 149: // Продление в разделе // Продление в разделе case 150: // Продление в подразделе if (!is_emp($this->user['role'])) { //Получаем диф.цену $sum = op_codes_price::getOpCodePrice($op_code, $this->_option['prof_id']); $code['sum'] = $sum ? $sum : $code['sum']; $data = array('ammount' => $code['sum'], 'descr' => '', 'comment' => 'Закрепление в каталоге фрилансеров', 'service' => 'frlbind'); if (!empty($this->_option)) { $data['src_id'] = $this->_option['prof_id']; $data['ammount'] = $data['ammount'] * $this->_option['weeks']; $data['op_count'] = $this->_option['weeks']; } } break; // Поднятие закрепления в каталоге фрилансеров // Поднятие закрепления в каталоге фрилансеров case 151: // Корневой каталог // Корневой каталог case 152: // Раздел // Раздел case 153: // Подраздел // Подраздел case 194: // Оплата из буфера if (!is_emp($this->user['role'])) { //Получаем диф.цену $sum = op_codes_price::getOpCodePrice($op_code, $this->_option['prof_id']); $code['sum'] = $sum ? $sum : $code['sum']; $data = array('ammount' => $code['sum'], 'descr' => '', 'comment' => 'Поднятие закрепления в каталоге фрилансеров', 'service' => 'frlbindup'); if (!empty($this->_option)) { $data['src_id'] = $this->_option['prof_id']; $data['op_count'] = 1; } } break; // Закрепление в каталоге услуг // Закрепление в каталоге услуг case 155: // Лендинг // Лендинг case 156: // Корневой каталог // Корневой каталог case 157: // Раздел // Раздел case 158: // Подраздел if (!is_emp($this->user['role'])) { //Получаем диф.цену $sum = op_codes_price::getOpCodePrice($op_code, $this->_option['prof_id']); $code['sum'] = $sum ? $sum : $code['sum']; $data = array('ammount' => $code['sum'], 'descr' => '', 'comment' => 'Закрепление в каталоге услуг', 'service' => 'tservicebind'); if (!empty($this->_option)) { $data['src_id'] = $this->_option['prof_id']; $data['ammount'] = $data['ammount'] * $this->_option['weeks']; $data['op_count'] = $this->_option['weeks']; $data['option'] = serialize(array('tservice_id' => $this->_option['tservice_id'], 'is_prolong' => $this->_option['is_prolong'])); } } break; // Поднятие закрепления в каталоге услуг // Поднятие закрепления в каталоге услуг case 159: // Лендинг // Лендинг case 160: // Корневой каталог // Корневой каталог case 161: // Раздел // Раздел case 162: // Подраздел // Подраздел case 193: // Оплата из буфера if (!is_emp($this->user['role'])) { //Получаем диф.цену $sum = op_codes_price::getOpCodePrice($op_code, $this->_option['prof_id']); $code['sum'] = $sum ? $sum : $code['sum']; $data = array('ammount' => $code['sum'], 'descr' => '', 'comment' => 'Поднятие закрепления в каталоге услуг', 'service' => 'tservicebindup'); if (!empty($this->_option)) { $data['src_id'] = $this->_option['bind_id']; $data['op_count'] = 1; } } break; } unset($this->_option); // Сбрасываем опции чтобы не путалось при покупке сразу нескольких услуг на странице //Перебиваем примечание к платежу по опкоду (любому и скидочному тоже) if ($_descr = $this->getDescrByOpCode($op_code)) { $data['descr'] = $_descr; } if ($this->promoCode) { $data['promo_code'] = $this->promoCode['id']; if (!isset($this->promoCode['is_original_price'])) { $promoCodes = new PromoCodes(); $data['ammount'] = $data['ammount'] - $promoCodes->getDiscount($this->promoCode, $data['ammount']); //@todo: для чего pro_ammount ? if (isset($data['pro_ammount']) && $data['pro_ammount'] > 0) { $data['pro_ammount'] = $data['pro_ammount'] - $promoCodes->getDiscount($this->promoCode, $data['pro_ammount']); } } } return $data; }
} } $action = 'next'; } elseif ($draft_id && !$drafts->getDraft($draft_id, $uid, 1)) { // если дан id черновика, но такой черновик не существует header("Location: /403.php"); exit; } $account = new account(); $account->GetInfo($uid); $_SESSION['ac_sum'] = $account->sum; $_SESSION['ac_sum_rub'] = $account->sum_rub; $_SESSION['bn_sum'] = $account->bonus_sum; $konk_price = new_projects::getPriceByCode(is_pro() ? new_projects::OPCODE_KON : new_projects::OPCODE_KON_NOPRO); //Определяем доступные коды для покупки $promoCodes = new PromoCodes(); $allowedPromoCodes = array(PromoCodes::SERVICE_PROJECT); if ($kind == projects::KIND_VACANCY) { $allowedPromoCodes[] = PromoCodes::SERVICE_VACANCY; } elseif ($kind == 7) { $allowedPromoCodes[] = PromoCodes::SERVICE_CONTEST; } $promoCodesForm = $promoCodes->render($allowedPromoCodes); switch ($step) { case 2: unset($_SESSION['isExistProjects']); case 1: if (!$PDA) { $js_file = array(); $js_file[] = 'attachedfiles2.js'; $js_file[] = 'public_step_1.js';