Пример #1
0
 public function action_update()
 {
     $name = $this->request->param('id');
     $field = new Model_Field();
     $field_data = $field->get($name);
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit') . ' ' . $name));
     $this->template->title = __('Edit Custom Field for Advertisement');
     //find all, for populating form select fields
     list($categories) = Model_Category::get_all();
     if ($_POST) {
         try {
             $options = array('label' => Core::post('label'), 'tooltip' => Core::post('tooltip'), 'required' => Core::post('required') == 'on' ? TRUE : FALSE, 'searchable' => Core::post('searchable') == 'on' ? TRUE : FALSE);
             if ($field->update($name, Core::post('values'), Core::post('categories'), $options)) {
                 Cache::instance()->delete_all();
                 Theme::delete_minified();
                 Alert::set(Alert::SUCCESS, __('Field edited ' . $name));
                 Request::current()->redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
             } else {
                 Alert::set(Alert::ERROR, __('Field cant be edited' . $name));
             }
         } catch (Exception $e) {
             throw new HTTP_Exception_500();
         }
     }
     $this->template->content = View::factory('oc-panel/pages/fields/update', array('field_data' => $field_data, 'name' => $name, 'categories' => $categories));
 }
Пример #2
0
 public function action_ipn()
 {
     //todo delete
     //paypal::validate_ipn();
     $this->auto_render = FALSE;
     //START PAYPAL IPN
     //manual checks
     $id_order = Core::post('item_number');
     $paypal_amount = Core::post('mc_gross');
     $payer_id = Core::post('payer_id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         //same amount and same currency
         if (Core::post('payment_status') == 'Completed' and Core::post('mc_gross') == number_format($order->amount, 2, '.', '') and Core::post('mc_currency') == $order->currency and Core::post('receiver_email') == core::config('payment.paypal_account') || Core::post('business') == core::config('payment.paypal_account')) {
             //same price , currency and email no cheating ;)
             if (paypal::validate_ipn()) {
                 $order->confirm_payment('paypal', Core::post('txn_id'), NULL, NULL, NULL, Core::post('mc_fee'));
             } else {
                 Kohana::$log->add(Log::ERROR, 'A payment has been made but is flagged as INVALID');
                 $this->response->body('KO');
             }
         } else {
             Kohana::$log->add(Log::ERROR, 'Attempt illegal actions with transaction');
             $this->response->body('KO');
         }
     } else {
         Kohana::$log->add(Log::ERROR, 'Order not loaded');
         $this->response->body('KO');
     }
     $this->response->body('OK');
 }
 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_pay()
 {
     $this->auto_render = FALSE;
     $id_order = $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         // include class vendor
         require Kohana::find_file('vendor/authorize/', 'autoload');
         define('AUTHORIZENET_API_LOGIN_ID', Core::config('payment.authorize_login'));
         define('AUTHORIZENET_TRANSACTION_KEY', Core::config('payment.authorize_key'));
         define('AUTHORIZENET_SANDBOX', Core::config('payment.authorize_sandbox'));
         $sale = new AuthorizeNetAIM();
         $sale->amount = $order->amount;
         $sale->card_num = Core::post('card-number');
         $sale->exp_date = Core::post('expiry-month') . '/' . Core::post('expiry-year');
         $response = $sale->authorizeAndCapture();
         if ($response->approved) {
             $order->confirm_payment('authorize', $response->transaction_id);
             //redirect him to his ads
             Alert::set(Alert::SUCCESS, __('Thanks for your payment!') . ' ' . $response->transaction_id);
             $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
         } else {
             Alert::set(Alert::INFO, $response->error_message);
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
     }
 }
Пример #4
0
 public function action_edit()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Translation')));
     $this->template->title = __('Edit Translation');
     $this->template->bind('content', $content);
     $content = View::factory('oc-panel/pages/translations/edit');
     $this->template->scripts['footer'][] = 'js/oc-panel/translations.js';
     $language = $this->language_fix($this->request->param('id'));
     //get the translated ad not translated.
     list($translation_array, $untranslated_array) = $this->get_translation($language);
     //watch out at any standard php installation there's a limit of 1000 posts....edit php.ini max_input_vars = 10000 to amend it.
     if ($this->request->post() and is_array(Core::post('translations'))) {
         $data_translated = Core::post('translations');
         if ($this->save_translation($language, $translation_array, $data_translated)) {
             Alert::set(Alert::SUCCESS, $language . ' ' . __('Language saved'));
         } else {
             Alert::set(Alert::ALERT, $language);
         }
         $this->redirect(URL::current());
     }
     //add filters to search
     $translation_array_filtered = $translation_array;
     //only display not translated
     if (core::get('translated') == 1) {
         $translation_array_filtered_aux = array();
         foreach ($untranslated_array as $key => $value) {
             $translation_array_filtered_aux[] = $translation_array_filtered[$value];
         }
         $translation_array_filtered = $translation_array_filtered_aux;
     } elseif (core::get('search') !== NULL) {
         $translation_array_filtered_aux = array();
         foreach ($translation_array as $key => $value) {
             if (strpos($value['original'], core::get('search')) !== FALSE or strpos($value['translated'], core::get('search')) !== FALSE) {
                 $translation_array_filtered_aux[] = $value;
             }
         }
         $translation_array_filtered = $translation_array_filtered_aux;
     }
     //how many translated items we have?
     $total_items = count($translation_array_filtered);
     //get elements for current page
     $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $total_items, 'items_per_page' => 20))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action(), 'id' => $language));
     $trans_array_paginated = array();
     $from = $pagination->offset;
     $to = $from + $pagination->items_per_page;
     for ($key = $from; $key < $to; $key++) {
         if (isset($translation_array_filtered[$key])) {
             $trans_array_paginated[$key] = $translation_array_filtered[$key];
         }
     }
     $content->edit_language = $language;
     $content->translation_array = $trans_array_paginated;
     $content->cont_untranslated = count($untranslated_array);
     $content->total_items = count($translation_array);
     $content->pagination = $pagination->render();
 }
Пример #5
0
 public function action_new()
 {
     $this->auto_render = FALSE;
     if (Menu::add(Core::post('title'), Core::post('url'), Core::post('target'), Core::post('icon'))) {
         Alert::set(Alert::SUCCESS, __('Menu created'));
     } else {
         Alert::set(Alert::ERROR, __('Menu not created'));
     }
     Request::current()->redirect(Route::url('oc-panel', array('controller' => 'menu', 'action' => 'index')));
 }
