Codeigniter Pagination highlights last link when current link is first - codeigniter-3

I got a strange problem, Codeigniter Pagination highlights last link when current link is first
$route['favorite/(:num)'] = 'user/favorite/$1';
$route['favorite/(:num)/page/(:num)'] = 'user/favorite/$1/$2';
$this->load->library('pagination');
$config['base_url'] = "/favorite/$user_fav_id/page";
$config['total_rows'] = $this->user_model->count_user_fav_all_movies($user_id, $user_fav_id);
$config['per_page'] = 3;
$config['use_page_numbers'] = true;
$config['first_link'] = 'в начало';
$config['last_link'] = 'в конец';
$config['next_link'] = '';
$config['prev_link'] = '';
$config['first_url'] = "/favorite/$user_fav_id";
$this->pagination->initialize($config);

You have to tell CI at what page you are currently at, by providing uri_segment :
$config['uri_segment'] = $this->uri->total_segments();
Or
$config['uri_segment'] = 4;

Related

Codeigniter mysql sum query

$this->db->select('SUM(status = In Stock)As In Stock,SUM(status = Allocated)AS Allocated,SUM(status = Decommission) as Decommission,SUM(status = In transit)AS In Transit');
// $this->db->from('assets');
$this->db->group_by("assettype,location");
$query = $this->db->get('assets');
Getting syntax error in the above query.
Kindly help
change
$this->db->select('SUM(status = "In Stock")As In_Stock,SUM(status = "Allocated")AS Allocated,SUM(status = "Decommission") as Decommission,SUM(status = "In transit")AS In_Transit');

How to search multi keywork in linq query

i have this code in homepage
CheckBox[] ch= new CheckBox[12];
ch[0] = ChkContextA;
ch[1]= ChkContextB;
ch[2]= ChkContextC;
ch[3]= ChkContextD;
ch[4]= ChkContextE;
ch[5]= ChkContextF;
ch[6]= ChkContextG;
ch[7]= ChkContextH;
ch[8]= ChkContextI;
ch[9]= ChkContextJ;
ch[10]= ChkContextK;
ch[11]= ChiContextL;
for (int i = 0; i < 11; i++)
if (ch[i].Checked) search += ch[i].Text + " ";
Response.Redirect("SearchEstate.aspx?content="+search);
and this code in SearchEstate
var content = Request.QueryString["content"];
RealEstateEntities db = new RealEstateEntities();
var query = from O in db.Owners
join E in db.Estates on O.OwnerID equals E.OwnerID
join P in db.Properties on E.PropertyID equals P.PropertyID
where P.Facilities.Contains(content)
select new
{
regdate = E.RegisterDate,
region = E.Region,
Estype = E.EstateType,
Fac = P.Facilities,
deal = P.DealType,
price = P.TotalCost,
img = E.Picture,
addrss = O.Address,
area = P.Area,
tel = P.TellNum,
bed = P.RoomNum,
park = P.ParikingNum
};
Repeater2.DataSource = query.OrderByDescending(x => x.regdate);
Repeater2.DataBind();
when user checked some checkbox "content" for example have this value:
SearchEstate.aspx?content=ContextB ContextE ContextJ
I Want search this values in Facility field in db
How can I do this? (Sorry for my bad English)
I have the feeling your are looking for something along the lines of this query:
var content = Request.QueryString["content"];
string[] contentArray = content.Split(' ');
//...
var query = //...
where P.Facilities.Any(f => contentArray.Contains(f.FacilityName))
//...
(or instead of FacilityName some other property of Facility)
But I am not sure.

Post to friends timeline using the feed dialog example c# api

