
Andy2024
Members-
Posts
17 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
Andy2024's Achievements
-
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
-
I tried that but still gives the same results
-
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
-
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
-
Found an issue, i haven't converted the datetime string to sql datetime somewhere
-
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!
-
Their are a total of 69 rows in table ".PREFIX."tprojects as per phpmyadmin
-
That is the issue because this also give the same result public function get_sales_count($id) { return $this->db->select("SELECT COUNT(".PREFIX."tprojects.IdProject) as Sales, MONTH(".PREFIX."tprojects.Start) AS Month FROM ".PREFIX."tprojects WHERE ".PREFIX."tprojects.IsActive = '1' AND ".PREFIX."tprojects.Service = '$id' GROUP BY MONTH(".PREFIX."tprojects.Start), YEAR(".PREFIX."tprojects.Start)"); } array(2) { [0]=> array(2) { ["Count"]=> int(61) ["Month"]=> NULL } [1]=> array(2) { ["Count"]=> int(5) ["Month"]=> int(5) } } I cannot understand where thus is coming from either because all entries are may 2024
-
I'm trying to get sales counts by month but having issues. Here is the dump array(2) { [0]=> object(stdClass)#80 (2) { ["Counter"]=> int(61) ["Month"]=> NULL } [1]=> object(stdClass)#81 (2) { ["Counter"]=> int(5) ["Month"]=> int(5) } } how would i get { ["Counter"]=> int(61) ["Month"]=> int(5) } Here is the code i am using MySQL public function get_sales_list() { return $this->db->select("SELECT * FROM ".PREFIX."tservices WHERE InGraph = '1'"); } public function get_sales_count($id) { return $this->db->select("SELECT COUNT(".PREFIX."tprojects.IdProject) as Sales FROM ".PREFIX."tprojects WHERE ".PREFIX."tprojects.IsActive = '1' AND ".PREFIX."tprojects.Service = '$id' GROUP BY MONTH(".PREFIX."tprojects.Start), YEAR(".PREFIX."tprojects.Start)"); } PHP $servGraph = $this->_query->get_sales_list(); if(isset($servGraph)) { $sales = array(); foreach($servGraph as $row) { $count = $this->_query->annual_sales($row->IdService); foreach($count as $key => $val) { array_push($sales, $val); } } } $data['sales-list'] = $sales; var_dump($data['sales-list']); Thanks in advance for any help or suggections
-
Ive modified the Simple PHP Shopping Cart from the phppot site but for some reason when the cart reaches 19 items it wont add anything else to it and i dont know why. Is their a limit within php how long a session array can be? Here is the code that adds each item to the array $cartItems = Session::get("cart_item"); $itemArray = array( 'ItemDesc' => $_POST["ItemDesc"], 'ItemCode' => $_POST["ItemCode"], 'ItemQty' => $_POST["ItemQty"], 'ItemAmount' => $_POST["ItemAmount"], 'ItemTotalAmount' => ($_POST["ItemQty"] * $_POST["ItemAmount"]), 'IdSupplier' => $_POST["IdSupplier"]); if(!empty($cartItems)) { if(in_array($itemArray["ItemCode"],array_keys($cartItems))) { foreach($cartItems as $k => $v) { if($itemArray["ItemCode"] == $k) { if(empty($cartItems[$k]["ItemQty"])) { $cartItems[$k]["ItemQty"] = 0; } $cartItems[$k]["ItemQty"] += $_POST["ItemQty"]; } } } else { $cartItems[] = array_merge($cartItems,$itemArray); } } else { $cartItems[] = $itemArray; } Session::set("cart_item", $cartItems); $counter = count(Session::get("cart_item")); Any help or suggestions would be greatly appreciated
-
Thanks you so much, i couldn't see the wood for the trees i'd put $cartItems = $itemArray; instead of $cartItems[] = $itemArray; before setting the session Session::set("cart_item", $cartItems);
-
Sorry am getting PH FLEXI FRAME EXTENDER FRAME 370373 1 210.92 210.92 So why is it putting everything on a new row!
-
I know its a different item because i cleared the session in case it was that but when i if(!empty(Session::get("cart_item"))) { print_r(Session::get("cart_item")); foreach(Session::get("cart_item") as $row) { print_r($row); } } for the session i'm getting Array ( [ItemDesc] => PH FLEXI FRAME EXTENDER FRAME [ItemCode] => 370373 [ItemQty] => 1 [price] => 210.92 [ItemTotalAmount] => 210.92 ) but for the row i'm getting PH FLEXI FRAME EXTENDER FRAME So where are the other keys and values going?
-
I'm trying to create a shopping cart but am having trouble retrieving the results and my head is about to explode. The array has been created because when i print_r or var_dump it i get Array ( [ItemDesc] => JOULE 300L AERO COIL [ItemCode] => 118710 [ItemQty] => 1 [price] => 4764.54 [ItemTotalAmount] => 4764.54 ) but when i call the array <table class="table table-striped"> <?php if(!empty(Session::get("cart_item"))) { foreach(Session::get("cart_item") as $row) { ?> <tr> <td width="70"><center><?php echo $row['ItemCode']; ?></center></td> <td><?php echo $row['ItemDesc']; ?></td> <td width="70"><center><?php echo $row['ItemQty']; ?></center></td> <td width="70"><center><?php echo $row['ItemAmount']; ?></center></td> <td width="70"><center><?php echo $row['ItemTotalAmount']; ?></center></td> </tr> <?php } } else { ?> <tr> <td colspan="5"><center><span class="rounded-pill p-1 px-5 bg-secondary">No Purchase Order Items Data Available!</span></center></td> </tr> <?php } ?> </table> I am getting the following error Error on Apr 22, 2024 22:25PM - Attempt to read property "ItemCode" Does anyone have any suggestions please I have also tried <tr> <td width="70"><center><?php echo $row->ItemCode; ?></center></td> <td><?php echo $row->ItemDesc; ?></td> <td width="70"><center><?php echo $row->ItemQty; ?></center></td> <td width="70"><center><?php echo $row->ItemAmount; ?></center></td> <td width="70"><center><?php echo $row->ItemTotalAmount; ?></center></td> </tr> But its throwing the exact same error
-
I have a materials table with over 7000 rows in it and it can take some time to load in datatables so have a pick from list drop down which works but not how i would like it, here is the code public function get_materials_pick($id) { return $this->db->select("SELECT ".PREFIX."tprices.IdPrice, ".PREFIX."tprices.Supplier, ".PREFIX."tprices.ProductCode, ".PREFIX."tprices.ProductDesc, ".PREFIX."tprices.Price FROM ".PREFIX."tprices WHERE ".PREFIX."tprices.ProductDesc LIKE '%$id%' ORDER BY ".PREFIX."tprices.Price, ".PREFIX."tprices.Supplier ASC"); } within datatables if i wanted to search say a black coat size XL i could put "Coat Black XL" "Black XL Coat" and anything and it would filter it but when I do the query above i have to type in the order its saved in the table Is their a way i can get arounf this Thanks in advance