Пример #6
0
 public function action_index()
 {
     // validation active
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List')));
     $this->template->title = __('Translations');
     //scan project files and generate .po
     $parse = $this->request->query('parse');
     if ($parse) {
         //scan script
         require_once Kohana::find_file('vendor', 'POTCreator/POTCreator', 'php');
         $obj = new POTCreator();
         $obj->set_root(DOCROOT);
         $obj->set_exts('php');
         $obj->set_regular('/_[_|e]\\([\\"|\']([^\\"|\']+)[\\"|\']\\)/i');
         $obj->set_base_path('..');
         $obj->set_read_subdir(true);
         $obj->write_pot(i18n::get_language_path());
         Alert::set(Alert::SUCCESS, 'File regenerated');
     }
     //change default site language
     if ($this->request->param('id')) {
         //save language
         $locale = new Model_Config();
         $locale->where('group_name', '=', 'i18n')->where('config_key', '=', 'locale')->limit(1)->find();
         if (!$locale->loaded()) {
             $locale->group_name = 'i18n';
             $locale->config_key = 'locale';
         }
         $locale->config_value = $this->request->param('id');
         try {
             $locale->save();
             Alert::set(Alert::SUCCESS, __('Translations regenarated'));
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations')));
     }
     //create language
     if (Core::post('locale')) {
         $language = $this->request->post('locale');
         $folder = DOCROOT . 'languages/' . $language . '/LC_MESSAGES/';
         // if folder does not exist, try to make it
         if (!file_exists($folder) and !@mkdir($folder, 0775, true)) {
             // mkdir not successful ?
             Alert::set(Alert::ERROR, __('Language folder cannot be created with mkdir. Please correct to be able to create new translation.'));
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations')));
         }
         // write an empty .po file for $language
         $out = 'msgid ""' . PHP_EOL;
         $out .= 'msgstr ""' . PHP_EOL;
         File::write($folder . 'messages.po', $out);
         Alert::set(Alert::SUCCESS, $this->request->param('id') . ' ' . __('Language saved'));
     }
     $this->template->content = View::factory('oc-panel/pages/translations/index', array('languages' => i18n::get_languages(), 'current_language' => core::config('i18n.locale')));
 }
Пример #7
0
 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Newsletter')));
     $this->template->title = __('Newsletter');
     //count all users
     $user = new Model_User();
     $user->where('status', '=', Model_User::STATUS_ACTIVE);
     $count_all_users = $user->count_all();
     //count support expired
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where('status', '=', Model_Order::STATUS_PAID)->where('support_date', '<', Date::unix2mysql())->execute();
     $count_support_expired = $query->as_array();
     $count_support_expired = $count_support_expired[0]['count'];
     //count license expired
     $query = DB::select(DB::expr('COUNT(id_license) count'))->from('licenses')->where('valid_date', 'IS NOT', NULL)->where('valid_date', '<', Date::unix2mysql())->execute();
     $count_license_expired = $query->as_array();
     $count_license_expired = $count_license_expired[0]['count'];
     //orders per product, not accuarate since 1 user could buy more than 1 product but will do
     $query = DB::select(DB::expr('COUNT(id_order) count'))->select('p.title')->select('p.id_product')->from(array('products', 'p'))->join(array('orders', 'o'))->using('id_product')->where('o.status', '=', Model_Order::STATUS_PAID)->group_by('p.id_product')->execute();
     $products = $query->as_array();
     //post done sending newsletter
     if ($this->request->post() and Core::post('subject') != NULL) {
         $users = array();
         if (core::post('send_all') == 'on') {
             $query = DB::select('email')->select('name')->from('users')->where('status', '=', Model_User::STATUS_ACTIVE)->execute();
             $users = array_merge($users, $query->as_array());
         }
         if (Theme::get('premium') == 1) {
             if (core::post('send_expired_support') == 'on') {
                 $query = DB::select('email')->select('name')->from(array('users', 'u'))->join(array('orders', 'o'))->using('id_user')->where('o.status', '=', Model_Order::STATUS_PAID)->where('o.support_date', '<', Date::unix2mysql())->where('u.subscriber', '=', 1)->group_by('u.id_user')->execute();
                 $users = array_merge($users, $query->as_array());
             }
             if (core::post('send_expired_license') == 'on') {
                 $query = DB::select('email')->select('name')->from(array('licenses', 'l'))->join(array('users', 'u'))->using('id_user')->where('l.valid_date', 'IS NOT', NULL)->where('l.valid_date', '<', Date::unix2mysql())->where('u.subscriber', '=', 1)->group_by('u.id_user')->execute();
                 $users = array_merge($users, $query->as_array());
             }
             if (is_numeric(core::post('send_product'))) {
                 $query = DB::select('email')->select('name')->from(array('users', 'u'))->join(array('orders', 'o'))->using('id_user')->where('o.id_product', '=', core::post('send_product'))->where('o.status', '=', Model_Order::STATUS_PAID)->where('u.subscriber', '=', 1)->group_by('u.id_user')->execute();
                 $users = array_merge($users, $query->as_array());
             }
         }
         //NOTE $users may have duplicated emails, but phpmailer takes care of not sending the email 2 times to same recipient
         //sending!
         if (count($users) > 0) {
             if (!Email::send($users, '', Core::post('subject'), Kohana::$_POST_ORIG['description'], Core::post('from'), Core::post('from_email'))) {
                 Alert::set(Alert::ERROR, __('Error on mail delivery, not sent'));
             } else {
                 Alert::set(Alert::SUCCESS, __('Email sent'));
             }
         } else {
             Alert::set(Alert::ERROR, __('Mail not sent'));
         }
     }
     $this->template->content = View::factory('oc-panel/pages/newsletter', array('count_all_users' => $count_all_users, 'count_support_expired' => $count_support_expired, 'count_license_expired' => $count_license_expired, 'products' => $products));
 }
Пример #8
0
 public function action_index()
 {
     $email = Core::post('email_subscribe');
     if (Valid::email($email, TRUE)) {
         /* find user and compare emails */
         $obj_user = new Model_User();
         $user = $obj_user->where('email', '=', $email)->limit(1)->find();
         // case when user is not logged in.
         // We create new user if he doesn't exists in DB
         // and send him mail for ad created + new profile created
         if (!$user->loaded()) {
             $user = Model_User::create_email($email);
         }
         /* save this user to data base as subscriber */
         $arr_cat = Core::post('category_subscribe');
         // string in this case is returned as "int,int" so we need to format min/max price
         $price = Core::post('price_subscribe');
         if ($price = Core::post('price_subscribe')) {
             $min_price = substr($price, '0', stripos($price, ','));
             $max_price = substr($price, strrpos($price, ',') + 1);
         } else {
             //in case of mobile version
             // jquery mobile have different slider, so we need to get data differently
             $min_price = Core::post('price_subscribe-1');
             $max_price = Core::post('price_subscribe-2');
         }
         //if categry is not selected, subscribe them for al, set category to 0 thats all...
         if ($arr_cat === NULL) {
             $arr_cat[] = 0;
         }
         // create entry table subscriber for each category selected
         foreach ($arr_cat as $c => $id_value) {
             $obj_subscribe = new Model_Subscribe();
             $obj_subscribe->id_user = $user->id_user;
             $obj_subscribe->id_category = $id_value;
             $obj_subscribe->id_location = Core::post('location_subscribe');
             $obj_subscribe->min_price = $min_price;
             $obj_subscribe->max_price = $max_price;
             try {
                 $obj_subscribe->save();
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
         }
         Alert::set(Alert::SUCCESS, __('Thank you for subscribing'));
         $this->redirect(Route::url('default'));
     } else {
         Alert::set(Alert::ALERT, __('Invalid Email'));
         $this->redirect(Route::url('default'));
     }
 }
Пример #9
0
 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_pay()
 {
     $this->auto_render = FALSE;
     $id_order = $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         if (isset($_POST['stripeToken'])) {
             //its a fraud...lets let him know
             if ($order->is_fraud() === TRUE) {
                 Alert::set(Alert::ERROR, __('We had, issues with your transaction. Please try paying with another paymethod.'));
                 $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
             }
             // include class vendor
             require Kohana::find_file('vendor/stripe/lib', 'Stripe');
             // Set your secret key: remember to change this to your live secret key in production
             // See your keys here https://manage.stripe.com/account
             Stripe::setApiKey(Core::config('payment.stripe_private'));
             // Get the credit card details submitted by the form
             $token = Core::post('stripeToken');
             // email
             $email = Core::post('stripeEmail');
             // Create the charge on Stripe's servers - this will charge the user's card
             try {
                 $charge = Stripe_Charge::create(array("amount" => StripeKO::money_format($order->amount), "currency" => $order->currency, "card" => $token, "description" => $order->description));
             } catch (Stripe_CardError $e) {
                 // The card has been declined
                 Kohana::$log->add(Log::ERROR, 'Stripe The card has been declined');
                 Alert::set(Alert::ERROR, 'Stripe The card has been declined');
                 $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
             }
             //mark as paid
             $order->confirm_payment('stripe', Core::post('stripeToken'));
             //redirect him to his ads
             Alert::set(Alert::SUCCESS, __('Thanks for your payment!'));
             $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
         } else {
             Alert::set(Alert::INFO, __('Please fill your card details.'));
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
     }
 }
Пример #10
0
 public function action_image()
 {
     $user = Auth::instance()->get_user();
     if (Core::post('photo_delete') and $user->delete_image() == TRUE) {
         Alert::set(Alert::SUCCESS, __('Photo deleted.'));
     } elseif (isset($_FILES['profile_image'])) {
         //get image
         $image = $_FILES['profile_image'];
         //file post
         $result = $user->upload_image($image);
         if ($result === TRUE) {
             Alert::set(Alert::SUCCESS, $image['name'] . ' ' . __('Image is uploaded.'));
         } else {
             Alert::set(Alert::ALERT, $result);
         }
     }
     $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit')));
 }
Пример #11
0
 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_pay()
 {
     $this->auto_render = FALSE;
     $id_order = $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         //its a fraud...lets let him know
         if ($order->is_fraud() === TRUE) {
             Alert::set(Alert::ERROR, __('We had, issues with your transaction. Please try paying with another paymethod.'));
             $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'checkout', 'id' => $order->id_order)));
         }
         //Functions from https://github.com/paymill/paybutton-examples
         $privateApiKey = Core::config('payment.paymill_private');
         if (isset($_POST['paymillToken'])) {
             $token = $_POST['paymillToken'];
             $client = Paymill::request('clients/', array(), $privateApiKey);
             $payment = Paymill::request('payments/', array('token' => $token, 'client' => $client['id']), $privateApiKey);
             $transaction = Paymill::request('transactions/', array('amount' => Paymill::money_format($order->amount), 'currency' => $order->currency, 'client' => $client['id'], 'payment' => $payment['id'], 'description' => $order->product->title), $privateApiKey);
             if (isset($transaction['status']) && $transaction['status'] == 'closed') {
                 //mark as paid
                 $order->confirm_payment('paymill', Core::post('paymillToken'), NULL, NULL, NULL, Paymill::calculate_fee($order->amount));
                 //redirect him to his ads
                 Alert::set(Alert::SUCCESS, __('Thanks for your payment!'));
                 $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'goal', 'id' => $order->id_order)));
             } else {
                 $msg = __('Transaction not successful!');
                 if (!$transaction['status'] == 'closed') {
                     $msg .= ' - ' . $transaction['data']['error'];
                 }
                 Kohana::$log->add(Log::ERROR, 'Paymill ' . $msg);
                 Alert::set(Alert::ERROR, $msg);
                 $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'checkout', 'id' => $order->id_order)));
             }
         } else {
             Alert::set(Alert::INFO, __('Please fill your card details.'));
             $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'checkout', 'id' => $order->id_order)));
     }
 }
