Jump to content

Help with Editing car rental script.


mav910623

Recommended Posts

Hi guys. I have this Car Rental Script and would like to change so price issues. The thing is the system chargers extra hours of rental by calculating the daily price divided against 24. This creates uneven numbers when proceeding to checkout phase. I would like to change the script to give a fixed price of 20 but it is not working. Mind you look at the .php file and help me out . Here iss a snippet of the code.

 

// looks up each day, works out the price and calclates the total, slow because if 7 days are chosen then this loop and query runs 7 times, but the only way to do this so that each day rate is calculated.

for ($counter = $starttime[0]+1; $counter <= $numberofHours; $counter += 1) {

 

$value = date("Y-m-d", mktime($startdateArray["hours"] + $counter,$startdateArray["minutes"],$startdateArray["seconds"],$startdateArray["mon"],$startdateArray["mday"],$startdateArray["year"]));

 

$sql="SELECT * FROM #__carman_prices WHERE uid='".$uid."' AND ('".$value."' BETWEEN startdate AND enddate)";

 

$database->setQuery($sql);

$rows = $database->loadObjectList();

$hourlyprice=$rows[0]->dayprice/24;

$total = $total + $hourlyprice;

}

} else {

// this puts each day in the date range into and array...

$date_array = carman_Calendar::date_range($sdateArray[0],$fdateArray[0]);

 

foreach ($date_array as $value) {

$sql="SELECT * FROM #__carman_prices WHERE uid='".$uid."' AND ('".$value."' BETWEEN startdate AND enddate)";

$database->setQuery($sql);

$rows = $database->loadObjectList();

$weekprice=$rows[0]->price;

//$dailyprice=$rows[0]->dayprice;

$weeklydayprice=$weekprice/7;

//$dailytotal = $dailytotal+$dailyprice;

$total = $total+$weeklydayprice;

}

}

Link to comment
Share on other sites

Try floor() with your division and % (modular division) - not sure this is what you want but I'm not sure I entirely understand your question.

 

$hourlyprice=floor($rows[0]->dayprice/24);
$hourlyprice2=$rows[0]->dayprice%24;

 

Using / will give you floating (aka decimal) results using floor() will round it down to the nearest integer. The modular part (%) will give you the remainder.

 

You can always ECHO the values out to see if they're what you should be using.

Link to comment
Share on other sites

Thanks For the quick reply  :D urm, what i would actually like to do is set the code to charge an additional $20 for every hour rather than just calculate the actual cost or renting the said car for an extra hour u get what i mean?

 

Example:

 

Car A cost $24 a day, with the current script it would charge an extra $1 for each extra hour. like the script says dayprice/24

 

What i want is for the script to charge $20 as a flat rate no matter how much the rental of said car is per day..

 

Hope you guys get it this time... :D if u need the entire script just let me know maybe something else is affecting it.. cheers

 

 

Link to comment
Share on other sites

I'll do my best to answer but someone here is playing very fast trance very loud in the office and I can't hear myself think!

 

Have you got the number of hours the car has been rented out?

 

Can't you just multiply that by 20 and add that to the amount?

Link to comment
Share on other sites

I really am unsure about the code structure as i was not the one who wrote it.. Im just editting. All i vae done is added

 

$flatrate = $numberofHours * 20;

$total = $total + $flatrate;

 

and it stopped working as soon as i revert it back to original it worked.. there was no other modification done...

Link to comment
Share on other sites

So do we have various cars with different rates depending on what they are and you want all cars to be charged at a flat rate of $20 per day?

 

If I still don't have it - a look at all the source would probably be handy in this case.

Link to comment
Share on other sites

So do we have various cars with different rates depending on what they are and you want all cars to be charged at a flat rate of $20 per day?

 

If I still don't have it - a look at all the source would probably be handy in this case.

 

Yup that almost rite.. i would like to charge a flat rate of $20 per additional hour the car is booked. i just don't have the source that's the problem... you mid going over the php file for me ? h

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.