Jump to content

Andy2024

Members
  • Posts

    25
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Andy2024's Achievements

Member

Member (2/5)

0

Reputation

4

Community Answers

  1. I've downloaded the latest release of PhpMailer and all is fine now
  2. PhpMailer is not sending html emails even with isHTML set to true $mail->Body = $message; $mail->isHTML(true); $mail->isHTML = true; if(!$mail->Send()) { return $mail->ErrorInfo; } Here is the html message <!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Site Title</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> I've tried to find a solution by searching but all everyone is saying is add $mail->isHTML(true); or $mail->isHTML = true; i have commented each out individually but still doesn't send html emails Any help at all would be much appreciated
  3. I've managed to sort it and it works perfectly. I've also put it into a class, here is code if anyone wants to use it. Thank you for all your help! class Calendar { public static function bookedArray($strDateFrom,$strDateTo) { $aryRange = []; $iDateFrom = strtotime($strDateFrom); $iDateTo = strtotime($strDateTo); if ($iDateTo >= $iDateFrom) { array_push($aryRange, date('Y-m-d', $iDateFrom)); // first entry while ($iDateFrom<$iDateTo) { $iDateFrom += 86400; // add 24 hours array_push($aryRange, date('Y-m-d', $iDateFrom)); } } return $aryRange; } public static function flattenCalendar($array) { $flatArray = []; array_walk_recursive($array, function($value) use (&$flatArray) { $flatArray[] = $value; }); return $flatArray; } public static function estimatePrice($checkin, $checkout, $stdArray, $specArray) { $requestDates = self::bookedArray($checkin, $checkout); $specialRate = array(); $standardRate = array(); $cost = array(); //return var_dump($requestDates); if(!empty($stdArray)) { foreach($stdArray as $row) { if($row->SeasonName == 'Standard Weekday') { $standardRate['Weekday'] = $row->SeasonPrice; } if($row->SeasonName == 'Standard Weekend') { $standardRate['Weekend'] = $row->SeasonPrice; } } } if(!empty($specArray)) { $i = 0; foreach($specArray as $row) { $specialRate[$i]['start'] = $row->SeasonStart; $specialRate[$i]['end'] = $row->SeasonEnd; $specialRate[$i]['price'] = $row->SeasonPrice; $i++; } } $specialCount = count($specialRate); $standardCount = count($stdArray); $flatRequest = self::flattenCalendar($requestDates); // Reqested Dated into One Array $cost = array(); $specialCost = array(); $days = count($flatRequest); foreach($flatRequest as $key => $val) { $specialDays = 0; for($i=0; $i<count($specialRate); $i++) { $range = self::bookedArray($specialRate[$i]['start'], $specialRate[$i]['end']); array_pop($range); if(in_array($val, $range)) { array_push($specialCost, $specialRate[$i]['price']); $specialDays++; unset($flatRequest[$key]); } } } array_pop($flatRequest); foreach($flatRequest as $key => $val) { if( date('l', strtotime($val)) == 'Saturday' || date('l', strtotime($val)) == 'Sunday' ) { array_push($cost, $standardRate['Weekend']); } else { array_push($cost, $standardRate['Weekday']); } } if(!empty($cost) && !empty($specialCost)) { return array_sum(array_merge($cost, $specialCost)); } elseif(!empty($specialCost) && empty($cost)) { array_pop($specialCost); return array_sum($specialCost); } else { return array_sum($cost); } } }
  4. So far this is what code I have if(!empty($standardRates)) { foreach($standardRates as $row) { if($row->SeasonName == 'Standard Weekday') { $standardRate['Weekday'] = $row->SeasonPrice; } if($row->SeasonName == 'Standard Weekend') { $standardRate['Weekend'] = $row->SeasonPrice; } } } if(!empty($setPrices)) { $i = 0; foreach($setPrices as $row) { $specialRate[$i]['start'] = $row->SeasonStart; $specialRate[$i]['end'] = $row->SeasonEnd; $specialRate[$i]['price'] = $row->SeasonPrice; $i++; } } $cost = array(); foreach($flatRequest as $key => $val) { for($i=0; $i<count($specialRate); $i++) { if(in_array($val, Cal::bookedArray($specialRate[$i]['start'], $specialRate[$i]['end']))) { array_push($cost, $specialRate[$i]['price']); } } if(empty($specialRate)) { if(date('l', strtotime($val)) == 'Saturday' || date('l', strtotime($val)) == 'Sunday') { array_push($cost, $standardRate['Weekend']); } else { array_push($cost, $standardRate['Weekday']); } } } This doesn't work though, $cost is empty
  5. I'll just put what i am trying to achieve instead of the code i am using I have 2 arrays with stored days and prices # Standard Days Array ( [0] => stdClass Object ( [name] => Standard Weekday [price] => 60 ) [1] => stdClass Object ( [name] => Standard Weekend [price] => 80 ) ) # Special Days Array ( [0] => Array ( [start] => 2025-02-21 [end] => 2025-03-03 [price] => 100 ) [1] => Array ( [start] => 2025-04-11 [end] => 2025-04-27 [price] => 100 ) [2] => Array ( [start] => 2025-05-02 [end] => 2025-05-05 [price] => 110 ) [3] => Array ( [start] => 2025-05-23 [end] => 2025-06-01 [price] => 110 ) [4] => Array ( [start] => 2025-07-18 [end] => 2025-09-01 [price] => 120 ) [5] => Array ( [start] => 2025-10-24 [end] => 2025-11-02 [price] => 110 ) [6] => Array ( [start] => 2025-12-19 [end] => 2026-01-04 [price] => 120 ) ) I want to get the prices from those arrays for each day from the selected dates, so from 1st May 2025 to 8th May 2025 would look like this # Selected Days Array ( [0] => 2025-05-01 [1] => 2025-05-02 [2] => 2025-05-03 [3] => 2025-05-04 [4] => 2025-05-05 [5] => 2025-05-06 [6] => 2025-05-07 [7] => 2025-05-08 ) so for each of the Selected Days if the date is not in the Special Days array it will give me the price of the standard weekday or weekend, If it is in the special date it will give me that instead. Because there are no special dates in the selected days it would calculate (5x60)+(2x80) so give a total of 460. Its when there is special dates where i am having the issue, how can i check each selected day in the special days array and get the price for that array
  6. I am trying to get values from an array with a date range This is the var_dump assuming from date is 06 May 2025 and to date is 22 May 2025 [0]=> string(10) "2025-05-06" [1]=> string(10) "2025-05-07" [2]=> string(10) "2025-05-08" [3]=> string(10) "2025-05-09" [4]=> string(10) "2025-05-10" [5]=> string(10) "2025-05-11" [6]=> string(10) "2025-05-12" [7]=> string(10) "2025-05-13" [8]=> string(10) "2025-05-14" [9]=> string(10) "2025-05-15" [10]=> string(10) "2025-05-16" [11]=> string(10) "2025-05-17" [12]=> string(10) "2025-05-18" [13]=> string(10) "2025-05-19" [14]=> string(10) "2025-05-20" [15]=> string(10) "2025-05-21" [16]=> string(10) "2025-05-22" It then searches the following array $count = 0; foreach($seasonPrices as $row) { $price[$count]['name'] = $row->SeasonName; $price[$count]['days'] = implode(',', Cal::bookedArray($row->SeasonStart, $row->SeasonEnd)); $price[$count]['price'] = $row->SeasonPrice; $count++; } unset($count); [2]=> array(3) { ["name"]=> string(16) "Spring half-term" ["days"]=> string(120) "2025-02-21,2025-02-22,2025-02-23,2025-02-24,2025-02-25,2025-02-26,2025-02-27,2025-02-28,2025-03-01,2025-03-02,2025-03-03" ["price"]=> string(3) "100" } [3]=> array(3) { ["name"]=> string(6) "Easter" ["days"]=> string(186) "2025-04-11,2025-04-12,2025-04-13,2025-04-14,2025-04-15,2025-04-16,2025-04-17,2025-04-18,2025-04-19,2025-04-20,2025-04-21,2025-04-22,2025-04-23,2025-04-24,2025-04-25,2025-04-26,2025-04-27" ["price"]=> string(3) "100" } [4]=> array(3) { ["name"]=> string(7) "May Day" ["days"]=> string(43) "2025-05-02,2025-05-03,2025-05-04,2025-05-05" ["price"]=> string(3) "110" } [5]=> array(3) { ["name"]=> string(16) "Summer half-term" ["days"]=> string(109) "2025-05-23,2025-05-24,2025-05-25,2025-05-26,2025-05-27,2025-05-28,2025-05-29,2025-05-30,2025-05-31,2025-06-01" ["price"]=> string(3) "110" } [6]=> array(3) { ["name"]=> string(6) "Summer" ["days"]=> string(505) "2025-07-18,2025-07-19,2025-07-20,2025-07-21,2025-07-22,2025-07-23,2025-07-24,2025-07-25,2025-07-26,2025-07-27,2025-07-28,2025-07-29,2025-07-30,2025-07-31,2025-08-01,2025-08-02,2025-08-03,2025-08-04,2025-08-05,2025-08-06,2025-08-07,2025-08-08,2025-08-09,2025-08-10,2025-08-11,2025-08-12,2025-08-13,2025-08-14,2025-08-15,2025-08-16,2025-08-17,2025-08-18,2025-08-19,2025-08-20,2025-08-21,2025-08-22,2025-08-23,2025-08-24,2025-08-25,2025-08-26,2025-08-27,2025-08-28,2025-08-29,2025-08-30,2025-08-31,2025-09-01" ["price"]=> string(3) "120" } [7]=> array(3) { ["name"]=> string(16) "Autumn half-term" ["days"]=> string(120) "2025-10-24,2025-10-25,2025-10-26,2025-10-26,2025-10-27,2025-10-28,2025-10-29,2025-10-30,2025-10-31,2025-11-01,2025-11-02" ["price"]=> string(3) "110" } [8]=> array(3) { ["name"]=> string(10) "Christmas " ["days"]=> string(186) "2025-12-19,2025-12-20,2025-12-21,2025-12-22,2025-12-23,2025-12-24,2025-12-25,2025-12-26,2025-12-27,2025-12-28,2025-12-29,2025-12-30,2025-12-31,2026-01-01,2026-01-02,2026-01-03,2026-01-04" ["price"]=> string(3) "120" } [9]=> array(3) { ["name"]=> string(16) "Spring half-term" ["days"]=> string(109) "2026-02-20,2026-02-21,2026-02-22,2026-02-23,2026-02-24,2026-02-25,2026-02-26,2026-02-27,2026-02-28,2026-03-01" ["price"]=> string(3) "100" } [10]=> array(3) { ["name"]=> string(6) "Easter" ["days"]=> string(197) "2026-04-02,2026-04-03,2026-04-04,2026-04-05,2026-04-06,2026-04-07,2026-04-08,2026-04-09,2026-04-10,2026-04-11,2026-04-12,2026-04-13,2026-04-14,2026-04-15,2026-04-16,2026-04-17,2026-04-18,2026-04-19" ["price"]=> string(3) "100" } [11]=> array(3) { ["name"]=> string(7) "May Day" ["days"]=> string(43) "2026-05-01,2026-05-02,2026-05-03,2026-05-04" ["price"]=> string(3) "110" } [12]=> array(3) { ["name"]=> string(16) "Summer half-term" ["days"]=> string(109) "2026-05-22,2026-05-23,2026-05-24,2026-05-25,2026-05-26,2026-05-27,2026-05-28,2026-05-29,2026-05-30,2026-05-31" ["price"]=> string(3) "110" } [13]=> array(3) { ["name"]=> string(6) "Summer" ["days"]=> string(516) "2026-07-17,2026-07-18,2026-07-19,2026-07-20,2026-07-21,2026-07-22,2026-07-23,2026-07-24,2026-07-25,2026-07-26,2026-07-27,2026-07-28,2026-07-29,2026-07-30,2026-07-31,2026-08-01,2026-08-02,2026-08-03,2026-08-04,2026-08-05,2026-08-06,2026-08-07,2026-08-08,2026-08-09,2026-08-10,2026-08-11,2026-08-12,2026-08-13,2026-08-14,2026-08-15,2026-08-16,2026-08-17,2026-08-18,2026-08-19,2026-08-20,2026-08-21,2026-08-22,2026-08-23,2026-08-24,2026-08-25,2026-08-26,2026-08-27,2026-08-28,2026-08-29,2026-08-30,2026-08-31,2026-09-01" ["price"]=> string(3) "120" } [14]=> array(3) { ["name"]=> string(16) "Autumn half-term" ["days"]=> string(120) "2026-10-23,2026-10-24,2026-10-25,2026-10-25,2026-10-26,2026-10-27,2026-10-28,2026-10-29,2026-10-30,2026-10-31,2026-11-01" ["price"]=> string(3) "110" } [15]=> array(3) { ["name"]=> string(10) "Christmas " ["days"]=> string(186) "2026-12-18,2026-12-19,2026-12-20,2026-12-21,2026-12-22,2026-12-23,2026-12-24,2026-12-25,2026-12-26,2026-12-27,2026-12-28,2026-12-29,2026-12-30,2026-12-31,2027-01-01,2027-01-02,2027-01-03" ["price"]=> string(3) "120" } If the requested dates are present in the price array i then need to extract the price for each day to put into an array to calculate the total cost if(in_array($rested, $prices) { array_push($cost, $prices[]['price']; } echo array_sum($cost); I have tried for loops, for each loops, array_diff, array_intersect and anything else i could think of put cant get it to work properly. Any help would me much appreciated The code i have put isnt the exact code i have now as i have been trying all day and its changed every time i've tried something else. The code i have right now only adds 2 prices to the cost array even though there more than 2 dates in the requested dates Please Help!! Thanks in advance
  7. I managed to sort it, my question was a bit misleading. I had a calendar that was only showing 1 booked date range but that was because i had used = instead of == so now it shows all bookings
  8. I'm Trying to create a booking/availability calendar that shows a full 12 months bookings/availability. I have come up with the following so far $publicHolidays = array(date('j-n-Y', strtotime('1st January 2025')), date('j-n-Y', strtotime('18th April 2025')), date('j-n-Y', strtotime('21st April 2025')), date('j-n-Y', strtotime('5th May 2025')), date('j-n-Y', strtotime('26th May 2025')), date('j-n-Y', strtotime('25th August 2025')), date('j-n-Y', strtotime('25th December 2025')), date('j-n-Y', strtotime('26th December 2025'))); $bookings = array(array('Check-In' => '1-1-2025', 'Check-Out' => '7-1-2025'), array('Check-In' => '3-2-2025', 'Check-Out' => '13-2-2025'), array('Check-In' => '2-3-2025', 'Check-Out' => '25-3-2025'), array('Check-In' => '2-4-2025', 'Check-Out' => '21-4-2025'), array('Check-In' => '6-6-2025', 'Check-Out' => '9-6-2025'), array('Check-In' => '2-9-2025', 'Check-Out' => '5-9-2025'), array('Check-In' => '3-11-2025', 'Check-Out' => '30-11-2025')); foreach($bookings as $row) { $res[] = Cal::bookedArray($row['Check-In'],$row['Check-Out']); } $booked = Cal::bookedArray('1-4-2025','7-4-2025'); $month = '1'; $year = date('Y'); for($m=$month;$m<13;$m++) { $timestamp = mktime(0, 0, 0, $m, 1, $year); $daysInMonth = date("t", $timestamp); $firstDay = date("N", $timestamp); if($m == date('m')) { $featured =' featured'; } else { $featured=''; } ?> <div class="col-xl-4 col-lg-6" data-aos="fade-up" data-aos-delay="100"> <div class="pricing-item p-0<?php echo $featured;?>"> <h3 class="mb-0 pt-5"><?php echo date('F', mktime(0,0,0,$m)); ?></h3> <table class="table table-bordered m-0"> <tr> <th>Mon</th> <th>Tue</th> <th>Wed</th> <th>Thu</th> <th>Fri</th> <th>Sat</th> <th>Sun</th> </tr> <?php $dayCount = 1; ?> <tr> <?php for ($i = 1; $i <= 7; $i++) { $date = "$dayCount-$m-$year"; if ($i < $firstDay) { echo "<td></td>"; } else { $date = "$dayCount-$m-$year"; if(date('l', strtotime($date)) == 'Saturday' && !in_array($date, $booked)) { $cellBg="class='table-info'"; } elseif(date('l', strtotime($date)) == 'Sunday' && !in_array($date, $booked)) { $cellBg="class='table-info'"; } elseif(in_array($date, $publicHolidays) && !in_array($date, $booked)) { $cellBg="class='table-warning'"; } else { $cellBg="class='table-light'"; } foreach($res as $key => $val) { /* $firstday = reset($val); $lastday = end($val); if($date = $firstday) { $cellBg="class='table-primary'"; } elseif(in_array($date, array_splice($val,1,-1))) { $cellBg="class='table-danger'"; } elseif($date = $lastday) { $cellBg="class='table-primary'"; } */ if(in_array($date, array_splice($val,1,-1))) { $cellBg="class='table-danger'"; } } echo "<td $cellBg>$dayCount</td>"; $dayCount++; } } echo "</tr>"; while ($dayCount <= $daysInMonth) { echo "<tr>"; for ($i = 1; $i <= 7 && $dayCount <= $daysInMonth; $i++) { $date = "$dayCount-$m-$year"; if(date('l', strtotime($date)) == 'Saturday' && !in_array($date, $booked)) { $cellBg="class='table-info'"; } elseif(date('l', strtotime($date)) == 'Sunday' && !in_array($date, $booked)) { $cellBg="class='table-info'"; } elseif(in_array($date, $publicHolidays) && !in_array($date, $booked)) { $cellBg="class='table-warning'"; } else { $cellBg="class='table-light'"; } foreach($res as $key => $val) { /* $firstday = reset($val); $lastday = end($val); if($date = $firstday) { $cellBg="class='table-primary'"; } elseif(in_array($date, array_splice($val,1,-1))) { $cellBg="class='table-danger'"; } elseif($date = $lastday) { $cellBg="class='table-primary'"; } */ if(in_array($date, array_splice($val,1,-1))) { $cellBg="class='table-danger'"; } } echo "<td $cellBg>$dayCount</td>"; $dayCount++; } ?> </tr> <?php } ?> </table> </div> </div> <?php } Its reading the arrays, drawing the calendar and colorizing the weekends, public holidays and bookings. What i need is to change the check-in and check-out date color to reflect what they are. I've commented out what ive been trying but it isnt working. here is the bookedarray function if anyone needs it public static function bookedArray($strDateFrom,$strDateTo) { $aryRange = []; $iDateFrom = strtotime($strDateFrom); $iDateTo = strtotime($strDateTo); if ($iDateTo >= $iDateFrom) { array_push($aryRange, date('j-n-Y', $iDateFrom)); // first entry while ($iDateFrom<$iDateTo) { $iDateFrom += 86400; // add 24 hours array_push($aryRange, date('j-n-Y', $iDateFrom)); } } return $aryRange; } Any help would be much appreciated or even a pointer as to were I could find a solution Thanks in advance
  9. Bit of a breakthrough I've altered the PHP to if(!empty($data['legend'])) { foreach($data['legend'] as $r1) { if(isset($r1->Name)) { $sales = $this->_query->get_sales_count($r1->IdService); if(!empty($sales)) { foreach($sales as $r2) { $count[$r1->Name][] = $r2->Sales; } $legend[] = array('label' => $r1->Name, 'backgroundColor' => $r1->GraphColor, 'data' => implode(',',$count[$r1->Name])); } } } } and that has given me [{"label":"Installation","backgroundColor":"#2bca2d","data":"8,19,11,3,49"},{"label":"Repair","backgroundColor":"#cfca3a","data":"1,3,7"}] which looks ok until its placed in the char then it adds everything to the wrong month and only 1 item per month
  10. I tried that but still gives the same results
  11. I have had to go about it a totally different way because I need figures for each job type so have got this "SELECT ".PREFIX."tservices.IdService, ".PREFIX."tservices.Name, ".PREFIX."tservices.GraphColor, ".PREFIX."tprojects.Service, COUNT(".PREFIX."tprojects.IdProject) as Sales, ".PREFIX."tprojects.Finish FROM ".PREFIX."tservices LEFT JOIN ".PREFIX."tprojects ON ".PREFIX."tservices.IdService = ".PREFIX."tprojects.Service WHERE ".PREFIX."tservices.InGraph = '1' GROUP BY MONTH(".PREFIX."tprojects.Finish), YEAR(".PREFIX."tprojects.Finish) ORDER BY ".PREFIX."tprojects.Finish DESC LIMIT 0, 12" Then the PHP is if(!empty($data['legend'])) { foreach($data['legend'] as $r1) { if(isset($r1->Name)) { $sales = $this->_query->get_sales_count($r1->IdService); if(!empty($sales)) { foreach($sales as $r2) { $count[] = $r2->Sales; } $legend[] = array('label' => $r1->Name, 'backgroundColor' => $r1->GraphColor, 'data' => implode(',',$count)); } } } } But the json its outputting [{"label":"Installation","backgroundColor":"#2bca2d","data":"8,19,11,3,49"},{"label":"Repair","backgroundColor":"#cfca3a","data":"8,19,11,3,49,1,3,7"}] instead of [{"label":"Installation","backgroundColor":"#2bca2d","data":"8,19,11,3,49"},{"label":"Repair","backgroundColor":"#cfca3a","data":"1,3,7"}] Does anyone have any idea how to solve this? Thanks in advance
  12. Sorted thanks I ended up putting if(!empty($counts->Counter) && !empty($counts->Month)) { array_push($sales, array('Count' => $counts->Counter, 'Month' => $counts->Month)); } At least its giving the correct count
  13. Found an issue, i haven't converted the datetime string to sql datetime somewhere
  14. i think it may be returning them on different rows in the array [0]=> array(2) { ["Count"]=> int(61) ["Month"]=> NULL } [1]=> array(2) { ["Count"]=> int(5) ["Month"]=> int(5) } } [0]is returning the count and [1] is returning the month (5) May!
  15. Their are a total of 69 rows in table ".PREFIX."tprojects as per phpmyadmin
×
×
  • 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.