Пример #12
0
 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Interactive map')));
     $this->template->title = __('Interactive map');
     $this->template->styles = array('css/map-generator.css' => 'screen');
     $this->template->scripts['footer'][] = '//www.google.com/jsapi';
     $this->template->scripts['footer'][] = '//maps.google.com/maps/api/js?sensor=false';
     $this->template->scripts['footer'][] = 'js/oc-panel/map/jscolor.js';
     $this->template->scripts['footer'][] = 'js/oc-panel/map/map-generator.js';
     $map_active = Core::post('map_active', Core::Config('appearance.map_active'));
     $map_settings = Core::post('current_settings', Core::Config('appearance.map_settings'));
     // change map
     if (Theme::get('premium') == 1 and Core::post('jscode')) {
         Model_Config::set_value('appearance', 'map_active', Core::post('map_active'));
         Model_Config::set_value('appearance', 'map_settings', Core::post('current_settings'));
         Model_Config::set_value('appearance', 'map_jscode', Kohana::$_POST_ORIG['jscode']);
         Core::delete_cache();
         Alert::set(Alert::SUCCESS, __('Map saved.'));
     }
     $this->template->content = View::factory('oc-panel/pages/map', array('map_active' => $map_active, 'map_settings' => $map_settings));
 }
Пример #13
0
 public function action_ipn()
 {
     //todo delete
     //paypal::validate_ipn();
     $this->auto_render = FALSE;
     //START PAYPAL IPN
     //manual checks
     $id_order = Core::post('item_number');
     $paypal_amount = Core::post('mc_gross');
     $payer_id = Core::post('payer_id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         // detect product to be processed
         if (is_numeric($order->id_product)) {
             $id_category = new Model_Category();
             $id_category = $id_category->where('id_category', '=', $order->id_product)->limit(1)->find();
             $product_id = $id_category->id_category;
         } else {
             $product_id = $order->id_product;
         }
         if (Core::post('mc_gross') == number_format($order->amount, 2, '.', '') && Core::post('mc_currency') == core::config('payment.paypal_currency') && (Core::post('receiver_email') == core::config('payment.paypal_account') || Core::post('business') == core::config('payment.paypal_account'))) {
             //same price , currency and email no cheating ;)
             if (paypal::validate_ipn()) {
                 $order->confirm_payment($id_order, core::config('general.moderation'));
             } else {
                 Kohana::$log->add(Log::ERROR, 'A payment has been made but is flagged as INVALID');
                 $this->response->body('KO');
             }
         } else {
             Kohana::$log->add(Log::ERROR, 'Attempt illegal actions with transaction');
             $this->response->body('KO');
         }
     } else {
         Kohana::$log->add(Log::ERROR, 'Order not loaded');
         $this->response->body('KO');
     }
     $this->response->body('OK');
 }
Пример #14
0
 public function action_update()
 {
     $name = $this->request->param('id');
     $menu_data = Menu::get_item($name);
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Menu') . ' ' . $menu_data['title']));
     $this->template->title = __('Edit Menu');
     $this->template->styles = array('css/sortable.css' => 'screen');
     $this->template->scripts['footer'][] = 'js/jquery-sortable-min.js';
     $this->template->scripts['footer'][] = 'js/oc-panel/menu.js';
     //find all, for populating form select fields
     $categories = Model_Category::get_as_array();
     $order_categories = Model_Category::get_multidimensional();
     if ($_POST) {
         if (Menu::update($name, Core::post('title'), Core::post('url'), Core::post('target'), Core::post('icon'))) {
             Alert::set(Alert::SUCCESS, __('Menu updated'));
         } else {
             Alert::set(Alert::ERROR, __('Menu not updated'));
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'menu', 'action' => 'index')));
     }
     // d($categories);
     $this->template->content = View::factory('oc-panel/pages/menu/update', array('menu_data' => $menu_data, 'name' => $name, 'categories' => $categories, 'order_categories' => $order_categories));
 }
Пример #15
0
 public function action_update()
 {
     $name = $this->request->param('id');
     $field = new Model_UserField();
     $field_data = $field->get($name);
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit') . ' ' . $name));
     $this->template->title = __('Edit Custom Field for Advertisement');
     if ($_POST) {
         try {
             $options = array('label' => Core::post('label'), 'tooltip' => Core::post('tooltip'), 'required' => Core::post('required') == 'on' ? TRUE : FALSE, 'searchable' => Core::post('searchable') == 'on' ? TRUE : FALSE, 'show_profile' => Core::post('show_profile') == 'on' ? TRUE : FALSE, 'show_register' => Core::post('show_register') == 'on' ? TRUE : FALSE, 'admin_privilege' => Core::post('admin_privilege') == 'on' ? TRUE : FALSE);
             if ($field->update($name, Core::post('values'), $options)) {
                 Core::delete_cache();
                 Alert::set(Alert::SUCCESS, sprintf(__('Field %s edited'), $name));
             } else {
                 Alert::set(Alert::ERROR, sprintf(__('Field %s cannot be edited'), $name));
             }
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'userfields', 'action' => 'index')));
     }
     $this->template->content = View::factory('oc-panel/pages/userfields/update', array('field_data' => $field_data, 'name' => $name));
 }
Пример #16
0
 public function action_index()
 {
     // validation active
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Newsletter')));
     $this->template->title = __('Newsletter');
     $user = new Model_User();
     $user->where('status', '=', Model_User::STATUS_ACTIVE);
     $user = $user->count_all();
     if ($this->request->post()) {
         $query = DB::select('email')->select('name')->from('users')->where('status', '=', Model_User::STATUS_ACTIVE)->execute();
         $users = $query->as_array();
         if (count($users) > 0 or Core::post('subject') != NULL) {
             if (!Email::send($users, '', Core::post('subject'), Core::post('description'), Core::post('from'), Core::post('from_email'))) {
                 Alert::set(Alert::ERROR, __('Error on mail delivery, not sent'));
             } else {
                 Alert::set(Alert::SUCCESS, __('Email sent to all the users'));
             }
         } else {
             Alert::set(Alert::ERROR, __('Mail not sent'));
         }
     }
     $this->template->content = View::factory('oc-panel/pages/newsletter', array('count' => $user));
 }
