Wednesday, 27 June 2012

using mysql count makes me only return 1 row

take a look at this code

   $query_user="select count(id) as total,id,firstname,middlename,lastname,cb_addressline1,cb_addressline2,cb_addressline3,cb_addressline4,cb_postcode,cb_telephone from #__comprofiler where id LIKE'%$find%' or  firstname LIKE'%$find%' or lastname LIKE'%$find%' or cb_telephone LIKE'%$find%' or cb_addressline1 LIKE'%$find%' or cb_addressline2 LIKE'%$find%' or cb_addressline3 LIKE'%$find%' or cb_addressline4 LIKE'%$find%'";
                                 $db->setQuery($query_user);
                               
                                $listdata  = $db->loadObjectList();
                                 //print_r($listdata);
                                 if($listdata[0]->total==0)
                                         {



you'll notice that  'count(id) as total ' is being used to count the results .  However using count() in this way was makiing my results only return 1 row.   Take a look at this post http://stackoverflow.com/questions/4082713/mysql-returns-only-one-row-when-using-count 

So I've now replaced the query for

[code]

  $query_user="select id,firstname,middlename,lastname,cb_addressline1,cb_addressline2,cb_addressline3,cb_addressline4,cb_postcode,cb_telephone, (select count(*) FROM #__comprofiler WHERE id LIKE'%$find%' or  firstname LIKE'%$find%' or lastname LIKE'%$find%' or cb_telephone LIKE'%$find%' or cb_addressline1 LIKE'%$find%' or cb_addressline2 LIKE'%$find%' or cb_addressline3 LIKE'%$find%' or cb_addressline4 LIKE'%$find%') as total from #__comprofiler where id LIKE'%$find%' or  firstname LIKE'%$find%' or lastname LIKE'%$find%' or cb_telephone LIKE'%$find%' or cb_addressline1 LIKE'%$find%' or cb_addressline2 LIKE'%$find%' or cb_addressline3 LIKE'%$find%' or cb_addressline4 LIKE'%$find%'";
                               

[/code]

I then got an error with $listdata[0]->total==0 

after testing the object  $listdata   - as I noticed if the search was empty then I changed the line.

f($listdata[0]->total==0 ) 

to

if($listdata == NULL )


So we don't need to use SELECT count(*) as total - at all .  is it enough just to test the search to see if its NULL.



Which is much simplier

Add / Delete Fields for View Timesheet Section

This is my Joomla Payroll System once again.   To add you will need to set up the field in the Community Builder Component first.   And you will also need then to find out what field in mysql that has created.   I will write more on this when I need to add a field from scratch myself.

Here's the details on how to delete.

OPEN component/com_comprofiler/comprofiler.html.php

REMOVE

the table row for Resume entry

and REMOVED on line 884

$edit_resume=JRequest::getVar('edit_resume', '', 'POST');

AND REMOVE

cb_resume='$edit_resume',

FROM query1 on line 890

Monday, 25 June 2012

How to Change the Date Format in DatePicker on JQuery UI

I was scratching my head over the call to DatePicker Function in JQuery UI - to change the date format.

the call to the function was this

[code]$(function() {
   
        $( ".datepicker" ).datepicker();
       
    });[/code]




 Change to

[code]

    $(function() {

$( ".datepicker" ).datepicker({ dateFormat: 'dd/mm/yy' });    });


[/code]


Thursday, 21 June 2012

Joomla Payroll System - Changing the 'add timesheets' page to submit to it's own page.

The following was an update for Joomla Payroll System to make the 'add timesheet' form go back to its own page.

in components/com_projectfork/views/add_timesheet/view.html.php  

 this is the code that was editing out.

###############################



/*           
            $user_id = JRequest::getVar('staff_id', '', 'POST');
            $project_id = JRequest::getVar('venue_id', '', 'POST');
           $start_time = JRequest::getVar('start_time', '', 'POST');
            $end_time = JRequest::getVar('end_time', '', 'POST');
            $hourly_rate = JRequest::getVar('hourly_rate', '', 'POST');
            $invoice_rate = JRequest::getVar('invoice_rate', '', 'POST');
            $shift_time = JRequest::getVar('timelog', '', 'POST');
            $cdate = JRequest::getVar('cdate', '', 'POST');
            $shift_pd = JRequest::getVar('post_date_entry', '0', 'POST');
           
             $start_hours = JRequest::getVar('start_hours', '', 'POST');
             $start_minutes = JRequest::getVar('start_minutes', '', 'POST');
             $end_hours = JRequest::getVar('end_hours', '', 'POST');
             $end_minutes = JRequest::getVar('end_minutes', '', 'POST');
          
           $task_id = JRequest::getVar('task_id', '', 'POST');


            $this->assign('st_sel', $user_id);
            $this->assign('tsk_sel', $task_id);
            $this->assign('vn_sel', $project_id);
            $this->assign('start_time', $start_time);
            $this->assign('start_time', $start_time);
            $this->assign('hourly_rate', $hourly_rate);
            $this->assign('invoice_rate', $invoice_rate);
            $this->assign('timelog', $shift_time);
            $this->assign('cdate', $cdate);

            $this->assign('post_date_entry', $shift_pd);
            $this->assign('start_hours',$start_hours);
            $this->assign('start_minutes',$start_minutes);
            $this->assign('start_hours',$end_hours);
            $this->assign('start_minutes',$end_minutes);*/
          
########################

and replaced with

      $user_id = JRequest::getVar('staff_id', '', 'POST');
            $project_id = JRequest::getVar('venue_id', '', 'POST');
            $hourly_rate = JRequest::getVar('hourly_rate', '', 'POST');
            $invoice_rate = JRequest::getVar('invoice_rate', '', 'POST');
            $shift_time = JRequest::getVar('timelog', '', 'POST');
          $task_id = JRequest::getVar('task_id', '', 'POST');
       

            //$start_time = JRequest::getVar('start_time', '', 'POST').":00";
            //$end_time = JRequest::getVar('start_time', '', 'POST').":00";
            $shift_time_arr = explode(':',$shift_time);
            @$timelog = intval($shift_time_arr[0])*60 + intval($shift_time_arr[1]);
         //   $cdate = strtotime(JRequest::getVar('cdate', '', 'POST'));
             $cdate1 =  JRequest::getVar('cdate', '', 'POST') ;
            $cdate2 = str_replace("/","-",$cdate1);
             $cdate=strtotime($cdate2);
            $shift_pd = JRequest::getVar('post_date_entry', '0', 'POST');
            $shift_pd = ($shift_pd=='on')?1:0;
           
           
           
             $start_hours = JRequest::getVar('start_hours', '', 'POST');
             $start_minutes = JRequest::getVar('start_minutes', '', 'POST');
              $end_hours = JRequest::getVar('end_hours', '', 'POST');
             $end_minutes = JRequest::getVar('end_minutes', '', 'POST');
          
              $start_time=$start_hours.":".$start_minutes;
              $end_time=$end_hours.":".$end_minutes;
             if($user_id && $project_id && $hourly_rate && $invoice_rate && $cdate){
               
                $db = & JFactory::getDBO();
                $query = "INSERT INTO #__pf_time_tracking (`task_id`, `project_id`, `user_id`, `content`, `cdate`, `timelog`, `hourly_rate`, `invoice_rate`, `post_date_entry`,`start_time`,`end_time`)"
                              ." VALUES ($task_id, $project_id, $user_id, '', $cdate, $timelog, $hourly_rate, $invoice_rate, $shift_pd,'".$start_time."','".$end_time."')";
                $db->setQuery($query);
                $db->query();
                $id = $db->insertid();

                if(!$id) {
                    $this->AddError($db->getErrorMsg());
                    return false;
                }
                else
                {
                     echo   "Thank you for entering a Timesheet Feel free to add more. ";
                 $this->assign('st_sel', 0);
            $this->assign('tsk_sel', 0);
            $this->assign('vn_sel', 0);
            $this->assign('hourly_rate', '0.00');
            $this->assign('invoice_rate', '0.00');
           
                   
            $this->assign('cdate',date("d/m/Y"));
           
           
           // $this->assign('cdate', 'DD-MM-YYYY');
            //$this->assign('timelog', 'HH:MM');
            $this->assign('start_time', 'HH:MM');
            $this->assign('end_time', 'HH:MM');
            $this->assign('start_hours', '00');
            $this->assign('start_minutes', '00');
            $this->assign('end_hours', '00');
            $this->assign('end_minutes', '00');
             
                }
                   
                    // $mainframe->redirect('index.php?option=com_projectfork&view=timesheets');
       
            // $mainframe = &JFactory::getApplication();
             //  $mainframe->redirect('index.php?option=com_projectfork&view=add_timesheet&Itemid=555');
           
            }
           
           
           
            






Joomla 1.5 Register message - 'in order to use Cookie Consent

I've installed 'Cookie Consent' on a Joomla 1.5 installation and am getting this message when a user clicks on register.

Developer: Caution! In order to use Cookie Consent, you need to use jQuery 1.4.4 or higher.

I found the solution was to install this component

JQuery Easy

Infact I've also got JQuery issues on other parts of my websites, so will try this plugin there also as it may be a fix for other Joomla issues I'm having.


Wednesday, 20 June 2012

Transferring over a Domain Name to your Heart Internet Dedicated server.

I've written these Heart help files as in my circumstance the order of which things need to be done is different.  As I buy my domains through another provider, which means my domain will not be on the manage>express dns list.

 From your Heart Internet Customer Area, go to 'Manage>Dedicated Servers' from the right-hand menu.
- Scroll down to 'Domain References for Dedicated Servers'.
- Enter your domain into the text field and hit 'Create Reference', do not include any subdomains (e.g. www/ftp/mail).


.....


- From your Heart Internet Customer Area, go to 'Manage>Dedicated Servers' from the right-hand menu.
- Scroll down to 'Express DNS for Dedicated Servers'.
- Select your dedicated server from the drop-down list.
- Select your domain from the second drop-down list.
- Click 'Set DNS'.
- This will automatically point the domain at the primary IP address of your dedicated server, the following services are included (www, ftp, *, @), mail is excluded.
- More granular controls are also available, look for the text: 'The following DNS settings will be created for yourdomain.com , please click here for more advanced settings.'



Checking Products and Google Shopping Performance

I'll shortly be writing a piece on comparing some stores which are doing well and others that are struggling for sales,  WHY?

anyway this isn't that blog, just some notes on the Womens Clothing store that I do some work for. 

Inga Blouse
__________


https://www.google.co.uk/search?source=ig&hl=en&rlz=&=&q=Inga+Blouse#q=Inga+Blouse&hl=en&prmd=imvns&source=lnms&tbm=shop&sa=X&ei=xJLhT-idIYjh8AOM4tHxAw&ved=0CEsQ_AUoBQ&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=3d2c054e028a098b&biw=1347&bih=657

£14 more expensive - however different style

Thilda Coat
___________

https://www.google.co.uk/search?source=ig&hl=en&rlz=&=&q=thilda+coat#q=thilda+coat&hl=en&prmd=imvns&source=lnms&tbm=shop&sa=X&ei=o5PhT_m0FsiI8gPqyuj-Aw&ved=0CE0Q_AUoBQ&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=3d2c054e028a098b&biw=1347&bih=657

only jacket there - picture could be better.


NYDJ Petite Modern Straight Jean
_______________________

https://www.google.co.uk/search?source=ig&hl=en&rlz=&=&q=NYDJ+Petite+Modern+Straight+Jean#q=NYDJ+Petite+Modern+Straight+Jean&hl=en&prmd=imvns&source=lnms&tbm=shop&sa=X&ei=WZThT4mHFM_e8QPapuGYBA&ved=0CHMQ_AUoBQ&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=3d2c054e028a098b&biw=1347&bih=657

Camille Flannel Tab Skirt
_______________________

https://www.google.co.uk/search?source=ig&hl=en&rlz=&=&q=back+to+basic+top#hl=en&gs_nf=1&ds=sh&pq=back%20to%20basic%20top&cp=25&gs_id=y&xhr=t&q=Camille%20Flannel%20Tab%20Skirt&pf=p&tbm=shop&sclient=psy-ab&oq=Camille+Flannel+Tab+Skirt&aq=f&aqi=&aql=&gs_l=&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=3d2c054e028a098b&biw=1359&bih=657

Hadas Tunic
_______________

https://www.google.co.uk/search?source=ig&hl=en&rlz=&=&q=Hadas+Tunic#q=Hadas+Tunic&hl=en&prmd=imvns&source=lnms&tbm=shop&sa=X&ei=4ZXhT4DhH8eV8QO-wqHuAw&ved=0CEoQ_AUoBQ&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=3d2c054e028a098b&biw=1359&bih=657