function init() { parent::init(); $this->addClass('xepan-commerce-search-tool'); $search_result_subpage = $this->options['xepan_commerce_search_result_page']; if (!$search_result_subpage) { $search_result_subpage = "product"; } $label = ""; if ($this->options['search-field-label'] != "") { $label = $this->options['search-field-label']; } $form = $this->add('Form', null, null, ['form/empty']); $search_field = $form->addField('line', 'search', $label)->validate('required'); //->setAttr('PlaceHolder',$this->options['search-input-placeholder']); if ($this->options['search-form-btn']) { if ($this->options['search-button-position'] === "before") { $submit_button = $search_field->beforeField()->add('Button'); } else { $submit_button = $search_field->afterField()->add('Button'); } $submit_button->setIcon('fa ' . $this->options['search-form-btn-icon']); $submit_button->set($this->options['search-form-btn-label']); $submit_button->js('click', $form->js()->submit()); // $form->addSubmit($this->options['search-form-btn-label'] !=""?$this->options['search-form-btn-label']:"Search"); } if ($form->isSubmitted()) { $form->api->redirect($this->api->url(null, array('page' => $search_result_subpage, 'search' => $form['search']))); } }
function init() { parent::init(); $cat_id = $this->app->stickyGET('category_id'); if ($this->options['freelance_result_page'] == '') { $this->add('View_Error')->set('Please Specify Designer Design page Url First'); return; } $customer = $this->add('xepan\\commerce\\Model_Customer'); $cus_j = $customer->join('freelancer_cat_customer_asso.customer_id'); $cus_j->addField('freelancer_category_id'); $customer->addCondition('status', 'Active'); $customer->addCondition('freelancer_category_id', $cat_id); $customer->addExpression('total_sale_design')->set(function ($m, $q) { return $m->add('xepan\\commerce\\Model_QSP_Detail')->addCondition('item_designer_id', $q->getField('id'))->sum('quantity'); }); // $contact->dsql()->group('designer_id'); $c = $this->add('CompleteLister', null, null, ['view\\tool\\freelancerlisting']); $c->setModel($customer); $c->add('xepan\\cms\\Controller_Tool_Optionhelper', ['options' => $this->options, 'model' => $customer]); $c->addHook('formatRow', function ($l) { if ($l->model['image']) { $l->current_row_html['profile_image'] = $l->model['image']; } else { $l->current_row_html['profile_image'] = "vendor/xepan/commerce/templates/images/avatar.jpg"; } }); }
function init() { parent::init(); if (!in_array($this->options['layout'], ['login_view', 'forget_password', 'new_registration', 'micro_login'])) { $this->add('View_Error')->set('View (' . $this->options['layout'] . ') Not Found'); return; } $layout = $this->app->stickyGET('layout'); if ($layout) { $this->options['layout'] = $layout; } $view_url = $this->api->url(null, ['cut_object' => $this->name]); $this->on('click', 'a.xepan-login-panl-loadview', function ($js, $data) use($view_url) { return $this->js()->reload(['layout' => $data['showview']], null, $view_url); }); if ($this->options['show_micro_login']) { $ml_view = $this->add('xepan\\base\\View_User_MicroLogin', array('options' => $this->options)); $this->app->stickyForget('options'); return; } if (!$this->app->auth->isLoggedIn()) { switch ($this->options['layout']) { case 'login_view': $user_login = $this->add('xepan\\base\\View_User_LoginPanel', array('options' => $this->options)); $this->app->stickyForget('layout'); break; case 'forget_password': $f_view = $this->add('xepan\\base\\View_User_ForgotPassword', array('options' => $this->options)); $this->app->stickyForget('options'); break; case 'new_registration': $r_view = $this->add('xepan\\base\\View_User_Registration', array('options' => $this->options)); $this->app->stickyForget('options'); break; case 'verify_account': $v_view = $this->add('xepan\\base\\View_User_VerifyAccount', array('options' => $this->options)); $this->app->stickyForget('options'); break; case 'verify_again': $va_view = $this->add('xepan\\base\\View_User_VerifyAgain', array('options' => $this->options)); $this->app->stickyForget('options'); break; case 'reset_form': $va_view = $this->add('xepan\\base\\View_User_ResetPassword', array('options' => $this->options)); $this->app->stickyForget('options'); break; case 'micro_login': break; default: $this->add('View_Error')->set('View Not Found .....specify data-showview attr'); } } else { $this->js()->univ()->loaction($this->api->url($this->options['redirect_url'])); if ($this->options['layout'] == "micro_login") { $this->add('xepan\\base\\View_User_MicroLogin', array('options' => $this->options)); } else { $this->add('xepan\\base\\View_User_AlreadyLoggedin', array('options' => $this->options)); } } }
function init() { parent::init(); $category = $this->add('xepan\\commerce\\Model_Category')->addCondition('id', $_GET['xsnb_category_id']); $category->tryLoadAny(); if (!$category->loaded()) { $this->add('View_Error')->set('Category not found'); $this->template->del('counts'); return; } $message = $this->validateRequiredOption(); if ($message) { $this->template->del('root_wrapper'); $this->add('View_Warning')->set($message); return; } $this->add('xepan\\cms\\Controller_Tool_Optionhelper', ['model' => $category]); $this->setModel($category); $url = $category['custom_link'] ? $category['custom_link'] : $this->options['redirect_page']; $url = $this->app->url($url, ['xsnb_category_id' => $this->model->id]); $description = $this->model['description']; $description = str_replace("{{url}}", $url, $description); $description = str_replace("{{category_id}}", $category->id, $description); $this->template->trySetHtml('category_description', $description); $this->template->trySetHtml('url', $url); }
function init() { parent::init(); $item_id = $this->app->stickyGET('commerce_item_id'); $this->app->stickyGET('custom_field'); $this->addClass('xepan-commerce-item-image'); $this->js('reload')->reload(); $item = $this->add('xepan\\commerce\\Model_Item')->tryLoad($item_id ?: -1); if (!$item->loaded()) { $this->add('View')->set('No Record Found'); return; } $image = $this->add('xepan\\commerce\\Model_Item_image')->addCondition('item_id', $item->id)->setOrder('sequence_no', 'desc'); if (!$image->count()->getOne()) { $this->add('View')->set('No Record Found')->addClass('no-record-found'); return; } if ($_GET['custom_field']) { $department_wise_custom_field_array = json_decode($_GET['custom_field'], true); foreach ($department_wise_custom_field_array as $department) { foreach ($department as $cf_id => $values) { if (!is_numeric($cf_id)) { continue; } $customfield_value_id_array[] = $values['custom_field_value_id']; } } if (isset($customfield_value_id_array)) { $temp_image = $this->add('xepan\\commerce\\Model_Item_image')->addCondition('item_id', $item->id); $temp_image->addCondition('customfield_value_id', $customfield_value_id_array); if ($temp_image->count()->getOne()) { $image->addCondition('customfield_value_id', $customfield_value_id_array); $image->tryLoadAny(); } else { $customfield_value_id_array = []; } } } $template = 'view/tool/itemimage'; if ($this->options['custom_template']) { $path = getcwd() . "/websites/" . $this->app->current_website_name . "/www/view/tool/" . $this->options['custom_template'] . ".html"; if (file_exists($path)) { $template = 'view/tool/' . $this->options['custom_template']; } else { $this->add('View_Error')->set('Custom template not found.'); return; } } $this->lister = $lister = $this->add('CompleteLister', null, null, [$template]); $this->lister->setModel($image); $first_image = $this->add('xepan\\commerce\\Model_Item_Image')->addCondition('item_id', $item_id)->setOrder('sequence_no', 'desc'); if (isset($customfield_value_id_array) and count($customfield_value_id_array)) { $first_image->addCondition('customfield_value_id', $customfield_value_id_array); } $firstimage_url = $first_image->setLimit(1)->fieldQuery('file'); $this->lister->template->set('firstimage', $firstimage_url); }
function init() { parent::init(); $admin_url = "http://www." . $_GET['epan_name'] . ".epan.in/admin/?page=xepan_hr_user"; $website_url = "http://www." . $_GET['epan_name'] . ".epan.in"; $message = $this->app->stickyGET('message'); $this->template->trySet('admin', $admin_url); $this->template->trySet('website', $website_url); $this->template->trySet('message', $message); }
function init() { parent::init(); $category = $this->add('xepan\\commerce\\Model_FreelancerCategory'); $category->addCondition('status', 'Active'); // $contact->dsql()->group('designer_id'); $c = $this->add('CompleteLister', null, null, ['view\\tool\\freelancercategory']); $c->setModel($category); $c->add('xepan\\cms\\Controller_Tool_Optionhelper', ['options' => $this->options, 'model' => $category]); }
function init() { parent::init(); $post_id = $this->api->stickyGET('post_id'); $this->post = $this->add('xepan\\blog\\Model_BlogPost')->tryLoad($post_id ?: -1); if (!$this->post->loaded()) { $this->template->tryDel('tag_wrapper'); return; } $this->app->template->trySet('title', $this->post['meta_title'] ?: $this->post['title']); $this->app->template->trySet('meta_keywords', $this->post['tag'] . ' ' . $this->post['meta_title']); $this->app->template->trySet('meta_description', $this->post['meta_description']); $this->setModel($this->post); $this->add('xepan\\cms\\Controller_Tool_Optionhelper', ['options' => $this->options, 'model' => $this->post]); if ($this->options['show_comment_list']) { $comment_m = $this->add('xepan\\blog\\Model_Comment')->addCondition('blog_post_id', $this->post->id)->addCondition('status', 'Approved'); $comment_view = $this->add('xepan\\blog\\View_Comment', ['options' => $this->options], 'comments'); $comment_view->setModel($comment_m); } if ($this->app->isEditing) { $this->template->tryDel('tag_wrapper'); $this->post->getElement('title')->display(['form' => 'hidden']); $this->post->getElement('description')->display(['form' => 'hidden']); $this->post->getElement('show_comments')->display(['form' => 'xepan\\base\\DropDownNormal']); $this->post->getElement('anonymous_comment_config')->display(['form' => 'xepan\\base\\DropDownNormal']); $this->post->getElement('registered_comment_config')->display(['form' => 'xepan\\base\\DropDownNormal']); $form = $this->add('Form', null, 'editing_mode'); $form->setModel($this->post, ['title', 'description', 'tag', 'meta_title', 'meta_description', 'show_comments', 'anonymous_comment_config', 'registered_comment_config']); $title_field = $form->getElement('title'); $description_field = $form->getElement('description'); $form->addSubmit('SAVE POST')->addClass('btn btn-danger btn-block'); $form->js('beforesubmit', [$title_field->js()->val($form->js()->_selector('#xepan-blog-title')->html()), $description_field->js()->val($form->js()->_selector('#xepan-blog-description')->html())]); if ($form->isSubmitted()) { $form->save(); $form->js()->univ()->successMessage('Blog Post Saved')->execute(); } } else { $this->template->tryDel('editing_mode'); } if (!$this->model['image_id']) { $this->template->tryDel('image_wrapper'); } // add social share todo shift into tool condition function if ($this->options['add_socialshare']) { $this->js(true)->_load('socialshare/jssocials'); $this->js(true)->_css('socialshare/jssocials'); $this->js(true)->_css('socialshare/jssocials-theme-' . $this->options['socialshare_theme']); $sharing_url = $this->app->pm->base_url . $this->app->url(null, ['xepan_landing_content_id' => $this->model->id]); $social_shares = explode(",", $this->options['include_socialshare'] ?: 'email,twitter,facebook,googleplus,linkedin,pinterest,stumbleupon,whatsapp'); $social_shares = array_values($social_shares); $this->js(true)->_selector('#postshare' . $this->model->id)->jsSocials(['shares' => $social_shares, "url" => $sharing_url]); } else { $this->template->trySet('sharewrapper', ""); } }
function init() { parent::init(); $category = $this->add('xepan\\blog\\Model_BlogPostCategory'); $category->setLimit($this->options['category_count']); $category->addCondition('status', 'Active'); if ($this->options['order']) { $category->setOrder('order', 'asc'); } if ($this->options['group']) { $category->addCondition('group', $this->options['group']); } $cl = $this->add('CompleteLister', null, null, ['view/tool/post/category']); if ($this->options['show_post']) { $assos_j = $category->leftJoin('blog_post_category_association.blog_post_category_id'); $blog_j = $assos_j->leftJoin('blog_post', 'blog_post_id'); $blog_j->addField('title'); $blog_j->addField('post_id', 'id'); $blog_j->addField('blog_status', 'status'); if (!$this->app->auth->isLoggedIn() || !in_array($this->app->auth->model['scope'], ['AdminUser', 'SuperUser'])) { $category->addCondition('blog_status', 'Published'); } $category->setOrder(['order asc', 'post_id asc']); } if (!$category->count()->getOne()) { $cl->template->set('not_found_message', 'No Record Found'); } else { $cl->template->del('not_found'); } $categories = []; $posts = []; foreach ($cat_rows = $category->getRows() as $cat) { if (!isset($categories[$cat['id']])) { $categories[$cat['id']] = $cat['name']; } $posts[$cat['id']][] = ['title' => $cat['title'], 'post_id' => $cat['post_id'], 'status' => $cat['blog_status']]; } if ($this->options['show_post']) { $cl->addHook('formatRow', function ($cl) use($categories, $posts, $category) { $pl = $cl->add('CompleteLister', null, 'cat_post', ['view/tool/post/category', 'cat_post']); $pl->addHook('formatRow', function ($pl_r) use($cl, $posts) { $pl_r->current_row['post_detail_page_url'] = $this->app->url($this->options['post_detail_page'], ['post_id' => $pl_r->model['post_id']]); if ($pl_r->model['status'] == 'UnPublished') { $pl_r->current_row['color'] = 'text-muted'; } }); $pl->setSource($posts[$cl->model->id]); $cl->current_row_html['cat_post'] = $pl->getHTMl(); }); } $cl->setSource($categories); $cl->add('xepan\\cms\\Controller_Tool_Optionhelper', ['options' => $this->options, 'model' => $category]); }
function init() { parent::init(); $search_result_page = $this->options['search_reasult_url']; if (!$search_result_page) { $this->add('View_Warning')->set('Please add a search result page in options'); return; } $form = $this->add('Form', null, null, ['form/empty']); $form_field = $form->addField('line', 'search'); if ($form->isSubmitted()) { $form->api->redirect($this->api->url(null, array('page' => $search_result_page, 'search' => $form['search']))); } }
function init() { parent::init(); // added for price changing $this->addClass('xshop-item'); $item_id = $this->api->stickyGET('commerce_item_id'); $this->item = $this->add('xepan\\commerce\\Model_Item')->tryLoad($item_id ?: -1); if (!$this->item->loaded()) { $this->add('View')->set('No Record Found'); $this->template->tryDel("xepan_commerce_itemdetail_wrapper"); return; } $this->setModel($this->item); }
function init() { parent::init(); // return; if ($this->options['custom_template']) { $path = getcwd() . "/websites/" . $this->app->current_website_name . "/www/view/tool/" . $this->options['custom_template'] . ".html"; if (!file_exists($path)) { $this->add('View_Warning')->set('template not found'); return; } } else { $this->options['custom_template'] = "categorylister"; } $lister = $this->add('xepan\\commerce\\View_CategoryLister', ['options' => $this->options]); }
function init() { parent::init(); if ($this->options['freelance_result_page'] == '') { $this->add('View_Error')->set('Please Specify Designer Design page Url First'); return; } $contact = $this->add('xepan\\base\\Model_Contact'); $item_j = $contact->join('item.designer_id'); $item_j->addField('designer_id'); $contact->addCondition('status', 'Active'); // $contact->dsql()->group('designer_id'); $c = $this->add('CompleteLister', null, null, ['view\\tool\\freelancerlisting']); $c->setModel($contact); $c->add('xepan\\cms\\Controller_Tool_Optionhelper', ['options' => $this->options, 'model' => $contact]); }
function init() { parent::init(); $message = $this->validateRequiredOption(); if ($message) { $this->add('View_Warning', null, 'no_auth_message')->set($message); $this->template->tryDel('myaccount_container_wrapper'); return; } //check authentication if (!$this->app->auth->model->loaded()) { if ($this->options['xepan_commerce_login_page']) { $this->app->memorize('next_url', $_GET['page']); $this->app->redirect($this->app->url($this->options['xepan_commerce_login_page'])); } else { $this->add('View_Warning', null, 'no_auth_message')->set('Login First'); } $this->template->tryDel('myaccount_container_wrapper'); return; } $this->app->stickyGET('selectedmenu'); $customer = $this->add('xepan\\commerce\\Model_Customer'); $customer->loadLoggedIn(); //check customer is loaded if (!$customer->loaded()) { $this->add('View_Info', null, 'no_auth_message')->set('customer account not found')->addClass('jumbotron well text-center row alert alert-info h3'); $this->template->tryDel('myaccount_container_wrapper'); return; } $this->setModel($customer); $self_url = $this->app->url(); $vp = $this->add('VirtualPage'); $vp->set(function ($p) use($customer, $self_url) { $f = $p->add('Form', null, null, ['form\\empty']); $f->setModel($customer, ['image_id', 'image']); if ($f->isSubmitted()) { $f->save(); return $f->app->redirect($self_url); } }); $this->js('click', $this->js()->univ()->dialogURL("CHANGE IMAGE", $this->api->url($vp->getURL())))->_selector('.myaccount-user-image'); $print_url = $this->api->url(['xepan_commerce_orderdetailprint&document_id=']); $this->on('click', '.xepan-customer-order-detail', function ($js, $data) use($print_url) { return $js->univ()->newWindow($print_url . $data['id']); }); }
function init() { parent::init(); if (!$this->app->auth->isLoggedIn()) { $this->app->redirect($this->options['login_page']); return; } $this->customer = $customer = $this->add('xepan\\commerce\\Model_Customer'); $customer->loadLoggedIn(); // check customer is loaded if (!$customer->loaded()) { $this->add('View_Info')->set('Customer account not found'); return; } $my_account = $this->add('xepan\\commerce\\Tool_MyAccount', null, 'account', null); $this->showMyEpans(); $this->showMyTemplates(); }
function init() { parent::init(); if ($this->options['show_microdata']) { $this->company_m = $this->add('xepan\\base\\Model_ConfigJsonModel', ['fields' => ['company_name' => "Line", 'company_owner' => "Line", 'mobile_no' => "Line", 'company_email' => "Line", 'company_address' => "Line", 'company_pin_code' => "Line", 'company_description' => "text", 'company_description' => "text", 'company_logo_absolute_url' => "Line", 'company_twitter_url' => "Line", 'company_facebook_url' => "Line", 'company_google_url' => "Line", 'company_linkedin_url' => "Line"], 'config_key' => 'COMPANY_AND_OWNER_INFORMATION', 'application' => 'communication']); $this->company_m->tryLoadAny(); } $post = $this->add('xepan\\blog\\Model_BlogPost'); $post->addCondition('status', 'Published'); $post->setOrder('created_at', 'desc'); if ($category_id = $this->app->stickyGET('category_id')) { $assoc_j = $post->join('blog_post_category_association.blog_post_id'); $assoc_j->addField('blog_post_category_id'); $post->addCondition('blog_post_category_id', $category_id); $post->_dsql()->group('blog_post_id'); } if ($search_string = $this->app->stickyGET('search')) { $post->addExpression('Relevance')->set('MATCH(title, description, tag, meta_title, meta_description) AGAINST ("' . $search_string . '" IN NATURAL LANGUAGE MODE)'); $post->addCondition('Relevance', '>', 0); $post->setOrder('Relevance', 'Desc'); } if ($month = $this->app->stickyGET('month')) { $post->addCondition('month', $month); } $cl = $this->add('CompleteLister', null, null, ['view/tool/post/list']); if (!$post->count()->getOne()) { $cl->template->set('not_found_message', 'No Record Found'); } else { $cl->template->del('not_found'); } $cl->setModel($post); if ($this->options['show_paginator'] == "true") { $paginator = $cl->add('Paginator', ['ipp' => $this->options['paginator_set_rows_per_page']]); $paginator->setRowsPerPage($this->options['paginator_set_rows_per_page']); } $cl->add('xepan\\cms\\Controller_Tool_Optionhelper', ['options' => $this->options, 'model' => $post]); if ($this->options['set_by_order'] == 'order_by_id') { $post->setOrder('order', 'asc'); } elseif ($this->options['set_by_order'] == 'order_by_recent_post') { $post->setOrder('created_at', 'Desc'); } elseif ($this->options['set_by_order'] == 'order_by_created_at') { $post->setOrder('created_at', 'asc'); } }
function init() { parent::init(); $post = $this->add('xepan\\blog\\Model_BlogPost'); $post->_dsql()->group($post->_dsql()->expr("[0]", [$post->getElement('year')])); $post->addExpression('year_post_count')->set(function ($m, $q) { return $q->expr("count([0])", [$m->getElement('id')]); }); $post->addExpression('month_post_count')->set(function ($m, $q) { return $q->expr("( COUNT([0]) )", [$m->getElement('id')]); }); $cl = $this->add('CompleteLister', null, null, ['view/tool/post/archieve']); if (!$post->count()->getOne()) { $cl->template->set('not_found_message', 'No Record Found'); } else { $cl->template->del('not_found'); } $cl->setModel($post); $cl->add('xepan\\cms\\Controller_Tool_Optionhelper', ['options' => $this->options, 'model' => $post]); }
function init() { parent::init(); $categories = $this->add('xepan\\commerce\\Model_Category'); $categories->setOrder('display_sequence', 'asc'); $this->add('xepan\\cms\\Controller_Tool_Optionhelper', ['model' => $categories]); if ($this->options['show_name'] or $this->options['show-category-description-only']) { if ($_GET['xsnb_category_id'] and is_numeric($_GET['xsnb_category_id'])) { $categories->tryLoad($_GET['xsnb_category_id']); if (!$categories->loaded()) { $this->add('View_Error')->set("category not found"); return; } } } //Only Category Description if ($this->options['show-category-description-only'] == "true") { $cat_m = $categories->load($_GET['xsnb_category_id']); //Category id replace because acustomer need category detail then go to the next page with passing category id $content = str_replace("{{category_id}}", $_GET['xsnb_category_id'], $cat_m['description']); $content = str_replace("{{product_page_name}}", $this->options['url_page'], $content); $this->add('View')->setHTML($content); return; } if ($this->options['show_name']) { //Count Only Website Display Item $cat_item_model = $this->add('xepan\\commerce\\Model_CategoryItemAssociation'); $cat_item_j = $cat_item_model->leftJoin('item.document_id', 'item_id'); $cat_item_j->addField('is_saleable'); $cat_item_j->addField('website_display'); $item_doc_j = $cat_item_j->join('document', 'document_id'); $item_doc_j->addField('status'); $cat_item_model->addCondition('status', 'Published'); $cat_item_model->addCondition('is_saleable', 1); $cat_item_model->addCondition('website_display', 1); $cat_item_model->addCondition('category_id', $categories->id); $single_view = $this->add('View', null, null, ["view/tool/category"]); $single_view->setModel($categories); $single_view->template->trySet('item_count', $cat_item_model->count()->getOne()); return; } $this->options['grid-column']; $width = 12; if ($this->options['show-category-column']) { $width = 12 / $this->options['show-category-column']; } $this->col = 'col-md-' . $width . ' col-sm-' . $width . ' col-xl-' . $width; // Define no of sub-category show in parent category if ($this->options['category_show_list']) { $this->options['category_show_list']; } if (!$this->options['url_page']) { $this->add('View_Error')->set('Please Specify Category URL Page Name (page name like.. about,contactus etc..)'); return; } else { $categories->addCondition('status', 'Active'); //todo OR Condition Using _DSQL $categories->addCondition($categories->_dsql()->orExpr()->where('parent_category_id', null)->where('parent_category_id', 0)); // $categories->addCondition('parent_id',Null); $categories->tryLoadAny(); if (!$categories->loaded()) { $this->add('View_Error')->setHTML('No Root Category Found'); return; } $output = "<div class='body epan-sortable-component epan-component ui-sortable ui-selected'>"; $output = "<ul class='sky-mega-menu sky-mega-menu-anim-slide sky-mega-menu-response-to-stack'>"; foreach ($categories as $junk_category) { $output .= $this->getCategory($categories); } $output .= "</ul></div>"; $this->setHTML($output); } //loading custom CSS file // $category_css = 'epans/'.$this->api->current_website['name'].'/xshopcategory.css'; // $this->api->template->appendHTML('js_include','<link id="xshop-category-customcss-link" type="text/css" href="'.$category_css.'" rel="stylesheet" />'."\n"); }
function init() { parent::init(); // echo'<pre>'; // print_r($this->options); // exit; $message = $this->validateRequiredOption(); if ($message) { $this->template->tryDel('lister'); $this->template->tryDel('footer'); $this->template->trySet('total_count', 0); $this->add('View_Warning')->set($message); return; } $entered_discount_voucher = $this->app->recall('discount_voucher'); $implement_express_shipping = $this->app->recall('express_shipping'); $this->addClass('xshop-cart'); $this->js('reload')->reload(); $cart = $this->add('xepan\\commerce\\Model_Cart'); $totals = $cart->getTotals(); $this->total_count = $totals['total_item_count']; //if no record found then delete other spot if (!$this->total_count) { $this->template->trySet('not_found_message', 'shopping cart is empty'); $this->template->tryDel('footer'); $this->template->tryDel('lister'); $this->template->trySet('total_count', 0); return; } else { $this->template->tryDel('not_found'); } $lister = $this->add('CompleteLister', null, 'lister', ["view/tool/cart/" . $this->options['layout'], 'lister']); $lister->setModel($cart); //discount voucher implementation // if($entered_discount_voucher){ // $discount_voucher_model = $this->add('xepan\commerce\Model_DiscountVoucher')->tryLoadBy('name',$entered_discount_voucher); $discount_amount = $totals['row_discount'] + $totals['row_discount_shipping'] + $totals['row_discount_shipping_express']; // $total = 0; // if($discount_voucher_model->loaded()){ // //get discount amount based on discount voucher condition // $discount_amount = $discount_voucher_model->getDiscountAmount($total_amount_raw, $sum_shipping_charge_raw); // //todo in future individual item wise with discount_voucher based_on condition // } // } // $net_amount = $total_amount + $sum_shipping_charge - $discount_amount; $this->template->trySet('total_count', $this->total_count ?: 0); $this->template->trySet('total_amount', $this->app->round($totals['amount'])); $this->template->trySet('total_shipping_amount', $this->app->round($totals['shipping_charge'])); $this->template->trySet('gross_amount', $this->app->round($totals['amount'] + $totals['shipping_charge'])); $this->template->trySet('discount_amount', $this->app->round($totals['row_discount'])); $this->template->trySet('net_amount', $this->app->round($totals['amount'] + $totals['shipping_charge'])); $count = $this->total_count; //cart item remove action if ($this->options['show_cart_item_remove_button']) { $this->on('click', '.xepan-commerce-cart-item-delete', function ($js, $data) use($count) { $count = $count - 1; $this->add('xepan\\commerce\\Model_Cart')->deleteItem($data['cartid']); $js_event = [$this->js()->_selector('.xepan-commerce-cart-item-count')->html($count), $js->closest('.xepan-commerce-tool-cart-item-row')->hide(), $this->js()->univ()->successMessage('removed successfully'), $this->js()->_selector('.xepan-commerce-tool-cart')->trigger('reload')]; return $js_event; }); } $cart_detail_url = $this->api->url($this->options['cart_detail_url']); $this->template->trySet('cart_detail_url', $cart_detail_url); // show or hide proceed to next button $checkout_page_url = $this->app->url($this->options['checkout_page']); if ($this->options['show_proceed_to_next_button']) { $this->on('click', ".xepan-cart-proceed-to-next-btn", function ($js, $data) use($checkout_page_url) { return $js->redirect($checkout_page_url); }); } else { $this->template->tryDel('proceed_to_next_button_wrapper'); } // discount voucher if (in_array($this->options['show_discount_voucher'], ["true", true, "1", 1])) { $form = $this->add('Form', null, 'discount_voucher', ['form\\empty']); $voucher_field = $form->addField('line', 'discount_voucher'); // $voucher_field->validate('required'); if ($entered_discount_voucher) { $voucher_field->set($entered_discount_voucher); } if (!$discount_amount and $entered_discount_voucher) { $voucher_field->belowField()->add('View')->addClass('text-danger')->set('Not Effective'); } $voucher_field->js('change', $form->js()->submit()); if ($form->isSubmitted()) { if ($form['discount_voucher'] == "" or is_null($form['discount_voucher'])) { $this->app->forget('discount_voucher'); $this->app->forget('discount_voucher_obj'); $this->add('xepan\\commerce\\Model_Cart')->reloadCart(); $this->js()->reload()->execute(); } $discount_voucher = $this->add('xepan\\commerce\\Model_DiscountVoucher'); $message = $discount_voucher->isVoucherUsable($form['discount_voucher']); if ($message == "success") { $this->app->memorize('discount_voucher', $form['discount_voucher']); $this->app->memorize('discount_voucher_obj', $this->add('xepan\\commerce\\Model_DiscountVoucher')->tryLoadBy('name', $form['discount_voucher'])); $this->add('xepan\\commerce\\Model_Cart')->reloadCart(); $this->js()->reload()->execute(); } else { $this->app->forget('discount_voucher'); $this->app->forget('discount_voucher_obj'); $form->displayError('discount_voucher', $message); } } } else { $this->template->tryDel('discount_voucher_wrapper'); } // express shipping if (in_array($this->options['show_express_shipping'], ["true", 1, "1", true])) { $express_form = $this->add('Form', null, 'express_shipping_checkbox', ['form\\empty']); $field_express_shipping = $express_form->addField('checkbox', 'express_shipping', ""); if ($implement_express_shipping) { $field_express_shipping->set(true); } $field_express_shipping->js('change', $express_form->js()->submit()); if ($express_form->isSubmitted()) { if ($express_form['express_shipping']) { $this->app->memorize('express_shipping', 1); } else { $this->app->forget('express_shipping'); } $this->app->redirect(); } } else { $this->template->tryDel('express_shipping_wrapper'); } if ($this->options['show_total_tax_amount']) { $this->template->trySet('tax_amount', $totals['tax_amount']); } else { $this->template->tryDel('tax_amount_wrapper'); } $this->view_font = $this->add('xepan\\commerce\\View_Designer_FontCSS'); $lister->add('xepan\\cms\\Controller_Tool_Optionhelper', ['options' => $this->options, 'model' => $cart]); }
function init() { parent::init(); $this->app->addStyleSheet('jquery-ui'); $company_m = $this->add('xepan\\base\\Model_ConfigJsonModel', ['fields' => ['company_name' => "Line", 'company_owner' => "Line", 'mobile_no' => "Line", 'company_email' => "Line", 'company_address' => "Line", 'company_pin_code' => "Line", 'company_description' => "text", 'company_description' => "text", 'company_logo_absolute_url' => "Line", 'company_twitter_url' => "Line", 'company_facebook_url' => "Line", 'company_google_url' => "Line", 'company_linkedin_url' => "Line"], 'config_key' => 'COMPANY_AND_OWNER_INFORMATION', 'application' => 'communication']); $company_m->tryLoadAny(); $social = $this->add('View', null, null, ['view/schema-micro-data', 'social_block']); $social->template->trySet('company_name', $company_m['company_name']); $social->template->trySet('website_url', $this->app->pm->base_url); $social->template->trySet('website_name', $this->app->current_website_name); $social->template->trySet('logo_url', $company_m['company_logo_absolute_url']); $social->template->trySet('twitter_url', $company_m['company_twitter_url']); $social->template->trySet('facebook_url', $company_m['company_facebook_url']); $social->template->trySet('google_url', $company_m['company_google_url']); $social->template->trySet('linkedin_url', $company_m['company_linkedin_url']); $view = $this->add('View', null, null, ['view/schema-micro-data', 'person_info']); $view->setModel($company_m); $this->app->memorize('next_url', $this->app->page); if (!$this->app->auth->isLoggedIn()) { $f = $this->add('Form'); $f->addSubmit('Free 14 days trial')->addClass('btn btn-primary btn-block xepan-form-free-trial-btn')->addStyle(['font-size' => '42px', 'font-family' => 'Lucida Console']); if ($f->isSubmitted()) { $this->app->redirect($this->options['login_page']); return; } return; } $this->customer = $customer = $this->add('xepan\\commerce\\Model_Customer'); $customer->loadLoggedIn(); if (!$customer->loaded()) { $this->add('View')->addClass('panel panel-danger')->set('You are not a registered customer'); return; } $v = $this->add('View')->setHtml('<span>Creating your website and admin panel. Be with us, it will take less than 1 minute.</span> <img src="vendor\\xepan\\epanservices\\templates\\images\\loader.gif">'); $v->js(true)->hide(); /*FORM TO ASK USER FOR EPAN NAME AND TO CHECK LOGGEDIN*/ if ($this->app->auth->isLoggedIn()) { $form = $this->add('Form', null, 'form'); $form->setLayout('view\\tool\\form\\epantrial'); $form->addField('epan_name')->setAttr(['placeholder' => 'your website name'])->validate('required?Please enter a website name'); $submit_button = $form->addSubmit('Free 14 day Trial')->addClass('btn btn-primary'); $submit_button->js('click', $v->js()->show()); } if ($form->isSubmitted()) { /* Already Tried */ $trial_epan = $this->add('xepan\\epanservices\\Model_Epan'); $trial_epan->addCondition('created_by_id', $customer->id); $trial_epan->addCondition('status', 'Trial'); $trial_epan->tryLoadAny(); if ($trial_epan->loaded()) { $form->js(true, $v->js(true)->hide())->atk4_form('fieldError', 'epan_name', 'You Have already tried!')->execute(); return; } /* DO EPAN WITH THE SAME NAME EXIST */ $epan_name = $form['epan_name']; $myEpans = $this->add('xepan\\epanservices\\Model_Epan'); $myEpans->addCondition('name', strtolower($epan_name)); $myEpans->tryLoadAny(); if ($myEpans->loaded()) { $form->js(true, $v->js(true)->hide())->atk4_form('fieldError', 'epan_name', 'name already taken')->execute(); return; } /* IF CUSTOMER IS LOGGED IN AND EPAN NAME IS UNIQUE THEN CREATE EPAN */ $epan_name = $form['epan_name']; $email_settings = $this->add('xepan\\communication\\Model_Communication_EmailSetting')->tryLoadAny(); try { set_time_limit(60); $this->api->db->beginTransaction(); $this->createEpan($epan_name); // in epan services database, just a new row with specifications of apps $newEpan_inServices = $this->add('xepan\\epanservices\\Model_Epan')->addCondition('name', $epan_name)->tryLoadAny(); $newEpan_inServices['is_published'] = true; $newEpan_inServices->createFolder($newEpan_inServices); $newEpan_inServices->userAndDatabaseCreate(); // individual new epan database $newEpan_inServices->save(); $this->api->db->commit(); } catch (\Exception_StopInit $e) { $this->api->db->commit(); } catch (\Exception $e) { if ($this->api->db->inTransaction()) { $this->api->db->rollback(); } throw $e; if (isset($newEpan_inServices)) { $newEpan_inServices->swipeEverything($epan_name); } $form->js(true, $v->js(true)->hide())->atk4_form('fieldError', 'epan_name', 'Could not create epan, please try again.')->execute(); return; } $user = $customer->user(); $email_id = $user['username']; $this->sendGreetingsMail($email_id, $email_settings); return $this->app->redirect($this->app->url('greetings', ['epan_name' => $epan_name, 'message' => 'We have sent you a welcome mail. Check your email address linked to the account.'])); } }
function init() { parent::init(); if (!$this->options['customformid']) { $this->add("View_Error")->set('please select any custom form'); return; } $customform_model = $this->add('xepan\\cms\\Model_Custom_Form')->tryLoad($this->options['customformid']); if (!$customform_model->loaded()) { $this->add('View_Error')->set('no such form found...'); return; } $customform_field_model = $this->add('xepan\\cms\\Model_Custom_FormField')->addCondition('custom_form_id', $customform_model->id); if (!$customform_field_model->count()->getOne()) { $this->add("View_Warning")->set('add form fields...'); return; } $this->form = $this->add('Form'); $form = $this->form; if ($this->options['template']) { $form->setLayout('view/tool/form/' . $this->options['template']); } foreach ($customform_field_model as $field) { if ($field['type'] === "email") { $new_field = $form->addField("line", $field['name']); $new_field->validate('email'); } else { if ($field['type'] === "Captcha") { $new_field = $form->addField('line', 'captcha', $field['name']); $new_field->add('xepan\\captcha\\Controller_Captcha'); } else { $new_field = $form->addField($field['type'], $field['name']); } } if ($field['type'] === "DropDown" or $field['type'] === "radio") { $field_array = explode(",", $field['value']); $new_field->setValueList($field_array); } if ($field['is_mandatory']) { $new_field->validate('required'); } } $this->form->addSubmit($customform_model['submit_button_name']); if ($this->form->isSubmitted()) { if ($form->hasElement('captcha') && !$form->getElement('captcha')->captcha->isSame($form['captcha'])) { $form->displayError('captcha', 'wrong Captcha'); } $model_submission = $this->add('xepan\\cms\\Model_Custom_FormSubmission'); $form_fields = $form->getAllFields(); $model_submission['value'] = $form_fields; $model_submission['custom_form_id'] = $this->options['customformid']; $model_submission->save(); $communication = $this->add('xepan\\communication\\Model_Communication_Email_Sent'); $email_settings = $this->add('xepan\\communication\\Model_Communication_EmailSetting')->load($customform_model['emailsetting_id']); $communication->setfrom($email_settings['from_email'], $email_settings['from_name']); $communication->addTo($customform_model['recipient_email']); $communication->setSubject('You have a new enquiry'); $communication->setBody($model_submission['value']); $communication->send($email_settings); if ($customform_model['auto_reply']) { $email_settings = $this->add('xepan\\communication\\Model_Communication_EmailSetting')->load($customform_model['emailsetting_id']); $communication1 = $this->add('xepan\\communication\\Model_Communication_Email_Sent'); $to_array = []; foreach ($customform_field_model as $field) { if (!($field['type'] == "email" and $field['auto_reply'])) { continue; } $to_array[] = $this->form[$field['name']]; } foreach ($to_array as $email) { $communication1->setfrom($email_settings['from_email'], $email_settings['from_name']); $communication1->addTo($email); $communication1->setSubject($customform_model['email_subject']); $communication1->setBody($customform_model['message_body']); $communication1->send($email_settings); } } $form->js(null, $form->js()->reload())->univ()->successMessage("Thank you for enquiry")->execute(); } }
function init() { parent::init(); if (isset($_COOKIE['xepan_state_cookies']) and isset($_COOKIE['xepan_country_cookies'])) { $c_model = $this->add('xepan\\base\\Model_Country')->load($_COOKIE['xepan_country_cookies']); $s_model = $this->add('xepan\\base\\Model_State')->load($_COOKIE['xepan_state_cookies']); $this->app->memorize('xepan-customer-current-country', $c_model); $this->app->memorize('xepan-customer-current-state', $s_model); $this->app->country = $c_model; $this->app->state = $s_model; } // $this->app->country = $this->add('xepan\base\Model_Country')->load(100); // $this->app->state = $this->add('xepan\base\Model_State')->load(95); $country_model = $this->add('xepan\\base\\Model_Country')->addCondition('status', 'Active')->setOrder('name', 'asc'); $state_model = $this->add('xepan\\base\\Model_State'); $state_model->addExpression('country_status')->set($state_model->refSQL('country_id')->fieldQuery('status')); $state_model->addCondition('status', 'Active'); $state_model->addCondition('country_status', 'Active'); $state_model->setOrder('name', 'asc'); $form = $this->add('Form', null, 'form_layout'); $form->setLayout(['view\\tool\\location\\location', 'form_layout']); $country_field = $form->addField("xepan\\base\\DropDownNormal", "country"); $country_field->validate('required'); $state_field = $form->addField("xepan\\base\\DropDownNormal", "state"); $state_field->validate('required'); $country_field->setModel($country_model); $country_field->setEmptyText("Please Select Your Country"); $selected_country_id = 0; if (isset($this->app->country) and $this->app->country instanceof \xepan\base\Model_Country) { $country_field->set($this->app->country->id); $selected_country_id = $this->app->country->id; if ($this->options['show_country_name']) { $this->template->trySet('country_name', $this->app->country['name']); } } if ($_GET['location_country_id']) { $selected_country_id = $_GET['location_country_id']; } if ($selected_country_id) { $state_model->addCondition('country_id', $selected_country_id); } $state_field->setEmptyText("Please Select State"); $state_field->setModel($state_model); if (isset($this->app->state) and $this->app->state instanceof \xepan\base\Model_State) { $selected_state_id = $this->app->state->id; if (!$_GET['location_country_id']) { $state_field->set($selected_state_id); } if ($this->options['show_state_name']) { $this->template->trySet('state_name', $this->app->state['name']); } } // Save Button $save_btn = $this->add('Button', null, "save_button"); $save_btn->set("Update")->setAttr(array("type" => "button"))->addClass('btn btn-primary')->setStyle('margin-top', 0); $save_btn->js('click', $this->js()->find('.atk-form')->atk4_form("submitForm")); $country_field->js('change', $state_field->js()->reload(null, null, [$this->app->url(null, ['cut_object' => $state_field->name]), 'location_country_id' => $country_field->js()->val()])); // Form Submission if ($form->isSubmitted()) { $c_model = $this->add('xepan\\base\\Model_Country')->load($form['country']); $s_model = $this->add('xepan\\base\\Model_State')->load($form['state']); $this->app->memorize('xepan-customer-current-country', $c_model); $this->app->memorize('xepan-customer-current-state', $s_model); $this->app->country = $c_model; $this->app->state = $s_model; setcookie('xepan_state_cookies', $form['state'], time() + 31556926, '/'); setcookie('xepan_country_cookies', $form['country'], time() + 31556926, '/'); // throw new \Exception(setcookie($cookie_state, $cookie_country), 1); $this->app->redirect($_SERVER['HTTP_REFERER']); } // if($this->app->country or $this->app->state) // $this->template->tryDel('location_fetcher_wrapper'); // $this->js(true)->_library('navigator')->geolocation->getCurrentPosition($this->js(null,'$.ajax({url:})'))->_enclose()); }
function init() { parent::init(); $selected_category = []; if ($this->options["lead_category"]) { $selected_category = explode(",", $this->options["lead_category"]); } $form = $this->add('Form', null, 'form'); $form->setLayout('view/tool/subscription'); if ($this->options['ask_name']) { $form->addField('first_name')->addClass('form-control'); $form->addField('last_name')->addClass('form-control'); } $form->addField('email')->addClass('form-control'); $form->addSubmit($this->options['submit_button_name'])->addClass('btn btn-primary btn-block'); if ($form->isSubmitted()) { $ei = $this->add('xepan\\base\\Model_Contact_Email'); $ei->tryLoadBy('value', $form['email']); if ($ei->loaded()) { $l_id = $ei['contact_id']; $l_model = $this->add('xepan\\marketing\\Model_Lead')->load($l_id); $cat_arr = $l_model->getAssociatedCategories(); setcookie('xepan_lead_subscription', $form['email']); $cat_diff = array_merge(array_diff($cat_arr, $selected_category), array_diff($selected_category, $cat_arr)); if (!count($cat_diff)) { if (!isset($_COOKIE['xepan_lead_subscription']) and $this->options['show_as_popup'] === true) { return $form->js(null, $form->js()->_selector('#' . $this->name . "_subscription_model")->modal('hide'))->univ()->errorMessage('Already Subscribed')->execute(); } return $form->js()->univ()->errorMessage('Already Subscribed')->execute(); } foreach ($cat_diff as $category) { $association = $this->add('xepan\\marketing\\Model_Lead_Category_Association'); $association['lead_id'] = $l_model->id; $association['marketing_category_id'] = $category; $association['created_at'] = $this->app->now; $association->save(); } if (!isset($_COOKIE['xepan_lead_subscription']) and $this->options['show_as_popup'] === true) { return $form->js(null, $form->js()->_selector('#' . $this->name . "_subscription_model")->modal('hide'))->univ()->successMessage('Done')->execute(); } return $form->js()->univ()->successMessage('Done')->execute(); } $lead = $this->add('xepan\\marketing\\Model_Lead'); try { $this->api->db->beginTransaction(); $lead['source'] = 'Subscription'; if ($this->options['ask_name']) { $lead['first_name'] = $form['first_name']; $lead['last_name'] = $form['last_name']; } else { $lead['first_name'] = 'Guest'; $lead['last_name'] = 'Visitor'; } $lead->save(); $this->app->hook('pointable_event', ['Subscription', ['lead' => $lead], 'score' => false]); foreach ($selected_category as $cat) { $assoc = $this->add('xepan\\marketing\\Model_Lead_Category_Association'); $assoc['lead_id'] = $lead->id; $assoc['marketing_category_id'] = $cat; $assoc['created_at'] = $this->app->now; $assoc->save(); } $email_info = $this->add('xepan\\base\\Model_Contact_Email'); $email_info['contact_id'] = $lead->id; $email_info['head'] = 'Official'; $email_info['value'] = $form['email']; $email_info->save(); $this->api->db->commit(); } catch (\Exception $e) { $this->api->db->rollback(); return $form->error('email', 'An unexpected error occured'); } setcookie('xepan_lead_subscription', $form['email']); if ($this->options['send_mail']) { $email_id = $form['email']; $this->sendThankYouMail($email_id); } if ($this->options['on_success'] == 'Same Page') { if (!isset($_COOKIE['xepan_lead_subscription']) and $this->options['show_as_popup'] === true) { return $form->js(null, $form->js()->_selector('#' . $this->name . "_subscription_model")->modal('hide'))->univ()->successMessage('Done')->execute(); } return $form->js()->univ()->successMessage('Done')->execute(); } else { $this->app->redirect($this->app->url($this->options['success_url'])); } } }
function init() { parent::init(); $form_layout = 'view/tool/filter/formsection'; if ($this->options['custom_template']) { $path = getcwd() . "/websites/" . $this->app->current_website_name . "/www/view/tool/filter" . $this->options['custom_template'] . ".html"; if (file_exists($path)) { $form_layout = 'view/tool/filter/' . $this->options['custom_template']; } else { $this->add('View_Error')->set('Custom template not found.'); return; } } $this->app->stickyGET('xsnb_category_id'); $previous_selected_filter = json_decode($this->app->recall('filter'), true) ?: []; $model_filter = $this->add('xepan\\commerce\\Model_Filter'); if (!$model_filter->count()->getOne()) { $this->add('View_Error')->set('no filter found'); return; } //Filter Form $form = $this->add('Form', null, null, ['form/empty']); //price slider if ($this->options['show_price_filter']) { $this->heading = $form->add('View', null, null, [$form_layout]); $price = $this->heading->addField('xepan\\commerce\\RangeSlider', 'price'); $price->min = $this->options['min_price'] ?: 0; $price->max = $this->options['max_price'] ?: 10; $price->step = $this->options['step'] ?: 1; $price->left = $this->options['left_label'] ?: 'min'; $price->right = $this->options['right_label'] ?: 'max'; if ($price_range = $this->app->recall('price_range')) { $range_array = explode(",", $price_range); $price->selected_min = $range_array[0]; $price->selected_max = $range_array[1]; $price->set($price_range); // $this->app->forget('price_range'); } $this->heading->template->trySet('name', 'Price Range ' . $price->selected_min . " - " . $price->selected_max); } $q = $model_filter->dsql(); /** get all unique value Filterable specification has many Association Association has many values */ //join with association $asso_join = $model_filter->Join('customfield_association.customfield_generic_id', 'id'); //association join with values $value_join = $asso_join->join('customfield_value.customfield_association_id', 'id'); $value_join->addField('value_name', 'name'); $value_join->addField('value_id', 'id'); //group by with value name $cf_name_group_element = $q->expr('[0]', [$model_filter->getElement('id')]); //group by with specification name $value_group_element = $q->expr('[0]', [$model_filter->getElement('value_name')]); $model_filter->_dsql()->group($value_group_element); $model_filter->addCondition('value_name', '<>', ""); $model_filter->setOrder('value_name', 'asc'); $model_filter->setOrder('name', 'asc'); $unique_specification_array = []; $count = 1; foreach ($model_filter as $specification) { if (!isset($unique_specification_array[$specification['name']])) { $this->heading = $form->add('View', null, null, ['view/tool/filter/formsection']); $this->heading->template->trySet('name', $specification['name']); // $this->heading->add('H2')->set($specification['name']); $unique_specification_array[$specification['name']] = []; } $field = $this->heading->addField('checkbox', $specification['value_id'], $specification['value_name']); if (count($previous_selected_filter)) { // echo "<pre>"; // print_r($previous_selected_filter[$specification['id']]['values']); if (isset($previous_selected_filter[$specification['id']])) { if (in_array($specification['value_name'], $previous_selected_filter[$specification['id']])) { $field->set(1); } } } // $count++; } // $form->on('click','input',$form->js()->submit()); $form->on('change', 'input', $form->js()->submit()); //specification_id_1:value1,value2|specification_id_2:value_1,value_2 if ($form->isSubmitted()) { $selected_options = []; $str = ""; $specification_array = []; // $count = 1; foreach ($model_filter as $specification) { //if filter checked or not if ($form[$specification['value_id']]) { if (!isset($specification_array[$specification['id']])) { $specification_array[$specification['id']] = []; } $specification_array[$specification['id']][] = $specification['value_name']; // echo '<pre>'; // var_dump($specification_array); // exit; } // $count++; } $this->app->memorize('filter', json_encode($specification_array, true)); $this->app->memorize('price_range', $form['price']); $form->app->redirect($this->app->url()); } }
function init() { parent::init(); //Memorize checkout page if not logged in $this->api->memorize('next_url', array('page' => $_GET['page'], 'order_id' => $_GET['order_id'])); //Check for the authtentication if (!$this->app->auth->model->id) { $this->stepLogin(); return; } $customer = $this->add('xepan\\commerce\\Model_Customer'); if (!$customer->loadLoggedIn()) { $this->add('View_Error')->set("customer not found"); // $this->app->redirect("logout"); return; } // Check if order is owned by current member ?????? if (isset($_GET['order_id'])) { $order = $this->order = $this->api->memorize('checkout_order', $this->api->recall('checkout_order', $this->add('xepan/commerce/Model_SalesOrder')->tryLoad($_GET['order_id'] ?: 0))); if (!$order->loaded()) { $this->api->forget('checkout_order'); $this->add('View_Error')->set('Order not found'); return; } if ($order['contact_id'] != $customer->id) { $this->add('View_Error')->set('Order does not belongs to your account. ' . $order->id); return; } } if ($_GET['canceled']) { $this->stepFailure(); return; } // $this->api->stickyGET('step'); $step = isset($_GET['step']) ? $_GET['step'] : "address"; try { $this->{"step{$step}"}(); } catch (Exception $e) { // remove all database tables if exists or connetion available // remove config-default.php if exists throw $e; } // ================================= PAYMENT MANAGEMENT ======================= if ($_GET['pay_now'] == 'true') { if (!$this->app->recall('checkout_order') instanceof \xepan\commerce\Model_SalesOrder) { throw new \Exception("order not found"); } $order = $this->order = $this->app->recall('checkout_order'); $this->order->reload(); // create gateway $gateway = $this->gateway; $gateway_factory = new GatewayFactory(); $gateway = $gateway_factory->create($order['paymentgateway']); $gateway_parameters = $order->ref('paymentgateway_id')->get('parameters'); $gateway_parameters = json_decode($gateway_parameters, true); // fill default values from database foreach ($gateway_parameters as $param => $value) { $param = ucfirst($param); $fn = "set" . $param; $gateway->{$fn}($value); } $protocol = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://'; $params = array('amount' => $order['net_amount'], 'currency' => 'INR', 'description' => 'Invoice Against Order Payment', 'transactionId' => $order->id, 'headerImageUrl' => 'http://xavoc.com/logo.png', 'returnUrl' => $protocol . $_SERVER['HTTP_HOST'] . $this->api->url(null, array('paid' => 'true', 'pay_now' => 'true', 'order_id' => $this->order->id))->getURL(), 'cancelUrl' => $protocol . $_SERVER['HTTP_HOST'] . $this->api->url(null, array('canceled' => 'true', 'order_id' => $this->order->id))->getURL(), 'language' => 'EN', 'billing_name' => $customer['first_name'], 'billing_address' => $order['billing_address'], 'billing_city' => $order['billing_city'], 'billing_state' => $order['billing_state'], 'billing_country' => $order['billing_country'], 'billing_zip' => $order['billing_pincode'], 'billing_tel' => $customer['contacts_str'], 'billing_email' => $this->app->auth->model['username'], 'delivery_address' => $order['shipping_address'], 'delivery_city' => $order['shipping_city'], 'delivery_state' => $order['shipping_state'], 'delivery_country' => $order['shipping_country'], 'delivery_zip' => $order['shipping_pincode'], 'delivery_tel' => $customer['contacts_str'], 'delivery_email' => $this->app->auth->model['username']); // Step 2. if got returned from gateway ... manage .. if ($_GET['paid']) { $response = $gateway->completePurchase($params)->send($params); if (!$response->isSuccessful()) { $order_status = $response->getOrderStatus(); throw new \Exception("Failed"); // if(in_array($order_status, ['Failure'])) // $order_status = "onlineFailure"; // elseif(in_array($order_status, ['Aborted'])) // $order_status = "onlineAborted"; // else // $order_status = "onlineFailure"; // $order->setStatus($order_status); $this->api->redirect($this->api->url(null, array('step' => "Failure", 'message' => $order_status, 'order_id' => $_GET['order_id']))); } $invoice = $order->invoice(); $invoice->PayViaOnline($response->getTransactionReference(), $response->getData()); //Change Order Status onlineUnPaid to Submitted $order->submit(); //send email after payment id paid successfully try { $salesorder_m = $this->add('xepan\\base\\Model_ConfigJsonModel', ['fields' => ['from_email' => 'Dropdown', 'subject' => 'line', 'body' => 'xepan\\base\\RichText', 'master' => 'xepan\\base\\RichText', 'detail' => 'xepan\\base\\RichText'], 'config_key' => 'SALESORDER_LAYOUT', 'application' => 'commerce']); $salesorder_m->add('xepan\\hr\\Controller_ACL'); $salesorder_m->tryLoadAny(); $config = $this->app->epan->config; $email_setting = $this->add('xepan\\communication\\Model_Communication_EmailSetting'); $email_setting->load($salesorder_m['from_email']); $customer = $invoice->customer(); $to_email = implode(',', $customer->getEmails()); /*To Maintain the complability to send function*/ $subject = $salesorder_m['subject']; $body = $salesorder_m['body']; // $merge_model_array=[]; $this->merge_model_array = array_merge($this->merge_model_array, $invoice->get()); $this->merge_model_array = array_merge($this->merge_model_array, $order->get()); $this->merge_model_array = array_merge($this->merge_model_array, $customer->get()); $temp_subject = $this->add('GiTemplate'); $temp_subject->loadTemplateFromString($subject); $subject_v = $this->add('View', null, null, $temp_subject); $subject_v->template->set($this->merge_model_array); $email_subject = $subject_v->getHtml(); $temp_body = $this->add('GiTemplate'); $temp_body->loadTemplateFromString($body); $body_v = $this->add('View', null, null, $temp_body); $body_v->template->set($this->merge_model_array); $email_body = $body_v->getHtml(); $invoice->acl = false; $invoice->send($email_setting->id, $to_email, null, null, $email_subject, $email_body); // $subject_v->destroy(); // $body_v->destroy(); } catch (Exception $e) { } $this->api->forget('checkout_order'); // $this->stepComplete(); $this->api->redirect($this->api->url(null, array('step' => "Complete", 'pay_now' => true, 'paid' => true, 'order_id' => $_GET['order_id']))); exit; // return; } // Step 1. initiate purchase .. try { //Sending $param with send function for passing value to gateway //dont know it's right way or no $response = $gateway->purchase($params)->send($params); if ($response->isSuccessful()) { // mark order as complete if not COD // Not doing onsite transactions now ... $responsereturn = $response->getData(); } elseif ($response->isRedirect()) { $response->redirect(); } else { // display error to customer exit($response->getMessage()); } } catch (\Exception $e) { throw $e; // internal error, log exception and display a generic message to the customer exit('Sorry, there was an error processing your payment. Please try again later.' . $e->getMessage() . " " . get_class($e)); } } // ================================= PAYMENT MANAGEMENT END =================== }
function init() { parent::init(); $edit_cartitem_id = $this->app->stickyGET('edit_cartitem_id'); $item_member_design_id = $this->api->stickyGET('item_member_design'); $item_id = $this->api->stickyGET('xsnb_design_item_id'); $want_to_edit_template_item = $this->api->stickyGET('xsnb_design_template'); $this->api->stickyGET('show_cart'); $this->api->stickyGET('show_preview'); //display cart tool if ($_GET['show_cart'] and $item_id) { $item = $this->add('xepan\\commerce\\Model_Item')->load($item_id); // display the name of item $this->template->trySet('name', $item['name'] . " ( " . $item['sku'] . " ) "); $this->template->trySet('step1_class', 'xepan-designer-step-deactive'); $this->template->trySet('step2_class', 'xepan-designer-step-deactive'); $this->template->trySet('step3_class', 'xepan-designer-step-active'); $this->template->tryDel('designer_tool_wrapper'); $this->template->tryDel('design_preview_wrapper'); $previous_button = $this->add('Button', null, 'previous_button')->addClass('xepan-designer-previous-step-button'); $previous_button->set('previous'); if ($previous_button->isclicked()) { $this->api->stickyForget('show_cart'); $this->js()->univ()->location($this->app->url(null, ['show_preview' => 1, 'edit_cartitem_id' => $_GET['edit_cartitem_id']]))->execute(); } $v = $this->add('View', null, 'add_to_cart', ['view/tool/designer/addtocart'])->addClass('xshop-item'); $v1 = $v->add('View', null, 'sale_price')->setElement('span')->addClass('xepan-commerce-tool-item-sale-price')->set($item['sale_price']); if ($this->options['show_original_price']) { $v2 = $v->add('View', null, 'original_price')->addClass('xepan-commerce-tool-item-original-price')->set($item['original_price']); } else { $this->template->tryDel('original_price'); } if ($this->options['show_shipping_charge'] and !$this->options['shipping_charge_with_item_amount']) { $v->add('View', null, 'shipping_price')->setElement('span')->addClass('xepan-commerce-tool-item-shipping-charge')->set(0); } else { $v->template->tryDel('shipping_price_wrapper'); } $cart_tool = $v->add('xepan\\commerce\\Tool_Item_AddToCartButton', ['options' => $this->options, 'item_member_design' => $item_member_design_id], 'price_addtocart_tool'); $cart_tool->setModel($item); $this->template->tryDel('next_button'); } elseif ($_GET['show_preview']) { $this->template->trySet('step1_class', 'xepan-designer-step-deactive'); $this->template->trySet('step2_class', 'xepan-designer-step-active'); $this->template->trySet('step3_class', 'xepan-designer-step-deactive'); $this->template->tryDel('designer_tool_wrapper'); $this->template->tryDel('add_to_cart_wrapper'); //next button for addto cart button $form_design_approved = $this->add('Form', null, 'check_and_approved_design'); $approved_checkbox = $form_design_approved->addField('checkbox', 'approved', $this->options['approved_design_checkbox_label']); $approved_checkbox->validate('required'); $previous_button = $this->add('Button', null, 'previous_button')->addClass('xepan-designer-previous-step-button'); $previous_button->set('previous'); if ($previous_button->isclicked()) { $this->app->stickyForget('show_preview'); $this->js()->univ()->location($this->api->url(['item_member_design' => $item_member_design_id, 'xsnb_design_item_id' => $item_id, 'xsnb_design_template' => $want_to_edit_template_item]))->execute(); } $next_button = $this->add('Button', null, 'next_button')->addClass('xepan-designer-next-step-button'); $next_button->set('next'); if ($next_button->isclicked()) { // throw new \Exception("first Next".$_GET['edit_cartitem_id'], 1); $form_design_approved->js()->submit()->execute(); } //load designs // $item_model = $this->add('xepan\commerce\Model_Item')->tryLoad($item_id); // if(!$item_model->loaded()){ // $this->add('View_Error',null,'design_preview')->set('Design Not loaded '); // return; // } $model_template_design = $this->add('xepan\\commerce\\Model_Item_Template_Design'); $model_template_design->addCondition('item_id', $item_id)->addCondition('id', $item_member_design_id); $customer = $this->add('xepan\\base\\Model_Contact'); $customer_logged_in = $customer->loadLoggedIn(); if (!$model_template_design->count()->getOne() and $customer_logged_in) { throw new \Exception("some thing happen wrong, design not found"); } $this->add('xepan\\commerce\\Tool_Item_Designer', ['options' => $this->options, 'item_member_design' => $item_member_design_id, 'xsnb_design_item_id' => $item_id, 'printing_mode' => false, 'show_canvas' => false, 'is_start_call' => 0, 'show_tool_bar' => false, 'show_pagelayout_bar' => true, 'show_layout_bar' => false, 'show_paginator' => 0, 'model' => 'primary', 'is_preview_mode' => 1, 'generating_image' => true], 'design_preview'); // $form_design_approved->addSubmit('Next'); if ($form_design_approved->isSubmitted()) { $this->app->stickyForget('show_preview'); $form_design_approved->js()->univ()->location($this->api->url(['show_cart' => 1, 'edit_cartitem_id' => $_GET['edit_cartitem_id']]))->execute(); } } else { //add class $this->template->trySet('step1_class', 'xepan-designer-step-active'); $this->template->trySet('step2_class', 'xepan-designer-step-deactive'); $this->template->trySet('step3_class', 'xepan-designer-step-deactive'); $this->template->tryDel('add_to_cart_wrapper'); $this->template->tryDel('design_preview_wrapper'); //step 1 $next_btn = $this->add('Button', null, 'next_button')->addClass('xepan-designer-next-step-button'); $next_btn->set('Next'); if ($next_btn->isclicked()) { // throw new \Exception($_GET['edit_cartitem_id'], 1); //check for the designed is saved or not if (!$item_member_design_id) { $this->js()->univ()->errorMessage('save your design first')->execute(); } $template_design = $this->add('xepan/commerce/Model_Item_Template_Design')->tryLoad($item_member_design_id); if (!$template_design->loaded()) { $this->js()->univ()->errorMessage('member not found')->execute(); } $contact_model = $this->add('xepan\\base\\Model_Contact')->tryLoad($template_design['contact_id']); if (!$contact_model->loadLoggedIn()) { $this->js()->univ()->errorMessage('not authorize users')->execute(); } $this->js()->univ()->location($this->app->url(null, ['show_preview' => 1, 'edit_cartitem_id' => $_GET['edit_cartitem_id']]))->execute(); } $designer_tool = $this->add('xepan\\commerce\\Tool_Item_Designer', ['options' => $this->options], 'designer_tool'); } }
function init() { parent::init(); //Validate Required Options Value $message = $this->validateRequiredOptions(); if ($message != 1) { $this->add('View_Warning')->set($message); return; } if ($this->options['show_microdata']) { $this->company_m = $this->add('xepan\\base\\Model_ConfigJsonModel', ['fields' => ['company_name' => "Line", 'company_owner' => "Line", 'mobile_no' => "Line", 'company_email' => "Line", 'company_address' => "Line", 'company_pin_code' => "Line", 'company_description' => "text"], 'config_key' => 'COMPANY_AND_OWNER_INFORMATION', 'application' => 'communication']); $this->company_m->tryLoadAny(); } $item = $this->add('xepan\\commerce\\Model_Item_WebsiteDisplay'); $item->addCondition('status', 'Published'); $q = $item->dsql(); $this->app->stickyGET('xsnb_category_id'); /** category wise filter */ //tool options show only category item $selected_category = []; if ($this->options["show_item_of_category"]) { $selected_category = explode(",", $this->options["show_item_of_category"]); } elseif ($_GET['xsnb_category_id'] and is_numeric($_GET['xsnb_category_id'])) { $selected_category[] = $_GET['xsnb_category_id']; } if (count($selected_category)) { $item_join = $item->Join('category_item_association.item_id'); $item_join->addField('category_id'); $item_join->addField('category_assos_item_id', 'item_id'); $cat_join = $item_join->leftJoin('category.document_id', 'category_id'); $cat_join->addField('category_document_id', 'document_id'); $document_join = $cat_join->leftJoin('document.id', 'document_id'); $document_join->addField('category_status', 'status'); $item->addCondition('category_status', "Active"); $item->addCondition('category_id', $selected_category); $group_element = $q->expr('[0]', [$item->getElement('category_assos_item_id')]); } if ($_GET['search']) { // $item->addExpression('Relevance')->set('MATCH(search_string) AGAINST ("'.$_GET['search'].'" IN NATURAL LANGUAGE MODE)'); $item->addExpression('Relevance')->set(function ($m, $q) { return $q->expr('MATCH([0]) AGAINST ("[1]" IN NATURAL LANGUAGE MODE)', [$q->getField('search_string'), $_GET['search']]); }); $item->addCondition('Relevance', '>', 0); $item->setOrder('Relevance', 'Desc'); } // //Price Range Search if ($price_range = $this->app->recall('price_range')) { $price_array = explode(",", $price_range); $item->addCondition('sale_price', '>=', $price_array[0]); $item->addCondition('sale_price', '<=', $price_array[1]); $this->app->forget('price_range'); } // //Filter Search if ($this->options['filter-effect'] and $filter = $this->app->recall('filter', false)) { $selected_filter_data_array = json_decode($filter, $filter); $item_custom_field_asso_j = $item->Join('customfield_association.item_id', 'id'); $item_custom_field_asso_j->addField('customfield_generic_id'); $item_custom_field_asso_j->addField('specification_item_id', 'item_id'); $custom_field_j = $item_custom_field_asso_j->join('customfield_generic.id', 'customfield_generic_id'); $custom_field_j->addField('cf_is_filterable', 'is_filterable'); $item->addCondition('cf_is_filterable', true); $cf_asso_value_j = $item_custom_field_asso_j->join('customfield_value.customfield_association_id', 'id'); $cf_asso_value_j->addField('value_name', 'name'); $cf_asso_value_j->addField('value_status', 'status'); $item->addCondition('value_status', 'Active'); $cond = []; foreach ($selected_filter_data_array as $specification_id => $values_array) { if (empty($values_array)) { continue; } $or = $q->orExpr(); foreach ($values_array as $value) { $or->where($q->expr('[0] = "[1]"', [$item->getElement('value_name'), $value])); } $item->addCondition($q->andExpr()->where('customfield_generic_id', $specification_id)->where($or)); } $group_element = $q->expr('[0]', [$item->getElement('specification_item_id')]); $item->_dsql()->group($group_element); // Multiple category association shows multiple times item so .. grouped $this->app->forget('filter'); } //load record according to sequence of order $item->setOrder('display_sequence', 'desc'); $layout_template = $this->options['layout']; if ($this->options['custom_template']) { $path = getcwd() . "/websites/" . $this->app->current_website_name . "/www/view/tool/item/" . $this->options['custom_template'] . ".html"; if (!file_exists($path)) { throw new \Exception($path); $this->add('View_Warning')->set('template not found'); return; } else { $layout_template = $this->options['custom_template']; } } $cl = $this->add('CompleteLister', null, null, ['view/tool/item/' . $layout_template]); //not record found if (!$item->count()->getOne()) { $cl->template->set('not_found_message', 'No Record Found'); } else { $cl->template->del('not_found'); } if ($designer_id = $this->app->stickyGET('designer_id')) { $item->addCondition('designer_id', $designer_id); } $cl->setModel($item); if (!($this->options['show_item_count'] or $this->options['show_category_name'])) { $cl->template->tryDel('item_count_wrapper'); } else { // show item count if ($this->options['show_item_count']) { $cl->template->trySet('item_count', $item->count()->getOne()); } if ($this->options['show_category_name']) { $str = ""; foreach ($selected_category as $cat_id) { $ct_model = $this->add('xepan\\commerce\\Model_Category')->tryLoad($cat_id); if ($ct_model->loaded()) { $str .= $ct_model['name'] . ", "; } } $cl->template->trySet('category_name', rtrim($str, ", ")); } } if ($this->options['show_paginator'] == "true") { $paginator = $cl->add('Paginator', ['ipp' => $this->options['paginator_set_rows_per_page']]); $paginator->setRowsPerPage($this->options['paginator_set_rows_per_page']); } $cl->add('xepan\\cms\\Controller_Tool_Optionhelper', ['options' => $this->options, 'model' => $item]); $self = $this; $url = $this->app->url($this->options['personalized_page_url']); //click in personilize btn redirect to personilize pag $cl->on('click', '.xepan-commerce-item-personalize', function ($js, $data) use($url, $self) { $url = $self->app->url($url, ['xsnb_design_item_id' => $data['xsnbitemid']]); return $js->univ()->location($url); }); }