Пример #17
0
 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_pay()
 {
     $this->auto_render = FALSE;
     $id_order = $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         //its a fraud...lets let him know
         if ($order->is_fraud() === TRUE) {
             Alert::set(Alert::ERROR, __('We had, issues with your transaction. Please try paying with another paymethod.'));
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
         if (isset($_POST['summarycode'])) {
             $fingerprint = Securepay::fingerprint_validation($order, Core::post('timestamp'), Core::post('summarycode'));
             if (Core::post('summarycode') == 1 and Core::post('fingerprint') == $fingerprint and Core::post('amount') == Securepay::money_format($order->amount)) {
                 //mark as paid
                 $order->confirm_payment('securepay', Core::post('txnid'));
                 //redirect him to his ads
                 Alert::set(Alert::SUCCESS, __('Thanks for your payment!'));
                 $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
             } else {
                 $msg = __('Transaction not successful!') . ' - ' . Core::post('restext');
                 Kohana::$log->add(Log::ERROR, 'Securepay ' . $msg);
                 Alert::set(Alert::ERROR, $msg);
                 $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
             }
         } else {
             Alert::set(Alert::INFO, __('Please fill your card details.'));
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
     }
 }
Пример #18
0
 /**
  * Simple register for user
  *
  */
 public function action_register()
 {
     $this->template->content = View::factory('pages/auth/register');
     $this->template->content->msg = '';
     //if user loged in redirect home
     if (Auth::instance()->logged_in()) {
         $this->redirect(Route::get('oc-panel')->uri());
     } elseif ($this->request->post()) {
         $validation = Validation::factory($this->request->post())->rule('name', 'not_empty')->rule('email', 'not_empty')->rule('email', 'email')->rule('password1', 'not_empty')->rule('password2', 'not_empty')->rule('password1', 'matches', array(':validation', 'password1', 'password2'));
         if ($validation->check()) {
             //posting data so try to remember password
             if (CSRF::valid('register')) {
                 $email = core::post('email');
                 //check we have this email in the DB
                 $user = new Model_User();
                 $user = $user->where('email', '=', $email)->limit(1)->find();
                 if ($user->loaded()) {
                     Form::set_errors(array(__('User already exists')));
                 } else {
                     //creating the user
                     $user = Model_User::create_email($email, core::post('name'), core::post('password1'));
                     //login the user
                     Auth::instance()->login(core::post('email'), core::post('password1'));
                     Alert::set(Alert::SUCCESS, __('Welcome!'));
                     //login the user
                     $this->redirect(Core::post('auth_redirect', Route::url('oc-panel')));
                 }
             }
         } else {
             $errors = $validation->errors('auth');
             foreach ($errors as $error) {
                 Alert::set(Alert::ALERT, $error);
             }
         }
     }
     //template header
     $this->template->title = __('Register new user');
     $this->template->meta_description = __('Create a new profile at') . ' ' . Core::config('general.site_name');
 }
Пример #19
0
 /**
  * Tickets Closed
  * 
  */
 public function action_tickets_closed()
 {
     $this->template->title = __('Tickets Closed');
     Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title)->set_url(Route::url('oc-panel', array('controller' => 'stats', 'action' => 'tickets_closed')) . '?' . http_build_query(['rel' => ''] + Request::current()->query())));
     $this->template->bind('content', $content);
     $content = View::factory('oc-panel/pages/stats/details');
     $content->title = $this->template->title;
     // Getting the dates and range
     $from_date = Core::post('from_date', Core::get('from_date', strtotime('-1 month')));
     $to_date = Core::post('to_date', Core::get('to_date', time()));
     //we assure is a proper time stamp if not we transform it
     if (is_string($from_date) === TRUE) {
         $from_date = strtotime($from_date);
     }
     if (is_string($to_date) === TRUE) {
         $to_date = strtotime($to_date);
     }
     $from_datetime = new DateTime();
     $to_datetime = new DateTime();
     //all  products
     $products = new Model_Product();
     $products = $products->cached()->find_all();
     // Dates displayed
     $content->from_date = date('Y-m-d', $from_date);
     $content->to_date = date('Y-m-d', $to_date);
     $content->days_ago = $from_datetime->setTimestamp($from_date)->diff($to_datetime->setTimestamp($to_date))->format("%a");
     $content->current_by_date = $this->tickets_closed_by_date($from_date, $to_date);
     $content->current_total = $this->tickets_closed_total($from_date, $to_date);
     $content->past_total = $this->tickets_closed_total($from_date, $to_date, TRUE);
     $content->month_ago_total = $this->tickets_closed_total(strtotime('-1 months'), time());
     $content->past_month_ago_total = $this->tickets_closed_total(strtotime('-1 months'), time(), TRUE);
     $content->three_months_ago_total = $this->tickets_closed_total(strtotime('-3 months'), time());
     $content->past_three_months_ago_total = $this->tickets_closed_total(strtotime('-3 months'), time(), TRUE);
     $content->six_months_ago_total = $this->tickets_closed_total(strtotime('-6 months'), time());
     $content->past_six_months_ago_total = $this->tickets_closed_total(strtotime('-6 months'), time(), TRUE);
     $content->twelve_months_ago_total = $this->tickets_closed_total(strtotime('-12 months'), time());
     $content->twelve_six_months_ago_total = $this->tickets_closed_total(strtotime('-12 months'), time(), TRUE);
     $content->num_format = 'INTEGER';
 }
