Skip to content

Commit 6117ff5

Browse files
j_nouryj_noury
j_noury
authored and
j_noury
committed
add first files
1 parent aacf1e9 commit 6117ff5

File tree

4 files changed

+244
-0
lines changed

4 files changed

+244
-0
lines changed

Module.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
namespace Beetools;
3+
4+
class Module
5+
{
6+
public function getConfig()
7+
{
8+
return include __DIR__ . '/config/module.config.php';
9+
}
10+
11+
public function getAutoloaderConfig()
12+
{
13+
return array(
14+
'Zend\Loader\StandardAutoloader' => array(
15+
'namespaces' => array(
16+
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
17+
),
18+
),
19+
);
20+
}
21+
}

config/module.config.php

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
return array(
3+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Beetools\Controller;
4+
5+
use Zend\Mvc\Controller\AbstractActionController;
6+
use Zend\View\Model\ViewModel;
7+
8+
use Beetools\Model\Beehive;
9+
10+
class IndexController extends AbstractActionController
11+
{
12+
public function indexAction()
13+
{
14+
$view = new ViewModel();
15+
$oRuche = new Beehive();
16+
17+
$aCalendars = array();
18+
foreach($oRuche->getTypes() as $type)
19+
{
20+
$aCalendars["$type"] = $oRuche->getCalendarOfType($type);
21+
//echo $oRuche->toHtml($aCalendars["$type"]);
22+
}
23+
$view->aCalendars = $aCalendars;
24+
$view->oRuche = $oRuche;
25+
26+
return $view;
27+
}
28+
29+
}

src/Beetools/Model/Beehive.php

+191
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
<?php
2+
class Beehive
3+
{
4+
protected $aTypes = array('bee','mother','drone');
5+
6+
public function getTypes()
7+
{
8+
return $this->aTypes;
9+
}
10+
public function getCalendarOfType($type)
11+
{
12+
$aBeille = array('title' => "Evolution of $type & varroas");
13+
for($day = 1; $day <= 31; $day++)
14+
{
15+
$state = $this->getState($day, $type);
16+
$cell = $this->getCell($day, $type);
17+
$event = $this->getEvent($day, $type);
18+
$aBeille['datas'][$day] = array(
19+
'state' => $state,
20+
'cell' => $cell,
21+
'event' => $event,
22+
);
23+
}
24+
return $aBeille;
25+
}
26+
27+
public function toHtml($aBeille)
28+
{
29+
$html = '<table name="' . $aBeille['title'] . '" >';
30+
$html .= '<thead>';
31+
$html .= '<caption>'. $aBeille['title'] .'</caption>';
32+
$html .= '</thead>';
33+
$days = '<tr>';
34+
$state = '<tr>';
35+
$cell = '<tr>';
36+
$events = '<tr>';
37+
foreach($aBeille['datas'] as $day => $d)
38+
{
39+
$days .= '<td>' . $day . '</td>';
40+
$state .= '<td>' . $d['state'] . '</td>';
41+
$cell .= '<td>' . $d['cell'] . '</td>';
42+
$events .= '<td>' . $d['event'] . '</td>';
43+
}
44+
$state .= '</tr>';
45+
$cell .= '</tr>';
46+
$events .= '</tr>';
47+
$html .= $days . $state . $cell . $events;
48+
$html .= '<tbody>';
49+
$html .= '</tbody>';
50+
$html .= '</table>';
51+
return $html;
52+
}
53+
public function getState($day, $type)
54+
{
55+
$state = null;
56+
if($day <= 3)
57+
{
58+
$state = 'egg';
59+
}
60+
else
61+
{
62+
if($day > 3)
63+
{
64+
if($type == 'bee' OR $type == 'mother')
65+
{
66+
if($day <= 8)
67+
{
68+
$state = 'larva';
69+
}
70+
elseif($day <= 11 && $type == 'bee')
71+
{
72+
$state = 'cocoon';
73+
}
74+
elseif($day <= 10 && $type == 'mother')
75+
{
76+
$state = 'cocoon';
77+
}
78+
}
79+
elseif($type == 'drone')
80+
{
81+
if($day <= 9)
82+
{
83+
$state = 'larva';
84+
}
85+
elseif($day <= 12)
86+
{
87+
$state = 'cocoon';
88+
}
89+
}
90+
}
91+
}
92+
93+
return $state;
94+
}
95+
96+
public function getCell($day, $type)
97+
{
98+
$cell = null;
99+
100+
if($day <= 3)
101+
{
102+
$cell = 'wax';// cire
103+
}
104+
if($day > 3)
105+
{
106+
if($type == 'bee' OR $type == 'drone')
107+
{
108+
if($day <= 6)
109+
{
110+
$cell = 'jelly';// cire
111+
}
112+
else
113+
{
114+
if($day <= 8 && $type == 'bee')
115+
{
116+
$cell = 'larval boiled';
117+
}
118+
elseif($day <= 9 && $type == 'drone')
119+
{
120+
$cell = 'larval boiled';
121+
}
122+
}
123+
}
124+
elseif($type == 'mother')
125+
{
126+
if($day <= 8)
127+
{
128+
$cell = 'jelly';// cire
129+
}
130+
}
131+
132+
}
133+
return $cell;
134+
}
135+
136+
public function getEvent($day, $type)
137+
{
138+
$event = null;
139+
140+
if($type == 'bee')
141+
{
142+
if($day == 8)
143+
{
144+
$event = 'varroa inside';//
145+
}
146+
if($day == 9)
147+
{
148+
$event = 'capping';// operculation
149+
}
150+
if($day == 21)
151+
{
152+
$event = 'bee & varroas birth';//
153+
}
154+
}
155+
if($type == 'mother')
156+
{
157+
if($day == 8)
158+
{
159+
$event = 'varroa inside';//
160+
}
161+
if($day == 9)
162+
{
163+
$event = 'capping';// operculation
164+
}
165+
if($day == 16)
166+
{
167+
$event = 'mother birth';//
168+
}
169+
if($day == (16 + 6))
170+
{
171+
$event = 'first fly';//
172+
}
173+
}
174+
if($type == 'drone')
175+
{
176+
if($day == 9)
177+
{
178+
$event = 'varroa inside';//
179+
}
180+
if($day == 10)
181+
{
182+
$event = 'capping';// operculation
183+
}
184+
if($day == 24)
185+
{
186+
$event = 'drone & varroas birth ';//
187+
}
188+
}
189+
return $event;
190+
}
191+
}

0 commit comments

Comments
 (0)