Opencart adding 3rd level category in filter module - add

i'm using a module for product filter,
In my admin backend i can able to set filter only for first and second level categories. I need to add 3rd level category too.
Below mentioned is my module controller file,
<?php
class ControllerModuleSuperCategoryMenu extends Controller {
private $error = array();
public function index() {
$this->data['current_version']='2.0.7';
//remove cache files
$this->cache->delete('product_filters');
$this->cache->delete('attribute_filters');
$this->load->language('module/supercategorymenu');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('setting/setting');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_setting_setting->editSetting('supercategorymenu', $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
}
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['tab_general'] = $this->language->get('tab_general');
$this->data['tab_settings'] = $this->language->get('tab_settings');
$this->data['tab_layouts'] = $this->language->get('tab_layouts');
$this->data['tab_contact'] = $this->language->get('tab_contact');
$this->data['entry_all_values'] = $this->language->get('entry_all_values');
$this->data['entry_list_number'] = $this->language->get('entry_list_number');
$this->data['entry_list_number_explanation'] = $this->language->get('entry_list_number_explanation');
$this->data['entry_pricerange'] = $this->language->get('entry_pricerange');
$this->data['entry_pricerange_explanation'] = $this->language->get('entry_pricerange_explanation');
$this->data['entry_set_vat'] = $this->language->get('entry_set_vat');
$this->data['entry_set_vat_explanation'] = $this->language->get('entry_set_vat_explanation');
$this->data['default_vat_price_range'] = $this->language->get('default_vat_price_range');
$this->data['default_vat_price_range_explanation'] = $this->language->get('default_vat_price_range_explanation');
$this->data['entry_manufacturer'] = $this->language->get('entry_manufacturer');
$this->data['entry_manufacturer_explanation'] = $this->language->get('entry_manufacturer_explanation');
$this->data['text_yes'] = $this->language->get('text_yes');
$this->data['text_no'] = $this->language->get('text_no');
$this->data['entry_count'] = $this->language->get('entry_count');
$this->data['entry_count_explanation'] = $this->language->get('entry_count_explanation');
$this->data['entry_ocscroll'] = $this->language->get('entry_ocscroll');
$this->data['entry_ocscroll_explanation'] = $this->language->get('entry_ocscroll_explanation');
$this->data['entry_nofollow'] = $this->language->get('entry_nofollow');
$this->data['entry_nofollow_explanation'] = $this->language->get('entry_nofollow_explanation');
$this->data['entry_track_google'] = $this->language->get('entry_track_google');
$this->data['entry_track_google_explanation'] = $this->language->get('entry_track_google_explanation');
$this->data['entry_ajax'] = $this->language->get('entry_ajax');
$this->data['entry_ajax_explanation'] = $this->language->get('entry_ajax_explanation');
$this->data['entry_order'] = $this->language->get('entry_order');
$this->data['entry_order_explanation'] = $this->language->get('entry_order_explanation');
$this->data['text_enabled'] = $this->language->get('text_enabled');
$this->data['text_disabled'] = $this->language->get('text_disabled');
$this->data['text_content_top'] = $this->language->get('text_content_top');
$this->data['text_content_bottom'] = $this->language->get('text_content_bottom');
$this->data['text_column_left'] = $this->language->get('text_column_left');
$this->data['text_column_right'] = $this->language->get('text_column_right');
$this->data['entry_layout'] = $this->language->get('entry_layout');
$this->data['entry_position'] = $this->language->get('entry_position');
$this->data['entry_status'] = $this->language->get('entry_status');
$this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
$this->data['entry_value'] = $this->language->get('entry_value');
$this->data['entry_separator'] = $this->language->get('entry_separator');
$this->data['entry_examples'] = $this->language->get('entry_examples');
$this->data['entry_separator_explanation'] = $this->language->get('entry_separator_explanation');
$this->data['entry_values_explanation'] = $this->language->get('entry_values_explanation');
$this->data['text_none'] = $this->language->get('text_none');
$this->data['button_save'] = $this->language->get('button_save');
$this->data['button_cancel'] = $this->language->get('button_cancel');
$this->data['button_add_module'] = $this->language->get('button_add_module');
$this->data['button_remove'] = $this->language->get('button_remove');
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} else {
$this->data['error_warning'] = '';
}
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_module'),
'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: '
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('module/supercategorymenu', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: '
);
$this->data['action'] = $this->url->link('module/supercategorymenu', 'token=' . $this->session->data['token'], 'SSL');
$this->data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
$this->data['settings'] = $this->url->link('module/supercategorymenu/settings', 'token=' . $this->session->data['token'], 'SSL');
$this->data['modules'] = array();
if (isset($this->request->post['supercategorymenu_module'])) {
$this->data['modules'] = $this->request->post['supercategorymenu_module'];
} elseif ($this->config->get('supercategorymenu_module')) {
$this->data['modules'] = $this->config->get('supercategorymenu_module');
}
$this->data['settings'] = array();
if (isset($this->request->post['supercategorymenu_settings'])) {
$this->data['settings'] = $this->request->post['supercategorymenu_settings'];
} elseif ($this->config->get('supercategorymenu_settings')) {
$this->data['settings'] = $this->config->get('supercategorymenu_settings');
}
if (isset($this->data['settings']['track_google'])){
$this->data['settings_trackgoogle']=$this->data['settings']['track_google'];
}else{
$this->data['settings_trackgoogle']=0;
}
if (isset($this->data['settings']['list_number'])){
$this->data['settings_listnumber']=$this->data['settings']['list_number'];
}else{
$this->data['settings_listnumber']=7;
}
if (isset($this->data['settings']['nofollow'])){
$this->data['settings_nofollow']=$this->data['settings']['nofollow'];
}else{
$this->data['settings_nofollow']=1;
}
if (isset($this->data['settings']['ajax'])){
$this->data['settings_ajax']=$this->data['settings']['ajax'];
}else{
$this->data['settings_ajax']=0;
}
if (isset($this->data['settings']['order'])){
$this->data['settings_order']=$this->data['settings']['order'];
}else{
$this->data['settings_order']="OH";
}
if (isset($this->data['settings']['ocscroll'])){
$this->data['settings_ocscroll']=$this->data['settings']['ocscroll'];
}else{
$this->data['settings_ocscroll']=0;
}
if (isset($this->data['settings']['countp'])){
$this->data['settings_countp']=$this->data['settings']['countp'];
}else{
$this->data['settings_countp']=1;
}
if (isset($this->data['settings']['pricerange'])){
$this->data['settings_pricerange']=$this->data['settings']['pricerange'];
}else{
$this->data['settings_pricerange']=1;
}
if (isset($this->data['settings']['setvat'])){
$this->data['settings_setvat']=$this->data['settings']['setvat'];
}else{
$this->data['settings_setvat']=1;
}
if (isset($this->data['settings']['manufacturer'])){
$this->data['settings_manufacturer']=$this->data['settings']['manufacturer'];
}else{
$this->data['settings_manufacturer']=1;
}
if (isset($this->data['settings']['tax_class_id'])){
$this->data['tax_class_id']=$this->data['settings']['tax_class_id'];
}else{
$this->data['tax_class_id']="";
}
$this->load->model('localisation/tax_class');
$this->data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
$this->load->model('module/supercategorymenu');
$this->data['categories'] = array();
$categories = $this->model_module_supercategorymenu->getCategories(0);
foreach ($categories as $category) {
if (isset($this->request->post['VALORES_'.$category['category_id'].''])) {
$this->data['category_attributes'][$category['category_id']]= $this->request->post['VALORES_'.$category['category_id'].''];
} else {
$this->data['category_attributes'][$category['category_id']] = $this->config->get('VALORES_'.$category['category_id'].'');
}
$children_data = array();
$children = $this->model_module_supercategorymenu->getCategories($category['category_id']);
foreach ($children as $child) {
if (isset($this->request->post['VALORES_'.$child['category_id'].''])) {
$this->data['category_attributes'][$child['category_id']]= $this->request->post['VALORES_'.$child['category_id'].''];
} else {
$this->data['category_attributes'][$child['category_id']] = $this->config->get('VALORES_'.$child['category_id'].'');
}
$results = $this->model_module_supercategorymenu->getCategoryAttributes($child['category_id']);
$attribute_data = array();
foreach ($results as $result) {
if (isset($this->data['category_attributes'][$child['category_id']]['attributes'][$result['attribute_id']])){
$attribute_checked=true;
$attribute_seperator=$this->data['category_attributes'][$child['category_id']]['attributes'][$result['attribute_id']]['separator'];
}else{
$attribute_checked=false;
$attribute_seperator="no";
}
$attribute_values=array();
$attribute_values = $this->model_module_supercategorymenu->getAttributeValues($result['attribute_id']);
//foreach ($res as $attribute_value){
//$attribute_values[key($res)]=$attribute_value;
//}
$attribute_data[] = array(
'attribute_id' => $result['attribute_id'],
'name' => $result['name'],
'checked' => $attribute_checked,
'separator' => $attribute_seperator,
'attribute_values'=> $attribute_values
);
}
$children_data[] = array(
'category_id' => $child['category_id'],
'name' => $child['name'],
'attributes' => $attribute_data
);
}
$results = $this->model_module_supercategorymenu->getCategoryAttributes($category['category_id']);
$attribute_data = array();
foreach ($results as $result) {
if (isset($this->data['category_attributes'][$category['category_id']]['attributes'][$result['attribute_id']])){
$attribute_checked=true;
$attribute_seperator=$this->data['category_attributes'][$category['category_id']]['attributes'][$result['attribute_id']]['separator'];
}else{
$attribute_checked=false;
$attribute_seperator="no";
}
$attribute_values_child=array();
$attribute_values_child = $this->model_module_supercategorymenu->getAttributeValues($result['attribute_id']);
//foreach ($res_child as $attribute_value_child){
//$attribute_values_child[key($res)]=$attribute_value_child;
//}
$attribute_data[] = array(
'attribute_id' => $result['attribute_id'],
'name' => $result['name'],
'checked' => $attribute_checked,
'separator' => $attribute_seperator,
'attribute_values'=> $attribute_values_child
);
}
$this->data['categories'][] = array(
'category_id' => $category['category_id'],
'name' => $category['name'],
'children' => $children_data,
'attributes' => $attribute_data,
//'valores_bd' => $this->data['category_attributes'][$category['category_id']]
);
}
$this->load->model('setting/extension');
if(in_array("ocscroll",$this->model_setting_extension->getInstalled('module'))){
$this->data['ocscroll']=true;
}else{
$this->data['ocscroll']=false;
}
$ch = curl_init();
// Now set some options (most are optional)
// Set URL to download
curl_setopt($ch, CURLOPT_URL,"http://opencart.tictachome.com/version/version.xml");
// Include header in result? (0 = yes, 1 = no)
curl_setopt($ch, CURLOPT_HEADER, 0);
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Timeout in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// Download the given URL, and return output
$output = curl_exec($ch);
// Close the cURL resource, and free system resources
curl_close($ch);
$analizador=simplexml_load_string($output,null);
$this->data['version']['version']=$analizador->children()->version;
$this->data['version']['whats_new']=$analizador->children()->whats_new;
foreach($analizador->children()->other_modules as $other_modules){
$this->data['version']['modules'][]=array(
'name' =>$other_modules->name,
'version' =>$other_modules->version,
'url' =>$other_modules->url,
'manual' =>$other_modules->manual,
'price' =>$other_modules->price,
'resume' =>$other_modules->resume,
);
}
$this->load->model('localisation/language');
$this->data['languages'] = $this->model_localisation_language->getLanguages();
$this->load->model('design/layout');
$this->data['layouts'] = $this->model_design_layout->getLayouts();
$this->template = 'module/supercategorymenu.tpl';
$this->children = array(
'common/header',
'common/footer'
);
$this->response->setOutput($this->render());
}
private function validate() {
if (!$this->user->hasPermission('modify', 'module/supercategorymenu')) {
$this->error['warning'] = $this->language->get('error_permission');
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>
Did anyone know how to add the 3rd level category too..
Please share your suggestions.
Thanks,

Related

connection.queryRaw is not a function error in NodeJs WebAPI call

I am new to Nodejs. I am developing WebAPI by using NodeJs and MSSQl as database.My api is giving proper response in case of POST endpoint If it is called while server is listening through Dev environment command [npm run start]. But, If I Deploy my API on Windows IIS , it is giving the mentioned error. My reference API endpoint code is as below :
router.post('/',async (req,res,next)=>{
// console.log('Enter products creation')
const Product = Array.from(req.body) // req.body
// console.log('New Product details passed on',Product)
const createProd = require('../CreateProduct')
const response = await createProd(Product)
res.status(404).json({
message : response.retStatus
})
})
CreateProduct function called in above code is as below :
const sql = require("mssql/msnodesqlv8");
const dataAccess = require("../DataAccess");
const fn_CreateProd = async function (product) {
let errmsg = "";
let objBlankTableStru = {};
let connPool = null;
// console.log('Going to connect with Connstr:',global.config)
await sql
.connect(global.config)
.then((pool) => {
global.connPool = pool;
productsStru = pool.request().query("DECLARE #tblProds tvp_products select * from #tblProds");
return productsStru;
})
.then(productsStru=>{
objBlankTableStru.products = productsStru
productsOhStru = global.connPool.request().query("DECLARE #tblprodsOh tvp_product_oh select * from #tblprodsOh");
return productsOhStru
})
.then((productsOhStru) => {
objBlankTableStru.products_oh = productsOhStru
let objTvpArr = [
{
uploadTableStru: objBlankTableStru,
},
{
tableName : "products",
tvpName: "tvp_products",
tvpPara: "tblProds"
},
{
tableName : "products_oh",
tvpName: "tvp_product_oh",
tvpPara: "tblProdsOh",
}
];
newResult = dataAccess.getPostResult(
objTvpArr,
"sp3s_ins_products_tvp",
product
);
console.log("New Result of Execute Final procedure", newResult);
return newResult;
})
.then((result) => {
// console.log("Result of proc", result);
if (!result.recordset[0].errmsg)
errmsg = "New Products Inserted successfully";
else errmsg = result.recordset[0].errmsg;
})
.catch((err) => {
console.log("Enter catch of Posting prod", err.message);
errmsg = err.message;
if (errmsg == "") {
errmsg = "Unknown error from Server... ";
}
})
.finally((resp) => {
sql.close();
});
return { retStatus: errmsg };
};
module.exports = fn_CreateProd;
GetPost() function is as below :
const getPostResult = (
tvpNamesArr,
procName,
sourceData,
sourceDataFormat,
singleTableData
) => {
let arrtvpNamesPara = [];
let prdTable = null;
let newSrcData = [];
// console.log("Source Data :", sourceData);
let uploadTable = tvpNamesArr[0];
for (i = 1; i <= tvpNamesArr.length - 1; i++) {
let tvpName = tvpNamesArr[i].tvpName;
let tvpNamePara = tvpNamesArr[i].tvpPara;
let TableName = tvpNamesArr[i].tableName;
let srcTable = uploadTable.uploadTableStru[TableName];
srcTable = srcTable.recordset.toTable(tvpName);
let newsrcTable = Array.from(srcTable.columns);
newsrcTable = newsrcTable.map((i) => {
i.name = i.name.toUpperCase();
return i;
});
if (!singleTableData) {
switch (sourceDataFormat) {
case 1:
newSrcData = sourceData.filter((obj) => {
return obj.tablename.toUpperCase() === TableName.toUpperCase();
});
break;
case 2:
newSrcData = getObjectDatabyKey(sourceData, TableName);
break;
default:
newSrcData = getTableDatabyKey(sourceData, TableName);
break;
}
} else {
newSrcData = sourceData;
}
// console.log(`Filtered Source data for Table:${TableName}`, newSrcData);
prdTable = generateTable(
newsrcTable,
newSrcData,
tvpName,
sourceDataFormat
);
arrtvpNamesPara.push({ name: tvpNamePara, value: prdTable });
}
const newResult = execute(procName, arrtvpNamesPara);
return newResult;
};
Finally, I have found the solution to this.. it is very strange and shocking and surprising that If I using Morgan Middleware in app.js and have used it by syntax : app.use(morgan('dev')) , then it is the culprit command..I just removed dev from this command after which problem got resolved..But I found no help regarding this issue over Google anywhere..I really fear that what type of challenges I am going to face in future development if these kind of silly error come without giving any hint..I would be highly obliged If anyone could make me understand this kind of silly errors..

how to read json file and search with filter for common items in nodejs

I have JSON file contain games objects, I want to get top 5 games that have the highest total playtime between users.
I tried to get all objects by reading the file using file system in nodejs :
const queryGames = async () => {
let data = fs.readFileSync(path.resolve(__dirname, '../../games.json'))
let games = JSON.parse(data)
return games
}
/**
* Query for top games by play time
* #returns {Promise<QueryResult>}
*/
const selectTopByPlaytime = async () => {
}
this is the json file : https://jsoneditoronline.org/#left=cloud.3b82169327044c04b7207fa186aee85b&right=local.tiniqu
something like this should work.
const gamePlayData = require('./gamePlay.json').data
/**
* Query for games and time
* #returns {
'League of legends': 1650,
'World of warcraft': 2300,
'Dark Souls': 218,
'The Witcher 3: Wild Hunt': 987,
etc....
}
*/
const getGamePlayTimes = () => {
gamePlayTimes = {}
gamePlayData.forEach( (playData) => {
const gameName = playData.game
if(gamePlayTimes[gameName]) {
gamePlayTimes[gameName] += playData.playTime
}
else {
gamePlayTimes[gameName] = playData.playTime
}
})
return gamePlayTimes;
}
const getGamesAndTimesAsList = (playTimes) => {
let gamesWithTimeArr = [];
let i = 0;
for(let game in playTimes) {
let gameAndPlayTime = {game: "", playTime: 0};
gameAndPlayTime.game = game;
gameAndPlayTime.playTime = playTimes[game];
gamesWithTimeArr[i++] = gameAndPlayTime
}
return gamesWithTimeArr;
}
const reverseBubbleSort = (a, par) => {
let swapped;
do {
swapped = false;
for (var i = 0; i < a.length - 1; i++) {
if (a[i][par] < a[i + 1][par]) {
var temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
swapped = true;
}
}
} while (swapped);
return a;
}
sortedArr = reverseBubbleSort(getGamesAndTimesAsList( getGameAndPlayTimes() ) , 'playTime')
const top5 = sortedArr.slice(0, 5);
console.log(top5);

Gantt - Modifying the Mouse-over information on a project

Good Morning;
I am looking to modify a Gantt Chart so that the Title found on the left and currently showing on the project are the same but when you hove the mouse over it, it will show a different set of information. Would also like to know the best way to separate the weeks with a noticeable break line that runs the entire gantt chart. Here is the code:
Page:
#using Kendo.Mvc.UI
<p></p>
<h2>#ViewBag.Title</h2>
#(Html.Kendo().Gantt<cpr_web.Models.TaskViewModel, cpr_web.Models.DependencyViewModel>()
.Name("Gantt")
.Views(views =>
{
views.WeekView(w => w.DayHeaderTemplate("#=kendo.toString(start, 'dd' )#").SlotSize(40));
views.MonthView(m => m.WeekHeaderTemplate("#=kendo.toString(start,'d', end,'d')#").SlotSize(150));
//views.YearView();
})
.Columns(columns =>
{
columns.Bound("title").Editable(false).Sortable(true).Width(100);
//columns.Bound("start").Format("{0:MM-dd}").Sortable(true).Width(10);
columns.Bound("State").Editable(false).Sortable(true).Width(30);
columns.Bound("City").Editable(false).Sortable(true).Width(40);
//columns.Bound("PercentComplete").Sortable(true).Width(10).Title("Complete");
})
.Events(e => {
e.Edit("editingGantt");
e.DataBound("databoundGantt");
e.Remove("unsupported");
e.Change("unsupported");
e.Move("unsupported");
e.MoveEnd("unsupported");
e.MoveStart("unsupported");
e.Resize("unsupported");
e.ResizeEnd("unsupported");
e.ResizeStart("unsupported");
})
.Navigatable(false)
.Editable(e => e.Confirmation(false))
.Toolbar(t =>
{
t.Add().Name("Menu").Template("<a href='/BackendSchedule/Index'>Schedule Menu</a>");
})
.ListWidth("450")
.ShowWorkDays(false)
.ShowWorkHours(false)
.Snap(true)
.Height(2000)
.DataSource(ds => ds
.Read(read => read
.Action("Tasks", "BackendSchedule")
)
.Model(m =>
{
m.Id(f => f.TaskID);
m.ParentId(f => f.ParentID);
m.OrderId(f => f.OrderId);
m.Field(f => f.Title);
m.Field(f => f.Title1);
m.Field(f => f.Start);
m.Field(f => f.End);
m.Field(f => f.Expanded).DefaultValue(false);
})
)
//.DependenciesDataSource(ds => ds
// .Read(read => read
// .Action("Dependencies", "BackendSchedule")
// )
// .Model(m =>
// {
// m.Id(f => f.DependencyID);
// m.PredecessorId(f => f.PredecessorID);
// m.SuccessorId(f => f.SuccessorID);
// m.Type(f => f.Type);
// })
//)
.Resources(r =>
{
r.Field("resources");
r.DataColorField("Color");
r.Field("PercentComplete");
r.DataSource(ds => ds
.Custom()
.Schema(s => s
.Model(m => m.Id("Id"))
.Data("Message")
)
.Transport(t =>
{
t.Read("GanttResources", "BackendSchedule");
})
);
})
)
#(Html.Kendo().Window().Name("utilityWindow")
.Title("Edit Job")
.Iframe(true)
.Visible(false)
.Modal(true)
.Draggable(true)
.Width(500)
.Height(250)
.Events(evt => evt
.Close("closeWindow")
)
)
<script>
kendo.culture().calendar.firstDay = 1;
function closeWindow(e) {
$(this.element).empty();
}
function unsupported(e) {
// remove not supported/permitted in this app
e.preventDefault();
}
function editingGantt(e) {
var jobId = e.task.title.split(':')[0];
var win = $("#utilityWindow").data("kendoWindow");
win.refresh({ url: "/BackendSchedule/_Jobs?jobId=" + jobId + "&source=gantt" });
win.setOptions({
title: "Edit Jobs",
width: 1000,
height: 600,
});
win.center().open();
e.preventDefault();
}
function databoundGantt(e) {
var gantt = $("#Gantt").data("kendoGantt")
var data = gantt.dataSource.data();
$.each(data, function (i,row){
var taskElement = $("div[data-uid=\"" + data[i].uid + "\"]");
if (row.percentComplete == 0) {
taskElement.addClass("color-green");
} else {
taskElement.addClass("color-red");
}
//alert(row.percentComplete);
});
}
</script>
Controller:
#region Gantt
[Authorize(Roles = "Manager, Administrator, Responsible Party")]
public ActionResult Gantt()
{
ViewBag.Title = "Manage Schedule";
return View();
}
public JsonResult GanttResources()
{
List<MessageModel> resources = new List<MessageModel>();
MessageModel resource = new MessageModel();
resource.Id = "0";
resource.Message = "green";
resources.Add(resource);
resource = new MessageModel();
resource.Id = "1";
resource.Message = "red";
resources.Add(resource);
return Json(resources, JsonRequestBehavior.AllowGet);
}
[Authorize]
public JsonResult Tasks([DataSourceRequest] DataSourceRequest request)
{
Jobs jobs = new Jobs();
var tasks = jobs.GetTasks();
return Json(tasks.AsQueryable().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
public JsonResult Dependencies([DataSourceRequest] DataSourceRequest request)
{
var dependencies = new List<DependencyViewModel> {
new DependencyViewModel { DependencyID = 100, PredecessorID = 0, SuccessorID = 0, Type = DependencyType.FinishStart }
};
return Json(dependencies.AsQueryable().ToDataSourceResult(request));
}
public ActionResult Resources()
{
return View();
}
And Core: (Note the information desired is found on the title1)
public List<TaskViewModel> GetTasks()
{
List<TaskViewModel> tasks = new List<TaskViewModel>();
Teams teamObject = new Teams();
IEnumerable<TeamModel> teams = teamObject.GetTeam();
int taskId = 0;
int parentId = 0;
bool teamChanged = true;
foreach (TeamModel team in teams)
{
teamChanged = true;
taskId++;
parentId = taskId;
TaskViewModel task = new TaskViewModel();
task.TaskID = taskId;
task.ParentID = null;
task.Title = team.Name + ": " + team.LeadName;
task.Expanded = true;
task.Summary = true;
task.Start = DateTime.Today.AddDays(-7);
task.End = task.Start.AddMonths(3);
tasks.Add(task);
foreach (JobModel job in getJobs().Where(j => j.TeamId == team.Id).OrderBy(j => j.PlanStartDate))
{
taskId++;
task = new TaskViewModel();
task.TaskID = taskId;
task.ParentID = parentId;
task.Title = job.Id /*+ ": " + job.ContactName + ": " + job.Phone + ": " + job.FullAddress + ": " + job.City + ": " + job.State*/;
task.Title1 = job.Id + ": <p>" + job.ContactName + ": </br>" + job.Phone + ": </br>" + job.City + ": </br>" + job.State;
task.City = job.City;
task.State = job.State;
task.Start = job.PlanStartDate;
task.End = job.PlanEndDate;
task.Expanded =true;
task.Summary = false;
if (job.IsComplete)
{
task.PercentComplete = 0.001M;
}
else
{
task.PercentComplete = 0;
}
tasks.Add(task);
}
}
return tasks;
}
public IEnumerable<ScheduleModel> GetSchedule()
{
foreach (JobModel job in getJobs())
{
yield return new ScheduleModel
{
JobId = job.Id,
Title = job.Company,
ContactName = job.ContactName,
Email = job.Email,
Phone = job.Phone,
Start = job.PlanStartDate,
End = job.PlanEndDate,
IsAllDay = true,
TeamName=job.Company,
TeamId=job.CompanyId,
TeamColour=job.TeamId,
};
}
}
Ok so it turned out to be really simple, I just added this and can add any item in the taskViewModel to make it show up
.Tooltip(t =>
t.Template("Contractor: #=task.ContactName #, Phone: #=task.Phone #"))

Checkout page is not working

i am using lotusbreath one step checkout. its work fine on localhost but its not working after uploading on server.
On server place order button is not redirected to order successfully page.
Both place(sever and localhost) has same file, so i doesn't understand what to do.
Can anybody help me what to do?
This is the link of checkout page on server: this
here is the validation of placed order button
public function saveOrderAction()
{
if (!$this->_validateFormKey()) {
$this->_redirect('*/*');
return;
}
if ($this->_expireAjax()) {
return;
}
$result = array();
try {
$requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
if ($requiredAgreements) {
$postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
$diff = array_diff($requiredAgreements, $postedAgreements);
if ($diff) {
$result['success'] = false;
$result['error'] = true;
$result['error_messages'] = $this->__('Please agree to all the terms and conditions before placing the order.');
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
return;
}
}
$data = $this->getRequest()->getPost('payment', array());
if ($data) {
$data['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT
| Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY
| Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY
| Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX
| Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL;
$this->getOnepage()->getQuote()->getPayment()->importData($data);
}
$this->getOnepage()->saveOrder();
$redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
$result['success'] = true;
$result['error'] = false;
} catch (Mage_Payment_Model_Info_Exception $e) {
$message = $e->getMessage();
if (!empty($message)) {
$result['error_messages'] = $message;
}
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
} catch (Mage_Core_Exception $e) {
Mage::logException($e);
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
$result['success'] = false;
$result['error'] = true;
$result['error_messages'] = $e->getMessage();
$gotoSection = $this->getOnepage()->getCheckout()->getGotoSection();
if ($gotoSection) {
$result['goto_section'] = $gotoSection;
$this->getOnepage()->getCheckout()->setGotoSection(null);
}
$updateSection = $this->getOnepage()->getCheckout()->getUpdateSection();
if ($updateSection) {
if (isset($this->_sectionUpdateFunctions[$updateSection])) {
$updateSectionFunction = $this->_sectionUpdateFunctions[$updateSection];
$result['update_section'] = array(
'name' => $updateSection,
'html' => $this->$updateSectionFunction()
);
}
$this->getOnepage()->getCheckout()->setUpdateSection(null);
}
} catch (Exception $e) {
Mage::logException($e);
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
$result['success'] = false;
$result['error'] = true;
$result['error_messages'] = $this->__('There was an error processing your order. Please contact us or try again later.');
}
$this->getOnepage()->getQuote()->save();

Rickshaw.Graph.RangeSlider TypeError: $(element).slider is not a function

I have this error:
TypeError: $(element).slider is not a function
with the following script:
Rickshaw.namespace('Rickshaw.Graph.RangeSlider');
Rickshaw.Graph.RangeSlider = function(args) {
var element = this.element = args.element;
var graph = this.graph = args.graph;
$( function() {
$(element).slider( {
range: true,
min: graph.dataDomain()[0],
max: graph.dataDomain()[1],
values: [
graph.dataDomain()[0],
graph.dataDomain()[1]
],
slide: function( event, ui ) {
graph.window.xMin = ui.values[0];
graph.window.xMax = ui.values[1];
graph.update();
// if we're at an extreme, stick there
if (graph.dataDomain()[0] == ui.values[0]) {
graph.window.xMin = undefined;
}
if (graph.dataDomain()[1] == ui.values[1]) {
graph.window.xMax = undefined;
}
}
} );
} );
$(element)[0].style.width = graph.width + 'px';
graph.onUpdate( function() {
var values = $(element).slider('option', 'values');
$(element).slider('option', 'min', graph.dataDomain()[0]);
$(element).slider('option', 'max', graph.dataDomain()[1]);
if (graph.window.xMin == undefined) {
values[0] = graph.dataDomain()[0];
}
if (graph.window.xMax == undefined) {
values[1] = graph.dataDomain()[1];
}
$(element).slider('option', 'values', values);
} );
};
From the following page:
https://github.com/shutterstock/rickshaw/blob/master/src/js/Rickshaw.Graph.RangeSlider.js
The javascript debugger show me this line: slide: function( event, ui ) {
Can you show me a way to resolve my problem. Thanks you!
You should import jqueryui before using the slider.
http://jqueryui.com/slider/

Resources