Пример #20
0
 public function action_index()
 {
     //if not god redirect him to the normal profile page
     if (Auth::instance()->get_user()->id_role != Model_Role::ROLE_ADMIN) {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
     }
     Core::ocacu();
     $this->template->title = __('Welcome');
     Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
     $this->template->bind('content', $content);
     $content = View::factory('oc-panel/home');
     /////////////////////RSS////////////////////////////////
     //try to get the RSS from the cache
     $rss_url = 'http://feeds.feedburner.com/OpenClassifieds';
     $content->rss = Feed::parse($rss_url, 10);
     /////////////////////ADS////////////////////////////////
     $content->res = new Model_Ad();
     //filter ads by status
     $content->res = $content->res->where('status', '=', Core::get('status', Model_Ad::STATUS_PUBLISHED));
     $content->res = $content->res->order_by('created', 'desc')->limit(10)->find_all();
     /////////////////////STATS////////////////////////////////
     //Getting the dates and range
     $from_date = Core::post('from_date', strtotime('-1 month'));
     $to_date = Core::post('to_date', time());
     //we assure is a proper time stamp if not we transform it
     if (is_string($from_date) === TRUE) {
         $from_date = strtotime($from_date);
     }
     if (is_string($to_date) === TRUE) {
         $to_date = strtotime($to_date);
     }
     //mysql formated dates
     $my_from_date = Date::unix2mysql($from_date);
     $my_to_date = Date::unix2mysql($to_date);
     //dates range we are filtering
     $dates = Date::range($from_date, $to_date, '+1 day', 'Y-m-d', array('date' => 0, 'count' => 0), 'date');
     //dates displayed in the form
     $content->from_date = date('Y-m-d', $from_date);
     $content->to_date = date('Y-m-d', $to_date);
     //ads published last XX days
     $query = DB::select(DB::expr('DATE(published) date'))->select(DB::expr('COUNT(id_ad) count'))->from('ads')->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('published', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( published )'))->order_by('date', 'asc')->execute();
     $ads_dates = $query->as_array('date');
     //Today
     $query = DB::select(DB::expr('COUNT(id_ad) count'))->from('ads')->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where(DB::expr('DATE( created )'), '=', DB::expr('CURDATE()'))->group_by(DB::expr('DATE( published )'))->order_by('published', 'asc')->execute();
     $ads = $query->as_array();
     $content->ads_today = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Yesterday
     $query = DB::select(DB::expr('COUNT(id_ad) count'))->from('ads')->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where(DB::expr('DATE( created )'), '=', date('Y-m-d', strtotime('-1 day')))->group_by(DB::expr('DATE( published )'))->order_by('published', 'asc')->execute();
     $ads = $query->as_array();
     $content->ads_yesterday = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Last 30 days ads
     $query = DB::select(DB::expr('COUNT(id_ad) count'))->from('ads')->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('published', 'between', array(date('Y-m-d', strtotime('-30 day')), date::unix2mysql()))->execute();
     $ads = $query->as_array();
     $content->ads_month = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //total ads
     $query = DB::select(DB::expr('COUNT(id_ad) count'))->from('ads')->where('status', '=', Model_Ad::STATUS_PUBLISHED)->execute();
     $ads = $query->as_array();
     $content->ads_total = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     /////////////////////VISITS STATS////////////////////////////////
     //visits created last XX days
     $query = DB::select(DB::expr('DATE(created) date'))->select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('created', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( created )'))->order_by('date', 'asc')->execute();
     $visits = $query->as_array('date');
     $stats_daily = array();
     foreach ($dates as $date) {
         $count_views = isset($visits[$date['date']]['count']) ? $visits[$date['date']]['count'] : 0;
         $count_ads = isset($ads_dates[$date['date']]['count']) ? $ads_dates[$date['date']]['count'] : 0;
         $stats_daily[] = array('date' => $date['date'], 'views' => $count_views, 'ads' => $count_ads);
     }
     $content->stats_daily = $stats_daily;
     //Today
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where(DB::expr('DATE( created )'), '=', DB::expr('CURDATE()'))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $ads = $query->as_array();
     $content->visits_today = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Yesterday
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where(DB::expr('DATE( created )'), '=', date('Y-m-d', strtotime('-1 day')))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $ads = $query->as_array();
     $content->visits_yesterday = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Last 30 days visits
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('created', 'between', array(date('Y-m-d', strtotime('-30 day')), date::unix2mysql()))->execute();
     $visits = $query->as_array();
     $content->visits_month = isset($visits[0]['count']) ? $visits[0]['count'] : 0;
     //total visits
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->execute();
     $visits = $query->as_array();
     $content->visits_total = isset($visits[0]['count']) ? $visits[0]['count'] : 0;
     /////////////////////ORDERS STATS////////////////////////////////
     //orders created last XX days
     $query = DB::select(DB::expr('DATE(created) date'))->select(DB::expr('COUNT(id_order) count'))->select(DB::expr('SUM(amount) total'))->from('orders')->where('created', 'between', array($my_from_date, $my_to_date))->where('status', '=', Model_Order::STATUS_PAID)->group_by(DB::expr('DATE( created )'))->order_by('date', 'asc')->execute();
     $orders = $query->as_array('date');
     $stats_orders = array();
     foreach ($dates as $date) {
         $count_orders = isset($orders[$date['date']]['count']) ? $orders[$date['date']]['count'] : 0;
         $count_sum = isset($orders[$date['date']]['total']) ? $orders[$date['date']]['total'] : 0;
         $stats_orders[] = array('date' => $date['date'], '#orders' => $count_orders, '$' => $count_sum);
     }
     $content->stats_orders = $stats_orders;
     //Today
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where(DB::expr('DATE( created )'), '=', DB::expr('CURDATE()'))->where('status', '=', Model_Order::STATUS_PAID)->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $ads = $query->as_array();
     $content->orders_yesterday = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Yesterday
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where(DB::expr('DATE( created )'), '=', date('Y-m-d', strtotime('-1 day')))->where('status', '=', Model_Order::STATUS_PAID)->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $ads = $query->as_array();
     $content->orders_today = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Last 30 days orders
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where('created', 'between', array(date('Y-m-d', strtotime('-30 day')), date::unix2mysql()))->where('status', '=', Model_Order::STATUS_PAID)->execute();
     $orders = $query->as_array();
     $content->orders_month = isset($orders[0]['count']) ? $orders[0]['count'] : 0;
     //total orders
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where('status', '=', Model_Order::STATUS_PAID)->execute();
     $orders = $query->as_array();
     $content->orders_total = isset($orders[0]['count']) ? $orders[0]['count'] : 0;
 }
Пример #21
0
                        <?php 
    echo FORM::textarea('message', "", array('class' => 'form-control', 'placeholder' => __('Message'), 'name' => 'message', 'id' => 'message', 'rows' => 2, 'required'));
    ?>
 
                    </div>
                </div>
                <?php 
    if (core::config('general.messaging') and core::config('advertisement.price') and core::config('advertisement.contact_price')) {
        ?>
                    <div class="form-group">
                        <div class="col-xs-12">
                            <?php 
        echo FORM::label('price', _e('Price'), array('class' => 'control-label', 'for' => 'price'));
        ?>
                            <?php 
        echo FORM::input('price', Core::post('price'), array('placeholder' => html_entity_decode(i18n::money_format(1)), 'class' => 'form-control', 'id' => 'price', 'type' => 'text'));
        ?>
                        </div>
                    </div>
                <?php 
    }
    ?>
                <!-- file to be sent-->
                <?php 
    if (core::config('advertisement.upload_file') and core::config('general.messaging') != TRUE) {
        ?>
                    <div class="form-group">
                        <div class="col-xs-12">
                            <?php 
        echo FORM::label('file', _e('File'), array('class' => 'control-label', 'for' => 'file'));
        ?>
Пример #22
0
 public function action_stats()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('My ads'))->set_url(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index'))));
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Stats')));
     Controller::$full_width = TRUE;
     $this->template->scripts['footer'] = array('js/chart.min.js', 'js/chart.js-php.js', 'js/oc-panel/stats/dashboard.js');
     $this->template->title = __('Stats');
     $this->template->bind('content', $content);
     $content = View::factory('oc-panel/profile/stats');
     $list_ad = array();
     $advert = new Model_Ad();
     //single stats for 1 ad
     if (is_numeric($id_ad = $this->request->param('id'))) {
         $advert = new Model_Ad($id_ad);
         if ($advert->loaded()) {
             //if admin or moderator user is the advert user ;) hack!!
             if ($this->user->id_role == Model_Role::ROLE_ADMIN or $this->user->id_role == Model_Role::ROLE_MODERATOR) {
                 $user = $advert->user;
             } else {
                 $user = $this->user;
             }
             if ($user->id_user !== $advert->id_user) {
                 Alert::set(Alert::ALERT, __("This is not your advertisement."));
                 HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
             }
             Breadcrumbs::add(Breadcrumb::factory()->set_title($advert->title));
             // make a list of 1 ad (array), and than pass this array to query (IN).. To get correct visits
             $list_ad[] = $id_ad;
         }
     }
     //we didnt filter by ad, so lets get them all!
     if (empty($list_ad)) {
         $ads = new Model_Ad();
         $collection_of_user_ads = $ads->where('id_user', '=', $this->user->id_user)->find_all();
         $list_ad = array();
         foreach ($collection_of_user_ads as $key) {
             // make a list of ads (array), and than pass this array to query (IN).. To get correct visits
             $list_ad[] = $key->id_ad;
         }
     }
     // if user doesn't have any ads
     if (empty($list_ad)) {
         $list_ad = array(NULL);
     }
     $content->advert = $advert;
     //Getting the dates and range
     $from_date = Core::post('from_date', strtotime('-1 month'));
     $to_date = Core::post('to_date', time());
     //we assure is a proper time stamp if not we transform it
     if (is_string($from_date) === TRUE) {
         $from_date = strtotime($from_date);
     }
     if (is_string($to_date) === TRUE) {
         $to_date = strtotime($to_date);
     }
     //mysql formated dates
     $my_from_date = Date::unix2mysql($from_date);
     $my_to_date = Date::unix2mysql($to_date);
     //dates range we are filtering
     $dates = Date::range($from_date, $to_date, '+1 day', 'Y-m-d', array('date' => 0, 'count' => 0), 'date');
     //dates displayed in the form
     $content->from_date = date('Y-m-d', $from_date);
     $content->to_date = date('Y-m-d', $to_date);
     /////////////////////CONTACT STATS////////////////////////////////
     //visits created last XX days
     $query = DB::select(DB::expr('DATE(created) date'))->select(DB::expr('COUNT(contacted) count'))->from('visits')->where('contacted', '=', 1)->where('id_ad', 'in', $list_ad)->where('created', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( created )'))->order_by('date', 'asc')->execute();
     $contacts_dates = $query->as_array('date');
     //Today
     $query = DB::select(DB::expr('COUNT(contacted) count'))->from('visits')->where('contacted', '=', 1)->where('id_ad', 'in', $list_ad)->where(DB::expr('DATE( created )'), '=', DB::expr('CURDATE()'))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $contacts = $query->as_array();
     $content->contacts_today = isset($contacts[0]['count']) ? $contacts[0]['count'] : 0;
     //Yesterday
     $query = DB::select(DB::expr('COUNT(contacted) count'))->from('visits')->where('contacted', '=', 1)->where('id_ad', 'in', $list_ad)->where(DB::expr('DATE( created )'), '=', date('Y-m-d', strtotime('-1 day')))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $contacts = $query->as_array();
     $content->contacts_yesterday = isset($contacts[0]['count']) ? $contacts[0]['count'] : 0;
     //
     //Last 30 days contacts
     $query = DB::select(DB::expr('COUNT(contacted) count'))->from('visits')->where('contacted', '=', 1)->where('id_ad', 'in', $list_ad)->where('created', 'between', array(date('Y-m-d', strtotime('-30 day')), date::unix2mysql()))->execute();
     $contacts = $query->as_array();
     $content->contacts_month = isset($contacts[0]['count']) ? $contacts[0]['count'] : 0;
     //total contacts
     $query = DB::select(DB::expr('COUNT(contacted) count'))->where('contacted', '=', 1)->where('id_ad', 'in', $list_ad)->from('visits')->execute();
     $contacts = $query->as_array();
     $content->contacts_total = isset($contacts[0]['count']) ? $contacts[0]['count'] : 0;
     /////////////////////VISITS STATS////////////////////////////////
     //visits created last XX days
     $query = DB::select(DB::expr('DATE(created) date'))->select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('id_ad', 'in', $list_ad)->where('created', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( created )'))->order_by('date', 'asc')->execute();
     $visits = $query->as_array('date');
     $stats_daily = array();
     foreach ($dates as $date) {
         $count_contants = isset($contacts_dates[$date['date']]['count']) ? $contacts_dates[$date['date']]['count'] : 0;
         $count_visits = isset($visits[$date['date']]['count']) ? $visits[$date['date']]['count'] : 0;
         $stats_daily[] = array('date' => $date['date'], 'views' => $count_visits, 'contacts' => $count_contants);
     }
     $content->stats_daily = $stats_daily;
     //Today
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('id_ad', 'in', $list_ad)->where(DB::expr('DATE( created )'), '=', DB::expr('CURDATE()'))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $visits = $query->as_array();
     $content->visits_today = isset($visits[0]['count']) ? $visits[0]['count'] : 0;
     //Yesterday
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('id_ad', 'in', $list_ad)->where(DB::expr('DATE( created )'), '=', date('Y-m-d', strtotime('-1 day')))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $visits = $query->as_array();
     $content->visits_yesterday = isset($visits[0]['count']) ? $visits[0]['count'] : 0;
     //Last 30 days visits
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('id_ad', 'in', $list_ad)->where('created', 'between', array(date('Y-m-d', strtotime('-30 day')), date::unix2mysql()))->execute();
     $visits = $query->as_array();
     $content->visits_month = isset($visits[0]['count']) ? $visits[0]['count'] : 0;
     //total visits
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->where('id_ad', 'in', $list_ad)->from('visits')->execute();
     $visits = $query->as_array();
     $content->visits_total = isset($visits[0]['count']) ? $visits[0]['count'] : 0;
 }
Пример #23
0
 /**
  * gets the payment token from stripe and marks order as paid. Methos for application fee
  */
 public function action_payconnect()
 {
     //TODO only if stripe connect enabled
     $this->auto_render = FALSE;
     $id_order = $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->where('id_product', '=', Model_Order::PRODUCT_AD_SELL)->limit(1)->find();
     if ($order->loaded()) {
         if (isset($_POST['stripeToken'])) {
             //its a fraud...lets let him know
             if ($order->is_fraud() === TRUE) {
                 Alert::set(Alert::ERROR, __('We had, issues with your transaction. Please try paying with another paymethod.'));
                 $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
             }
             StripeKO::init();
             // Get the credit card details submitted by the form
             $token = Core::post('stripeToken');
             // email
             $email = Core::post('stripeEmail');
             // Create the charge on Stripe's servers - this will charge the user's card
             try {
                 //in case memberships the fee may be set on the plan ;)
                 $fee = NULL;
                 if ($order->ad->user->subscription()->loaded()) {
                     $fee = $order->ad->user->subscription()->plan->marketplace_fee;
                 }
                 $application_fee = StripeKO::application_fee($order->amount, $fee);
                 //we charge the fee only if its not admin
                 if (!$order->ad->user->is_admin()) {
                     $charge = \Stripe\Charge::create(array("amount" => StripeKO::money_format($order->amount), "currency" => $order->currency, "card" => $token, "description" => $order->description, "application_fee" => StripeKO::money_format($application_fee)), array('stripe_account' => $order->ad->user->stripe_user_id));
                 } else {
                     $charge = \Stripe\Charge::create(array("amount" => StripeKO::money_format($order->amount), "currency" => $order->currency, "card" => $token, "description" => $order->description));
                 }
             } catch (Exception $e) {
                 // The card has been declined
                 Kohana::$log->add(Log::ERROR, 'Stripe The card has been declined');
                 Alert::set(Alert::ERROR, 'Stripe The card has been declined');
                 $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
             }
             //mark as paid
             $order->confirm_payment('stripe', Core::post('stripeToken'));
             //only if is not admin
             if (!$order->ad->user->is_admin()) {
                 //crete new order for the application fee so we know how much the site owner is earning ;)
                 $order_app = Model_Order::new_order($order->ad, $order->ad->user, Model_Order::PRODUCT_APP_FEE, $application_fee, core::config('payment.paypal_currency'), 'id_order->' . $order->id_order . ' id_ad->' . $order->ad->id_ad);
                 $order_app->confirm_payment('stripe', Core::post('stripeToken'));
             }
             //redirect him to his ads
             Alert::set(Alert::SUCCESS, __('Thanks for your payment!'));
             $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
         } else {
             Alert::set(Alert::INFO, __('Please fill your card details.'));
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
     }
 }
Пример #24
0
 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Stats')));
     //local files
     if (Theme::get('cdn_files') == FALSE) {
         $this->template->styles = array('css/datepicker.css' => 'screen');
         $this->template->scripts['footer'] = array('js/bootstrap-datepicker.js', 'js/oc-panel/stats/dashboard.js');
     } else {
         $this->template->styles = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/css/datepicker.css' => 'screen');
         $this->template->scripts['footer'] = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/js/bootstrap-datepicker.js', 'js/oc-panel/stats/dashboard.js');
     }
     $this->template->title = __('Stats');
     $this->template->bind('content', $content);
     $content = View::factory('oc-panel/pages/stats/dashboard');
     //Getting the dates and range
     $from_date = Core::post('from_date', strtotime('-1 month'));
     $to_date = Core::post('to_date', time());
     //we assure is a proper time stamp if not we transform it
     if (is_string($from_date) === TRUE) {
         $from_date = strtotime($from_date);
     }
     if (is_string($to_date) === TRUE) {
         $to_date = strtotime($to_date);
     }
     //mysql formated dates
     $my_from_date = Date::unix2mysql($from_date);
     $my_to_date = Date::unix2mysql($to_date);
     //dates range we are filtering
     $dates = Date::range($from_date, $to_date, '+1 day', 'Y-m-d', array('date' => 0, 'count' => 0), 'date');
     //dates displayed in the form
     $content->from_date = date('Y-m-d', $from_date);
     $content->to_date = date('Y-m-d', $to_date);
     //ads published last XX days
     $query = DB::select(DB::expr('DATE(published) date'))->select(DB::expr('COUNT(id_ad) count'))->from('ads')->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('published', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( published )'))->order_by('date', 'asc')->execute();
     $ads_dates = $query->as_array('date');
     //Today
     $query = DB::select(DB::expr('COUNT(id_ad) count'))->from('ads')->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where(DB::expr('DATE( created )'), '=', DB::expr('CURDATE()'))->group_by(DB::expr('DATE( published )'))->order_by('published', 'asc')->execute();
     $ads = $query->as_array();
     $content->ads_today = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Yesterday
     $query = DB::select(DB::expr('COUNT(id_ad) count'))->from('ads')->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where(DB::expr('DATE( created )'), '=', date('Y-m-d', strtotime('-1 day')))->group_by(DB::expr('DATE( published )'))->order_by('published', 'asc')->execute();
     $ads = $query->as_array();
     $content->ads_yesterday = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Last 30 days ads
     $query = DB::select(DB::expr('COUNT(id_ad) count'))->from('ads')->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('published', 'between', array(date('Y-m-d', strtotime('-30 day')), date::unix2mysql()))->execute();
     $ads = $query->as_array();
     $content->ads_month = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //total ads
     $query = DB::select(DB::expr('COUNT(id_ad) count'))->from('ads')->where('status', '=', Model_Ad::STATUS_PUBLISHED)->execute();
     $ads = $query->as_array();
     $content->ads_total = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     /////////////////////VISITS STATS////////////////////////////////
     //visits created last XX days
     $query = DB::select(DB::expr('DATE(created) date'))->select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('created', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( created )'))->order_by('date', 'asc')->execute();
     $visits = $query->as_array('date');
     $stats_daily = array();
     foreach ($dates as $date) {
         $count_views = isset($visits[$date['date']]['count']) ? $visits[$date['date']]['count'] : 0;
         $count_ads = isset($ads_dates[$date['date']]['count']) ? $ads_dates[$date['date']]['count'] : 0;
         $stats_daily[] = array('date' => $date['date'], 'views' => $count_views, 'ads' => $count_ads);
     }
     $content->stats_daily = $stats_daily;
     //Today
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where(DB::expr('DATE( created )'), '=', DB::expr('CURDATE()'))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $ads = $query->as_array();
     $content->visits_today = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Yesterday
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where(DB::expr('DATE( created )'), '=', date('Y-m-d', strtotime('-1 day')))->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $ads = $query->as_array();
     $content->visits_yesterday = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Last 30 days visits
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('created', 'between', array(date('Y-m-d', strtotime('-30 day')), date::unix2mysql()))->execute();
     $visits = $query->as_array();
     $content->visits_month = isset($visits[0]['count']) ? $visits[0]['count'] : 0;
     //total visits
     $query = DB::select(DB::expr('COUNT(id_visit) count'))->from('visits')->execute();
     $visits = $query->as_array();
     $content->visits_total = isset($visits[0]['count']) ? $visits[0]['count'] : 0;
     /////////////////////ORDERS STATS////////////////////////////////
     //orders created last XX days
     $query = DB::select(DB::expr('DATE(created) date'))->select(DB::expr('COUNT(id_order) count'))->select(DB::expr('SUM(amount) total'))->from('orders')->where('created', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( created )'))->order_by('date', 'asc')->execute();
     $orders = $query->as_array('date');
     $stats_orders = array();
     foreach ($dates as $date) {
         $count_orders = isset($orders[$date['date']]['count']) ? $orders[$date['date']]['count'] : 0;
         $count_sum = isset($orders[$date['date']]['total']) ? $orders[$date['date']]['total'] : 0;
         $stats_orders[] = array('date' => $date['date'], '#orders' => $count_orders, '$' => $count_sum);
     }
     $content->stats_orders = $stats_orders;
     //Today
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where(DB::expr('DATE( created )'), '=', DB::expr('CURDATE()'))->where('status', '=', Model_Order::STATUS_PAID)->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $ads = $query->as_array();
     $content->orders_yesterday = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Yesterday
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where(DB::expr('DATE( created )'), '=', date('Y-m-d', strtotime('-1 day')))->where('status', '=', Model_Order::STATUS_PAID)->group_by(DB::expr('DATE( created )'))->order_by('created', 'asc')->execute();
     $ads = $query->as_array();
     $content->orders_today = isset($ads[0]['count']) ? $ads[0]['count'] : 0;
     //Last 30 days orders
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where('created', 'between', array(date('Y-m-d', strtotime('-30 day')), date::unix2mysql()))->where('status', '=', Model_Order::STATUS_PAID)->execute();
     $orders = $query->as_array();
     $content->orders_month = isset($orders[0]['count']) ? $orders[0]['count'] : 0;
     //total orders
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where('status', '=', Model_Order::STATUS_PAID)->execute();
     $orders = $query->as_array();
     $content->orders_total = isset($orders[0]['count']) ? $orders[0]['count'] : 0;
 }
Пример #25
0
									</div>
								</div>
							<?php 
    }
    ?>
							<!-- Set Stock Levels? -->
							<?php 
    if (core::config('payment.stock')) {
        ?>
								<div class="col-xs-6">
									<?php 
        echo FORM::label('stock', _e('In Stock'), array('for' => 'stock'));
        ?>
									<div class="input-prepend">
										<?php 
        echo FORM::input('stock', Core::post('stock', 1), array('placeholder' => '10', 'class' => 'form-control fc-small', 'id' => 'stock', 'type' => 'text'));
        ?>
									</div>
								</div>
							<?php 
    }
    ?>
						</div>	
					<?php 
}
?>
			
					<!-- ad description -->
					<?php 
if ($form_show['description'] != FALSE) {
    ?>
Пример #26
0
 /**
  * deletes all the locations
  * @return void 
  */
 public function action_delete_all()
 {
     if (core::post('confirmation')) {
         //delete location icons
         $locations = new Model_Location();
         if ($id_location = intval(Core::post('id_location')) and $id_location > 0) {
             $selected_location = new Model_Location($id_location);
             $locations->where('id_location', 'in', $selected_location->get_siblings_ids())->where('id_location', '!=', $selected_location->id_location);
         } else {
             $locations->where('id_location', '!=', '1')->find_all();
         }
         $locations = $locations->find_all();
         foreach ($locations as $location) {
             $root = DOCROOT . 'images/locations/';
             //root folder
             if (is_dir($root)) {
                 @unlink($root . $location->seoname . '.png');
                 // delete icon from Amazon S3
                 if (core::config('image.aws_s3_active')) {
                     $s3->deleteObject(core::config('image.aws_s3_bucket'), 'images/locations/' . $location->seoname . '.png');
                 }
             }
         }
         $query_update = DB::update('ads');
         $query_delete = DB::delete('locations');
         if ($id_location = intval(Core::post('id_location')) and $id_location > 0) {
             $query_update->set(array('id_location' => $selected_location->id_location));
             $query_delete->where('id_location', 'in', $selected_location->get_siblings_ids())->where('id_location', '!=', $selected_location->id_location);
         } else {
             $query_update->set(array('id_location' => '1'));
             $query_delete->where('id_location', '!=', '1');
         }
         $query_update->execute();
         $query_delete->execute();
         Core::delete_cache();
         Alert::set(Alert::SUCCESS, __('All locations were deleted.'));
     } else {
         Alert::set(Alert::ERROR, __('You did not confirmed your delete action.'));
     }
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'location', 'action' => 'index')));
 }
Пример #27
0
                                    <?php 
echo FORM::label('subject', __('Subject'), array('class' => 'col-sm-2 control-label', 'for' => 'subject'));
?>
                                    <div class="col-md-4 ">
                                        <?php 
echo FORM::input('subject', Core::post('subject'), array('placeholder' => __('Subject'), 'class' => 'form-control', 'id' => 'subject'));
?>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <?php 
echo FORM::label('message', __('Message'), array('class' => 'col-sm-2 control-label', 'for' => 'message'));
?>
                                    <div class="col-md-6">
                                        <?php 
echo FORM::textarea('message', Core::post('message'), array('class' => 'form-control', 'placeholder' => __('Message'), 'name' => 'message', 'id' => 'message', 'rows' => 2, 'required'));
?>
	
                                    </div>
                                </div>
                                <!-- file to be sent-->
                                <?if(core::config('advertisement.upload_file')):?>
                                    <div class="form-group">
                                        <?php 
echo FORM::label('file', __('File'), array('class' => 'col-sm-2 control-label', 'for' => 'file'));
?>
                                        <div class="col-md-6">
                                            <?php 
echo FORM::file('file', array('placeholder' => __('File'), 'class' => 'form-control', 'id' => 'file'));
?>
                                        </div>
Пример #28
0
 /**
  * Simple register for user
  *
  */
 public function action_register()
 {
     //validates captcha
     if (Core::post('ajaxValidateCaptcha')) {
         $this->auto_render = FALSE;
         $this->template = View::factory('js');
         if (captcha::check('register', TRUE)) {
             $this->template->content = 'true';
         } else {
             $this->template->content = 'false';
         }
         return;
     }
     $this->template->meta_description = __('Create a new profile at') . ' ' . core::config('general.site_name');
     $this->template->content = View::factory('pages/auth/register');
     $this->template->content->msg = '';
     //if user loged in redirect home
     if (Auth::instance()->logged_in()) {
         $this->redirect(Route::get('oc-panel')->uri());
     } elseif ($this->request->post()) {
         if (captcha::check('register')) {
             $validation = Validation::factory($this->request->post())->rule('name', 'not_empty')->rule('email', 'not_empty')->rule('email', 'email')->rule('email', 'email_domain')->rule('password1', 'not_empty')->rule('password2', 'not_empty')->rule('password1', 'matches', array(':validation', 'password1', 'password2'));
             if (core::post('cf_vatnumber') and core::post('cf_vatcountry')) {
                 if (!euvat::verify_vies(core::post('cf_vatnumber'), core::post('cf_vatcountry'))) {
                     Alert::set(Alert::ERROR, __('Invalid EU Vat Number, please verify number and country match'));
                     $this->redirect(Route::url('oc-panel', array('controller' => 'auth', 'action' => 'register')));
                 }
             }
             if ($validation->check()) {
                 //posting data so try to remember password
                 if (CSRF::valid('register')) {
                     $email = core::post('email');
                     //check we have this email in the DB
                     $user = new Model_User();
                     $user = $user->where('email', '=', $email)->limit(1)->find();
                     if ($user->loaded()) {
                         Form::set_errors(array(__('User already exists')));
                     } else {
                         //creating the user
                         $user = Model_User::create_email($email, core::post('name'), core::post('password1'));
                         //add custom fields
                         $save_cf = FALSE;
                         foreach ($this->request->post() as $custom_field => $value) {
                             if (strpos($custom_field, 'cf_') !== FALSE) {
                                 $user->{$custom_field} = $value;
                                 $save_cf = TRUE;
                             }
                         }
                         //saves the user only if there was CF
                         if ($save_cf === TRUE) {
                             $user->save();
                         }
                         //login the user
                         Auth::instance()->login(core::post('email'), core::post('password1'));
                         Alert::set(Alert::SUCCESS, __('Welcome!'));
                         //login the user
                         $this->redirect(Core::post('auth_redirect', Route::url('oc-panel')));
                     }
                 }
             } else {
                 $errors = $validation->errors('auth');
                 foreach ($errors as $error) {
                     Alert::set(Alert::ALERT, $error);
                 }
             }
         } else {
             Alert::set(Alert::ALERT, __('Captcha is not correct'));
         }
     }
     //template header
     $this->template->title = __('Register new user');
 }
Пример #29
0
 public function action_template()
 {
     if ($_POST) {
         $cf_templates = '
                         {
                             "cars": [
                                 {
                                     "name": "forsaleby",
                                     "type": "select",
                                     "label": "For sale by",
                                     "tooltip": "For sale by",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Owner,Dealer"
                                 },
                                 {
                                     "name": "adtype",
                                     "type": "select",
                                     "label": "Ad type",
                                     "tooltip": "Ad type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": "I’m selling my car,I’m looking for a car to buy"
                                 },
                                 {
                                     "name": "make",
                                     "type": "select",
                                     "label": "Make",
                                     "tooltip": "Make",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Acura,Alfa Romeo,AM General,AMC,Aston Martin,Audi,Austin-Healey,Bently,BMW,Bricklin,Bugatti,Buick,Cadillac,Chevrolet,Chrysler,Daewoo,Datsun,Diahatsu,Dodge,Eagle,Ferrari,Fiat,Ford,Geo,GMC,Honda,HUMMER,Hyundai,Infiniti,International Harvester,Isuzu,Jaguar,Jeep,Kia,Lamborghini,Land Rover,Lexus,Lincoln,Lotus,Maserati,Maybach,Mazda,Mercedes-Benz,Mercury,MG,MINI,Mitsubishi,Nissan,Oldsmobile,Opel,Peugeot,Plymouth,Pontiac,Porsche,Ram,Renault,Rolls-Royce,Saab,Saturn,Scion,Shelby,Smart,Subaru,Suzuki,Toyota,Triumph,Volkswagen,Volvo,Other"
                                 },
                                 {
                                     "name": "othermake",
                                     "type": "string",
                                     "label": "Other make",
                                     "tooltip": "Other make",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "model",
                                     "type": "string",
                                     "label": "Model",
                                     "tooltip": "Model",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "year",
                                     "type": "integer",
                                     "label": "Year",
                                     "tooltip": "Year",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "kilometers",
                                     "type": "integer",
                                     "label": "Kilometers",
                                     "tooltip": "Kilometers",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "bodytype",
                                     "type": "select",
                                     "label": "Body type",
                                     "tooltip": "Body type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Convertible,Coupe (2 door),Hatchback,Minivan or Van,Pickup Truck,Sedan,SUV. crossover,Wagon,Other"
                                 },
                                 {
                                     "name": "transmission",
                                     "type": "select",
                                     "label": "Transmission",
                                     "tooltip": "Transmission",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Automatic,Manual,Other"
                                 },
                                 {
                                     "name": "drivetrain",
                                     "type": "select",
                                     "label": "Drivetrain",
                                     "tooltip": "Drivetrain",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "4 x 4,All-wheel drive (AWD),Front-wheel drive (FWD),Rear-wheel drive (RWD),Other"
                                 },
                                 {
                                     "name": "color",
                                     "type": "select",
                                     "label": "Color",
                                     "tooltip": "Color",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Black,Blue,Brown,Burgundy,Gold,Green,Grey,Orange,Pink,Purple,Red,Silver,Tan,Teal,White,Yellow,Other"
                                 },
                                 {
                                     "name": "fueltype",
                                     "type": "select",
                                     "label": "Fuel Type",
                                     "tooltip": "Fuel Type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Diesel,Gasoline,Hybrid-Electric,Other"
                                 },
                                 {
                                     "name": "type",
                                     "type": "select",
                                     "label": "Type",
                                     "tooltip": "Type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Damaged,Lease Takeover,New,Used"
                                 }
                             ],
                             "houses": [
                                 {
                                     "name": "furnished",
                                     "type": "select",
                                     "label": "Furnished",
                                     "tooltip": "Furnished",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Yes,No"
                                 },
                                 {
                                     "name": "bedrooms",
                                     "type": "select",
                                     "label": "Bedrooms",
                                     "tooltip": "Bedrooms",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Studio,1,2,3,4,5,6,7,8,9,10"
                                 },
                                 {
                                     "name": "bathrooms",
                                     "type": "select",
                                     "label": "Bathrooms",
                                     "tooltip": "Bathrooms",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "1,2,3,4,5,6,7,8,9,10"
                                 },
                                 {
                                     "name": "pets",
                                     "type": "select",
                                     "label": "Pets",
                                     "tooltip": "Pets",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "yes,No"
                                 },
                                 {
                                     "name": "agencybrokerfee",
                                     "type": "select",
                                     "label": "Agency\\/broker fee",
                                     "tooltip": "Agency\\/broker fee",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Yes,No"
                                 },
                                 {
                                     "name": "squaremeters",
                                     "type": "string",
                                     "label": "Square meters",
                                     "tooltip": "Square meters",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "pricenegotiable",
                                     "type": "checkbox",
                                     "label": "Price negotiable",
                                     "tooltip": "Price negotiable",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 }
                             ],
                             "jobs": [
                                 {
                                     "name": "jobtype",
                                     "type": "select",
                                     "label": "Job type",
                                     "tooltip": "Job type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Full-time,Part-time"
                                 },
                                 {
                                     "name": "experienceinyears",
                                     "type": "select",
                                     "label": "Experience in Years",
                                     "tooltip": "Experience in Years",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Less than 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,More than 20"
                                 },
                                 {
                                     "name": "salary",
                                     "type": "integer",
                                     "label": "Salary",
                                     "tooltip": "Salary",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "salarytype",
                                     "type": "select",
                                     "label": "Salary type",
                                     "tooltip": "Salary type",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": "Hourly,Daily,Weekly,Monthly,Quarterly,Yearly"
                                 },
                                 {
                                     "name": "extrainformation",
                                     "type": "textarea",
                                     "label": "Extra information",
                                     "tooltip": "Extra information",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "company",
                                     "type": "string",
                                     "label": "Company",
                                     "tooltip": "Company name",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "companydescription",
                                     "type": "textarea",
                                     "label": "Company description",
                                     "tooltip": "Company description",
                                     "required": false,
                                     "searchable": false,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 }
                             ],
                             "dating": [
                                 {
                                     "name": "age",
                                     "type": "integer",
                                     "label": "Age",
                                     "tooltip": "Age",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "body",
                                     "type": "select",
                                     "label": "Body",
                                     "tooltip": "Body",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "-,Athletic,Average,big,Curvy,Fit,Heavy,HWP,Skinny,Thin,"
                                 },
                                 {
                                     "name": "height",
                                     "type": "select",
                                     "label": "Height",
                                     "tooltip": "Height",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Taller than 6.8 (203 cm),6.7 (200 cm),6.6 (198 cm),6.5 (195 cm),6.4 (194cm),6.3 (190 cm),6.2 (187 cm),6.1 (185 cm),6.0 (182 cm),5.11 (180 cm),5.10 (177 cm),5.9 (175 cm),5.8 (172 cm),5.7 (170 cm),5.6 (167 cm),5.5 (165 cm),5.4 (162 cm),5.3 (160 cm),5.2 (157 cm),5.1 (154 cm),5.0 (152 cm),4.11 (150 cm),4.10 (147 cm),4.9 (145 cm),4.8 (142 cm) or less"
                                 },
                                 {
                                     "name": "status",
                                     "type": "select",
                                     "label": "Status",
                                     "tooltip": "Status",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": "Single,In a Relationship,Engaged,Married,Separated,Divorced,Widowed"
                                 },
                                 {
                                     "name": "occupation",
                                     "type": "string",
                                     "label": "Occupation",
                                     "tooltip": "Occupation",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "hair",
                                     "type": "string",
                                     "label": "Hair",
                                     "tooltip": "Hair",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "eyecolor",
                                     "type": "string",
                                     "label": "Eye color",
                                     "tooltip": "Eye color",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 }
                             ]
                         }
                         ';
         $cf_templates = json_decode($cf_templates, TRUE);
         $field = new Model_Field();
         foreach ($cf_templates[Core::post('type')] as $custom_field) {
             try {
                 $name = $custom_field['name'];
                 $options = array('label' => $custom_field['label'], 'tooltip' => $custom_field['tooltip'], 'required' => $custom_field['required'], 'searchable' => $custom_field['searchable'], 'admin_privilege' => $custom_field['admin_privilege'], 'show_listing' => $custom_field['show_listing']);
                 if ($field->create($name, $custom_field['type'], $custom_field['values'], Core::post('categories'), $options)) {
                     Core::delete_cache();
                     Alert::set(Alert::SUCCESS, sprintf(__('Field %s created'), $name));
                 } else {
                     Alert::set(Alert::WARNING, sprintf(__('Field %s already exists'), $name));
                 }
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
     } else {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
     }
 }
Пример #30
0
            <option>_self</option>
            <option>_blank</option>
            <option>_parent</option>
            <option>_top</option>
        </select>
    </div>
</div>

<div class="form-group">
    <label class="control-label col-sm-1"><a target="_blank" href="http://getbootstrap.com/2.3.2/base-css.html#icons"><?php 
echo __('Icon');
?>
</a></label>
    <div class="col-sm-4">
        <input class="form-control" type="text" name="icon" value="<?php 
echo Core::post('icon');
?>
" placeholder="<?php 
echo __('glyphicon  glyphicon-envelope glyphicon');
?>
">
    </div>
</div>

<div class="form-actions">

<button type="submit" class="btn btn-primary"><?php 
echo __('Save');
?>
</button>
</div>