473,473 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help...

24 New Member
What languages is this in???

<?php
session_start();
require('db.php');

mysql_connect(MACHINE, USER, '');
mysql_select_db(DBNAME);

//Obtaining session variables (From do_login.php)
$uname = $_SESSION['username'];
$pwd =$_SESSION['pwd'];
$outletid = $_SESSION['outletid'];
$role = $_SESSION['role'];
$userid = $_SESSION['userid'];

$month = $_POST['month'];
$year = $_POST['year'];

class easyChart {
var $title;
var $width;
var $height;
var $bartitle;
var $barheight;
var $barwidth;
var $background;
var $multiply;
var $spacebar;
var $leftspace;
var $rightspace;
var $upspace;
var $bottomspace;
var $leftlegend;
var $linecolor;
var $barcolor;
var $titlecolor;
var $legendcolor;
var $barinfocolor;

function easyChart () {
$this->title = "Chart Title";
$this->background = Array(153,204,102);
$this->linecolor = Array(240,240,240);
$this->barcolor = Array(255,255,153);
$this->titlecolor = Array(111,166,55);
$this->legendcolor = Array(0,0,0);
$this->barinfocolor = Array(0,0,0);
$this->width = 600;
$this->height = 500;
$this->barwidth = 20;
$this->leftspace = 75;
$this->rightspace = 25;
$this->upspace = 50;
$this->bottomspace = 50;
$this->leftlegend = 10;
$this->chartlegend = "";
}

function setTitleColor ($color) {
$this->titlecolor = explode(",",$color);
}
function setLegendColor ($color) {
$this->legendcolor = explode(",",$color);
}
function setBarInfoColor ($color) {
$this->barinfocolor = explode(",",$color);
}
function setBarColor ($color) {
$this->barcolor = explode(",",$color);
}
function setLineColor ($color) {
$this->linecolor = explode(",",$color);
}
function setLeftLegend ($leftlegend) {
$this->leftlegend = $leftlegend;
}
function setLeftSpace ($leftspace) {
$this->leftspace = $leftspace;
}
function setRightSpace ($rightspace) {
$this->rightspace = $rightspace;
}
function setTitle ($title) {
$this->title = $title;
}
function setBackground ($color) {
$this->background = explode (",", $color);
}
function setWidth ($width) {
$this->width = $width;
}
function setHeight ($height) {
$this->height = $height;
}
function setBarWidth ($barwidth) {
$this->barwidth = $barwidth;
}
function addBar ($bartitle, $barheight) {
$this->bartitle[] = $bartitle;
$this->barheight[] = $barheight;
}
function prepare() {
$this->chartlegend .= "";
$arr = $this->barheight;
sort ($arr);
reset ($arr);
$this->highestvalue = end($arr);
$this->valueincriement = $this->highestvalue / $this->leftlegend;
$this->multiply = ( ($this->height-($this->upspace + $this->bottomspace)) / $this->highestvalue);
$this->spacebar = ( ($this->width - ($this->leftspace + $this->rightspace)) - ($this->barwidth * count($arr) ) ) / (count($arr)+1);
$this->legendspace = ($this->height - ($this->upspace+$this->bottomspace)) / $this->leftlegend;
if ($this->barwidth * count($this->barheight) > ($this->width-($this->upspace+$this->bottomspace))) $err = "Bar width is to large";
if ($err!="") {
print $err;
exit;
}
}
function generateChart() {
$im = ImageCreate($this->width,$this->height);
$white = ImageColorAllocate($im,255,255,255);
$background = ImageColorAllocate($im,$this->background[0],$this->background[1],$this->background[2]);
$black = ImageColorAllocate($im,0,0,0);
$gray = ImageColorAllocate($im,100,100,100);
$linecolor = ImageColorAllocate($im,$this->linecolor[0],$this->linecolor[1],$this->linecolor[2]);
$barcolor = ImageColorAllocate($im,$this->barcolor[0],$this->barcolor[1],$this->barcolor[2]);
$titlecolor = ImageColorAllocate($im,$this->titlecolor[0],$this->titlecolor[1],$this->titlecolor[2]);
$legendcolor = ImageColorAllocate($im,$this->legendcolor[0],$this->legendcolor[1],$this->legendcolor[2]);
$barinfocolor = ImageColorAllocate($im,$this->barinfocolor[0],$this->barinfocolor[1],$this->barinfocolor[2]);
@ImageFilledRectangle($im,0,25,$this->width,$this->height-15,$background);
@ImageFilledRectangle($im,1,26,$this->width-2,$this->height-16,$white);
@ImageFilledRectangle($im,2,27,$this->width-3,$this->height-17,$background);
@ImageFilledRectangle($im,$this->leftspace,$this->upspace-10,$this->width-$this->rightspace,$this->height-($this->bottomspace-20),$white);
$titlewidth = strlen($this->title) * ImageFontWidth(5);
$titlexpos = ($this->width - $titlewidth)/2;
@ImageString ($im, 5, $titlexpos, 5, $this->title, $titlecolor);
@ImageString ($im, 1, 0, $this->height - 10, base64_decode($this->chartlegend.""), $black);
for($i=0;$i<=$this->leftlegend;$i++){
$legendx = 5;
$legendy = $this->upspace + ($this->legendspace * $i) - 6;
@ImageString($im, 2, $legendx, $legendy, $this->highestvalue-($this->valueincriement*$i), $legendcolor);
@ImageLine ($im, $this->leftspace, $legendy+6, $this->width - $this->rightspace, $legendy+6, $linecolor);
}
for($i=0;$i<count($this->barheight);$i++){
$j=$i+1;
$x1 = ($j * $this->spacebar) + ($i * $this->barwidth) + $this->leftspace;
$y1 = $this->height - ($this->barheight[$i]*$this->multiply) - $this->upspace;
$x2 = $x1 + $this->barwidth;
$y2 = $this->height - $this->bottomspace;
$bartitlewidth = strlen($this->bartitle[$i]) * ImageFontWidth(2);
$centerofbar = $x1 + ($this->barwidth / 2);
$bartitlex = $centerofbar - ($bartitlewidth/2);
$bartitley = $y2 + 5;
@ImageFilledRectangle($im, $x1, $y1, $x2, $y2, $barcolor);
@ImageString($im, 2, $bartitlex, $bartitley, $this->bartitle[$i], $barinfocolor);
}
@ImageJPEG($im);
@ImageDestroy($im);
}
};