I am trying to post something on my friend's timeline and I keep on getting an error every time i try to do it. the code i am using is below. i wonder if the code is correct? Cause it doesn't work for me. Can you help?
dynamic parameters = new ExpandoObject();
if (!string.IsNullOrEmpty(action.Post.PictureLocalSource))
{
var pictureTracking = GetNextPhotoFromFolder(action.Post.PictureLocalSource);
if (pictureTracking != null)
{
// action.Post.Picture = pictureTracking.FBPictureRef; // org
action.Post.Link = pictureTracking.FBPictureRef;
action.Post.Picture = pictureTracking.TrackingFileName;
parameters.type = "";
}
}
parameters.to = action.FacebookPostTargetID;
//parameters.Add("from", MyFacebookID);
parameters.message=action.Post.Message.Trim();
parameters.link = action.Post.Link;
parameters.picture = action.Post.Picture;
parameters.source = action.Post.Source;
parameters.name = action.Post.Name;
string caption = action.Post.Caption;
if (caption.Length > 200)
caption = caption.Substring(0, 200);
parameters.caption = caption.Trim(); // "Σχετικά με το asfame.gr";
parameters.description=action.Post.Description;
string feedtype = "";
if (action.Type == ActionType.Comments)
feedtype = "comments";
else
feedtype = "feed";
parameters.method = feedtype;
result = Client.Post(parameters);
Facebook has removed the ability to post on friends wall from 6th feb,2013. checkout the official doc here http://developers.facebook.com/roadmap/completed-changes/ under subsection Removing ability to post to friends walls via Graph API from February 6, 2013 changes. Hope it helps.

How to connect SSRS into ReportViewer 2010 at Runtime?

I have my codes as bellow and it shows me empty page after compiling:
ReportViewerControl = new ReportViewer();
ShowZoomControl="false"
ReportViewerControl.ServerReport.ReportServerUrl = new Uri(ReportServerUri);
ReportViewerControl.ServerReport.ReportPath = Model.Report.ReportPath;
ReportViewerControl.Visible = true;
ReportViewerControl.ShowReportBody = true;
ReportViewerControl.ShowParameterPrompts = false;
ReportViewerControl.ProcessingMode = ProcessingMode.Remote;
ReportViewerControl.ShowZoomControl = false;
ReportViewerControl.ShowBackButton = false;
ReportViewerControl.InteractivityPostBackMode = InteractivityPostBackMode.AlwaysAsynchronous;
ReportViewerControl.Height = 780;
ReportViewerControl.Width = 800;
IList<ReportParameter> FishSpeciesParameters = new List<ReportParameter>();
ReportParameter SPStatus = new ReportParameter();
SPStatus.Name = "SPStatus";
if (Model.Report.ID == 8)
SPStatus.Values.Add("T,E,C");
ReportParameter FishCode = new ReportParameter();
FishCode.Name = "FishCode";
FishCode.Values.Add("11");
FishSpeciesParameters.Add(SPStatus);
FishSpeciesParameters.Add(FishCode);
ReportViewerControl.ServerReport.SetParameters(FishSpeciesParameters);
ReportViewerControl.ServerReport.Refresh();
Any Ideas to view SSRS Report into ReportViewer on Fly?
maily you just need to set ServerReport.ReportServerUrl to something like this:
"http://localhost:8080/ReportServer"
and the ReportPath to
reportFolder + "/" + reportName;

zend router optimization

How can I optimize all of these routes into one. As we do in .htaccess file.
routes.addemails.type = "Zend_Controller_Router_Route_Regex"
routes.addemails.route = "campaign/email/add"
routes.addemails.defaults.module = campaignManagement
routes.addemails.defaults.controller = Email
routes.addemails.defaults.action = add
routes.updateEmail.type = "Zend_Controller_Router_Route_Regex"
routes.updateEmail.route = "campaign/email/edit/?([a-zA-Z0-9_-]+)?"
routes.updateEmail.defaults.module = campaignManagement
routes.updateEmail.defaults.controller = Email
routes.updateEmail.defaults.action = edit
routes.updateEmail.map.key = 1
routes.delEmail.type = "Zend_Controller_Router_Route_Regex"
routes.delEmail.route = "campaign/email/delete/?([a-zA-Z0-9_-]+)?"
routes.delEmail.defaults.module = campaignManagement
routes.delEmail.defaults.controller = Email
routes.delEmail.defaults.action = delete
routes.delEmail.map.id = 1
I've not set up a route using a config file, but at a glance try:
routes.emails.route = "campaign/email/(add|edit|delete)/?([a-zA-Z0-9_-]+)?"
routes.emails.map.action = 1
routes.emails.map.id = 2
I am assuming that the map.* are the variables in the url (so action is the first bit of regex, with id being the second bit of regex. Correct me if I'm wrong).