function getStatsUsersEff($json) { $options = array('total', 'Events', 'Objects', 'Customers', 'Deposits', 'Handshakes'); $sql=" SELECT `users`.`ID`, CONCAT(`users`.`Firstname`, ' ', `users`.`Surname`) AS `Description`, COUNT(`events`.`ID`) AS `Events_c` FROM `users` INNER JOIN `events` ON `users`.`ID` =`events`.`UserID` WHERE (NOT `events`.`TableName` = 'newbuildings_subitems') GROUP BY `users`.`ID` ; "; $listitems=$this->db->query_assoc($sql, "ID"); $sql=" SELECT `users`.`ID`, COUNT(`objects`.`ID`) AS `Cnt` FROM `users` INNER JOIN `objects` ON `users`.`ID` =`objects`.`UserID` GROUP BY `users`.`ID` ; "; $objects=$this->db->query_assoc($sql, "ID"); $sql=" SELECT `users`.`ID`, COUNT(`customers`.`ID`) AS `Cnt` FROM `users` INNER JOIN `customers` ON `users`.`ID` =`customers`.`UserID` GROUP BY `users`.`ID` ; "; $customers=$this->db->query_assoc($sql, "ID"); $sql=" SELECT `users`.`ID`, COUNT(`customers`.`ID`) AS `Cnt` FROM `users` INNER JOIN `customers` ON `users`.`ID` =`customers`.`UserID` WHERE `customers`.`DepositReceived` = 1 GROUP BY `users`.`ID` ; "; $deposits=$this->db->query_assoc($sql, "ID"); $sql=" SELECT `users`.`ID`, COUNT(`customers`.`ID`) AS `Cnt` FROM `users` INNER JOIN `customers` ON `users`.`ID` =`customers`.`UserID` WHERE `customers`.`Handshake` = 1 GROUP BY `users`.`ID` ; "; $handshakes=$this->db->query_assoc($sql, "ID"); $t_Events_c = 0; $t_Objects_c = 0; $t_Customers_c = 0; $t_Deposits_c = 0; $t_Handshakes_c = 0; $w = 100; $hmax = 14; $listitems_new = array(); foreach ($listitems as $listitem) { if ($customers[$listitem->ID]->Cnt) { $listitem->Objects_c = ( $objects[$listitem->ID]->Cnt)?$objects[$listitem->ID]->Cnt:0; $listitem->Customers_c = ( $customers[$listitem->ID]->Cnt)?$customers[$listitem->ID]->Cnt:0; $listitem->Deposits_c = ( $deposits[$listitem->ID]->Cnt)?$deposits[$listitem->ID]->Cnt:0; $listitem->Handshakes_c = ($handshakes[$listitem->ID]->Cnt)?$handshakes[$listitem->ID]->Cnt:0; // $t_Events_c += $listitem->Events_c; $t_Objects_c += $listitem->Objects_c; $t_Customers_c += $listitem->Customers_c; $t_Deposits_c += $listitem->Deposits_c; $t_Handshakes_c += $listitem->Handshakes_c; if ( $t_Events_max<$listitem->Events_c ) $t_Events_max = $listitem->Events_c; if ( $t_Objects_max<$listitem->Objects_c ) $t_Objects_max = $listitem->Objects_c; if ( $t_Customers_max<$listitem->Customers_c ) $t_Customers_max = $listitem->Customers_c; if ( $t_Deposits_max<$listitem->Deposits_c ) $t_Deposits_max = $listitem->Deposits_c; if ($t_Handshakes_max<$listitem->Handshakes_c) $t_Handshakes_max = $listitem->Handshakes_c; $listitems_new[$listitem->ID] = clone $listitem; } } // ajax_echo_r ($listitems); // ajax_echo_r ($listitems_new); $listitems = $listitems_new; foreach ($listitems as $listitem) { $listitem->Events_r = (int)($listitem->Events_c*$w /$t_Events_max); $listitem->Objects_r = (int)($listitem->Objects_c *$w /$t_Objects_max); $listitem->Customers_r = (int)($listitem->Customers_c *$w /$t_Customers_max); if ($t_Deposits_max) { $listitem->Deposits_r = (int)($listitem->Deposits_c *$w /$t_Deposits_max); } else { $listitem->Deposits_r = (int)(1*$w); } if ($t_Handshakes_max) { $listitem->Handshakes_r = (int)($listitem->Handshakes_c*$w /$t_Handshakes_max); } else { $listitem->Handshakes_r = (int)(1*$w); } $listitem->Objects_RGB = HSVtoRGB(($listitem->Objects_r /$w)*0.33, 0.9, 1); $listitem->Customers_RGB = HSVtoRGB(($listitem->Customers_r /$w)*0.33, 0.9, 1); $listitem->Deposits_RGB = HSVtoRGB(($listitem->Deposits_r /$w)*0.33, 0.9, 1); $listitem->Handshakes_RGB = HSVtoRGB(($listitem->Handshakes_r/$w)*0.33, 0.9, 1); $listitem->Events_RGB = HSVtoRGB(($listitem->Events_r /$w)*0.33, 0.9, 1); } $objTotal = new stdClass; $objTotal->ID = 0; $objTotal->Description = "Итого"; $objTotal->Events_c = $t_Events_c; $objTotal->Objects_c = $t_Objects_c; $objTotal->Customers_c = $t_Customers_c; $objTotal->Deposits_c = $t_Deposits_c; $objTotal->Handshakes_c = $t_Handshakes_c; // echo dechex(15)."<br>"; $listitems['total']=$objTotal; $listitems = $this->fillTotals($listitems, $options); return $listitems; }
// Rect $colTracker = imagecolorallocate($target_image, 0, 220, 0); // Tracker $colTrackBg = imagecolorallocate($target_image, 0, 255, 0); // Tracker-Bg $colLshape = imagecolorallocate($target_image, 30, 30, 255); // L-Shape $colBgL = imagecolorallocate($target_image, 240, 240, 255); // L-Shape Cut-out $pNum = 0; // shape rendering ------------------------ foreach ($area->paths as $path) { switch ($path[0]) { case QR_AREA_PATH: // nice random colors $rgb = HSVtoRGB(array(mt_rand(0, 360) / 360.0, (mt_rand(0, 25) + 75) / 100.0, 0.9)); $colShape = imagecolorallocate($target_image, floor($rgb[0] * 255), floor($rgb[1] * 255), floor($rgb[2] * 255)); $subShape = 0; // fill pattern $fill_image = imagecreatetruecolor(5, 5); $colFillBg = imagecolorallocate($fill_image, 255, 255, 255); $colFill = imagecolorallocate($fill_image, floor($rgb[0] * 255), floor($rgb[1] * 255), floor($rgb[2] * 255)); imagefilledrectangle($fill_image, 0, 0, 5, 5, $colFillBg); imagesetthickness($fill_image, 1); imageline($fill_image, 0, 4, 4, 0, $colFill); // we iterate over all subshapes of shape foreach ($path[1] as $pathDetails) { $points = array(); $px = array_shift($pathDetails); $py = array_shift($pathDetails); $rle_steps = array_shift($pathDetails);