// HERE IS THE EXAMPLE TO USE THE CHART CLASS
$chart = new easyChart(); // Object initialized
$chart->setTitle("Stock Item Graph"); // Title of Chart
$chart->setBackground("153,204,102"); // Background of chart [opt]
$chart->setLineColor("225,225,225"); // Line color separator [opt]
$chart->setBarColor("255,255,153"); // Bar color [opt]
$chart->setTitleColor("111,166,55"); // Color Title [opt]
$chart->setLegendColor("0,0,0"); // Legend Color [opt]
$chart->setBarInfoColor("0,0,0"); // Bar Info Color [opt]
$chart->setWidth(800); // Width of Chart
$chart->setHeight(500); // Height of Chart
$chart->setBarWidth(20); // Bar Width
$chart->setLeftSpace(55); // Left Space
$chart->setRightSpace(25); // Right Space
$chart->setLeftLegend(10); // Left Legend

$sql="SELECT SUM(quantity), SUM(amount), category FROM invoice WHERE category='Bottoms - Shorts' AND month = '$month' AND year = '$year' GROUP BY category";
$results=mysql_query($sql) or die(mysql_error());
$rows = mysql_fetch_array($results);
$shorts = $rows['SUM(quantity)'];

$sql="SELECT SUM(quantity), SUM(amount), category FROM invoice WHERE category='Bottoms - Skirts' AND month = '$month' AND year = '$year' GROUP BY category";
$results=mysql_query($sql) or die(mysql_error());
$rows = mysql_fetch_array($results);
$skirts = $rows['SUM(quantity)'];

$sql="SELECT SUM(quantity), SUM(amount), category FROM invoice WHERE category='Outerwear - Coats' AND month = '$month' AND year = '$year' GROUP BY category";
$results=mysql_query($sql) or die(mysql_error());
$rows = mysql_fetch_array($results);
$coats = $rows['SUM(quantity)'];

$sql="SELECT SUM(quantity), SUM(amount), category FROM invoice WHERE category='Tops - Blouse' AND month = '$month' AND year = '$year' GROUP BY category";
$results=mysql_query($sql) or die(mysql_error());
$rows = mysql_fetch_array($results);
$blouse = $rows['SUM(quantity)'];

$sql="SELECT SUM(quantity), SUM(amount), category FROM invoice WHERE category='Others' AND month = '$month' AND year = '$year' GROUP BY category";
$results=mysql_query($sql) or die(mysql_error());
$rows = mysql_fetch_array($results);
$others = $rows['SUM(quantity)'];

$chart->addBar("Bottoms - Shorts",$shorts); // Sample content of chart
$chart->addBar("Bottoms - Skirts",$skirts);
$chart->addBar("Outerwear - Coats",$coats);
$chart->addBar("Tops - Blouse",$blouse);
$chart->addBar("Others",$others);


$chart->prepare(); // Chart Preparation
$chart->generateChart(); // Chart Generation
?>
Jan 10 '08 #1
5 1644
nitinpatel1117
111 New Member
hi, it looks like PHP

It usess OO (Object oriented) programing.


so if you've never seen or done any OOD code before, then i suppose this will look unfamiliar.
Jan 10 '08 #2
fruityfreak
24 New Member
I've done a bit of it before... But I've never came across something like this... (A mixture of PHP and the bold part codes) Mmm... Any idea how can I label my x-axis and y-axis???
Jan 10 '08 #3
mwasif
802 Recognized Expert Contributor
It will be easy for others to read your code if you can use proper coding tags. Read the guidelines to use CODE tags.
Jan 10 '08 #4
fruityfreak
24 New Member
sorry...

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. session_start(); 
  4. require('db.php');
  5.  
  6. mysql_connect(MACHINE, USER, '');
  7. mysql_select_db(DBNAME);
  8.  
  9. //Obtaining session variables (From do_login.php)
  10. $uname = $_SESSION['username'];
  11. $pwd =$_SESSION['pwd']; 
  12. $outletid = $_SESSION['outletid'];
  13. $role = $_SESSION['role']; 
  14. $userid = $_SESSION['userid'];
  15.  
  16.     $month = $_POST['month'];
  17.     $year = $_POST['year'];
  18.  
  19. class easyChart {
  20. var $title;
  21. var $width;
  22. var $height;
  23. var $bartitle;
  24. var $barheight;
  25. var $barwidth;
  26. var $background;
  27. var $multiply;
  28. var $spacebar;
  29. var $leftspace;
  30. var $rightspace;
  31. var $upspace;
  32. var $bottomspace;
  33. var $leftlegend;
  34. var $linecolor;
  35. var $barcolor;
  36. var $titlecolor;
  37. var $legendcolor;
  38. var $barinfocolor;
  39.  
  40. function easyChart () {
  41. $this->title = "Chart Title";
  42. $this->background = Array(153,204,102);
  43. $this->linecolor = Array(240,240,240);
  44. $this->barcolor = Array(255,255,153);
  45. $this->titlecolor = Array(111,166,55);
  46. $this->legendcolor = Array(0,0,0);
  47. $this->barinfocolor = Array(0,0,0);
  48. $this->width = 600;
  49. $this->height = 500;
  50. $this->barwidth = 20;
  51. $this->leftspace = 75;
  52. $this->rightspace = 25;
  53. $this->upspace = 50;
  54. $this->bottomspace = 50;
  55. $this->leftlegend = 10;
  56. $this->chartlegend = "";
  57. }
  58.  
  59. function setTitleColor ($color) {
  60. $this->titlecolor = explode(",",$color);
  61. }
  62. function setLegendColor ($color) {
  63. $this->legendcolor = explode(",",$color);
  64. }
  65. function setBarInfoColor ($color) {
  66. $this->barinfocolor = explode(",",$color);
  67. }
  68. function setBarColor ($color) {
  69. $this->barcolor = explode(",",$color);
  70. }
  71. function setLineColor ($color) {
  72. $this->linecolor = explode(",",$color);
  73. }
  74. function setLeftLegend ($leftlegend) {
  75. $this->leftlegend = $leftlegend;
  76. }
  77. function setLeftSpace ($leftspace) {
  78. $this->leftspace = $leftspace;
  79. }
  80. function setRightSpace ($rightspace) {
  81. $this->rightspace = $rightspace;
  82. }
  83. function setTitle ($title) {
  84. $this->title = $title;
  85. }
  86. function setBackground ($color) {
  87. $this->background = explode (",", $color);
  88. }
  89. function setWidth ($width) {
  90. $this->width = $width;
  91. }
  92. function setHeight ($height) {
  93. $this->height = $height;
  94. }
  95. function setBarWidth ($barwidth) {
  96. $this->barwidth = $barwidth;
  97. }
  98. function addBar ($bartitle, $barheight) {
  99. $this->bartitle[] = $bartitle;
  100. $this->barheight[] = $barheight;
  101. }
  102. function prepare() {
  103. $this->chartlegend .= "";
  104. $arr = $this->barheight;
  105. sort ($arr);
  106. reset ($arr);
  107. $this->highestvalue = end($arr);
  108. $this->valueincriement = $this->highestvalue / $this->leftlegend;
  109. $this->multiply = ( ($this->height-($this->upspace + $this->bottomspace)) / $this->highestvalue);
  110. $this->spacebar = ( ($this->width - ($this->leftspace + $this->rightspace)) - ($this->barwidth * count($arr) ) ) / (count($arr)+1);
  111. $this->legendspace = ($this->height - ($this->upspace+$this->bottomspace)) / $this->leftlegend;
  112. if ($this->barwidth * count($this->barheight) > ($this->width-($this->upspace+$this->bottomspace))) $err = "Bar width is to large";
  113. if ($err!="") {
  114. print $err;
  115. exit;
  116. }
  117. }
  118. function generateChart() {
  119. $im = ImageCreate($this->width,$this->height);
  120. $white = ImageColorAllocate($im,255,255,255);
  121. $background = ImageColorAllocate($im,$this->background[0],$this->background[1],$this->background[2]);
  122. $black = ImageColorAllocate($im,0,0,0);
  123. $gray = ImageColorAllocate($im,100,100,100);
  124. $linecolor = ImageColorAllocate($im,$this->linecolor[0],$this->linecolor[1],$this->linecolor[2]);
  125. $barcolor = ImageColorAllocate($im,$this->barcolor[0],$this->barcolor[1],$this->barcolor[2]);
  126. $titlecolor = ImageColorAllocate($im,$this->titlecolor[0],$this->titlecolor[1],$this->titlecolor[2]);
  127. $legendcolor = ImageColorAllocate($im,$this->legendcolor[0],$this->legendcolor[1],$this->legendcolor[2]);
  128. $barinfocolor = ImageColorAllocate($im,$this->barinfocolor[0],$this->barinfocolor[1],$this->barinfocolor[2]);
  129. @ImageFilledRectangle($im,0,25,$this->width,$this->height-15,$background);
  130. @ImageFilledRectangle($im,1,26,$this->width-2,$this->height-16,$white);
  131. @ImageFilledRectangle($im,2,27,$this->width-3,$this->height-17,$background);
  132. @ImageFilledRectangle($im,$this->leftspace,$this->upspace-10,$this->width-$this->rightspace,$this->height-($this->bottomspace-20),$white);
  133. $titlewidth = strlen($this->title) * ImageFontWidth(5);
  134. $titlexpos = ($this->width - $titlewidth)/2;
  135. @ImageString ($im, 5, $titlexpos, 5, $this->title, $titlecolor);
  136. @ImageString ($im, 1, 0, $this->height - 10, base64_decode($this->chartlegend.""), $black);
  137. for($i=0;$i<=$this->leftlegend;$i++){
  138. $legendx = 5;
  139. $legendy = $this->upspace + ($this->legendspace * $i) - 6;
  140. @ImageString($im, 2, $legendx, $legendy, $this->highestvalue-($this->valueincriement*$i), $legendcolor);
  141. @ImageLine ($im, $this->leftspace, $legendy+6, $this->width - $this->rightspace, $legendy+6, $linecolor);
  142. }
  143. for($i=0;$i<count($this->barheight);$i++){
  144. $j=$i+1;
  145. $x1 = ($j * $this->spacebar) + ($i * $this->barwidth) + $this->leftspace;
  146. $y1 = $this->height - ($this->barheight[$i]*$this->multiply) - $this->upspace;
  147. $x2 = $x1 + $this->barwidth;
  148. $y2 = $this->height - $this->bottomspace;
  149. $bartitlewidth = strlen($this->bartitle[$i]) * ImageFontWidth(2);
  150. $centerofbar = $x1 + ($this->barwidth / 2);
  151. $bartitlex = $centerofbar - ($bartitlewidth/2);
  152. $bartitley = $y2 + 5;
  153. @ImageFilledRectangle($im, $x1, $y1, $x2, $y2, $barcolor);
  154. @ImageString($im, 2, $bartitlex, $bartitley, $this->bartitle[$i], $barinfocolor);
  155. }
  156. @ImageJPEG($im);
  157. @ImageDestroy($im);
  158. }
  159. };
  160.  
  161. // HERE IS THE EXAMPLE TO USE THE CHART CLASS
  162. $chart = new easyChart(); // Object initialized
  163. $chart->setTitle("Stock Item Graph"); // Title of Chart
  164. $chart->setBackground("153,204,102"); // Background of chart [opt]
  165. $chart->setLineColor("225,225,225"); // Line color separator [opt]
  166. $chart->setBarColor("255,255,153"); // Bar color [opt]
  167. $chart->setTitleColor("111,166,55"); // Color Title [opt]
  168. $chart->setLegendColor("0,0,0"); // Legend Color [opt]
  169. $chart->setBarInfoColor("0,0,0"); // Bar Info Color [opt]
  170. $chart->setWidth(800); // Width of Chart
  171. $chart->setHeight(500); // Height of Chart
  172. $chart->setBarWidth(20); // Bar Width
  173. $chart->setLeftSpace(55); // Left Space
  174. $chart->setRightSpace(25); // Right Space
  175. $chart->setLeftLegend(10); // Left Legend
  176.  
  177. $sql="SELECT SUM(quantity), SUM(amount), category FROM invoice WHERE category='Bottoms - Shorts' AND month = '$month' AND year = '$year' GROUP BY category";
  178. $results=mysql_query($sql) or die(mysql_error());
  179.     $rows = mysql_fetch_array($results);
  180.     $shorts = $rows['SUM(quantity)'];
  181.  
  182. $sql="SELECT SUM(quantity), SUM(amount), category FROM invoice WHERE category='Bottoms - Skirts' AND month = '$month' AND year = '$year' GROUP BY category";
  183. $results=mysql_query($sql) or die(mysql_error());
  184.     $rows = mysql_fetch_array($results);
  185.     $skirts = $rows['SUM(quantity)'];    
  186.  
  187. $sql="SELECT SUM(quantity), SUM(amount), category FROM invoice WHERE category='Outerwear - Coats' AND month = '$month' AND year = '$year' GROUP BY category";
  188. $results=mysql_query($sql) or die(mysql_error());
  189.     $rows = mysql_fetch_array($results);
  190.     $coats = $rows['SUM(quantity)'];
  191.  
  192. $sql="SELECT SUM(quantity), SUM(amount), category FROM invoice WHERE category='Tops - Blouse' AND month = '$month' AND year = '$year' GROUP BY category";
  193. $results=mysql_query($sql) or die(mysql_error());
  194.     $rows = mysql_fetch_array($results);
  195.     $blouse = $rows['SUM(quantity)'];
  196.  
  197. $sql="SELECT SUM(quantity), SUM(amount), category FROM invoice WHERE category='Others' AND month = '$month' AND year = '$year' GROUP BY category";
  198. $results=mysql_query($sql) or die(mysql_error());
  199.     $rows = mysql_fetch_array($results);
  200.     $others = $rows['SUM(quantity)'];    
  201.  
  202. $chart->addBar("Bottoms - Shorts",$shorts); // Sample content of chart
  203. $chart->addBar("Bottoms - Skirts",$skirts);
  204. $chart->addBar("Outerwear - Coats",$coats);
  205. $chart->addBar("Tops - Blouse",$blouse);
  206. $chart->addBar("Others",$others);
  207.  
  208.  
  209. $chart->prepare(); // Chart Preparation
  210. $chart->generateChart(); // Chart Generation
  211. ?>
  212.  
  213.  
Jan 10 '08 #5
Markus
6,050 Recognized Expert Expert
It's most definitely in PHP.

I know this by:
[php]
<?php
[/php]

;)
Jan 10 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
9
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
5
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time...
8
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
1
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve...
0
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.