noalyss Version-9
Public Member Functions | Static Public Member Functions | Data Fields | Private Attributes
Anticipation Class Reference
+ Collaboration diagram for Anticipation:

Public Member Functions

 __construct ($p_init, $p_id=0)
 constructor More...
 
 display ()
 Display the result of the forecast. More...
 
 getCat ()
 
 getForecastId ()
 
 getItem ()
 
 input_category ()
 
 input_form ()
 display the detail for the forecast , for modifying item, category or name More...
 
 input_title ()
 
 object_clone ()
 Clone completely Forecast and returns the new forecast_id. More...
 
 setCat ($cat)
 
 setForecastId ($forecast_id)
 
 setItem ($item)
 

Static Public Member Functions

static div ()
 

Data Fields

 $cat
 
 $item
 

Private Attributes

 $cn
 
 $forecast_id
 forecast.f_id More...
 

Detailed Description

Definition at line 35 of file anticipation.class.php.

Constructor & Destructor Documentation

◆ __construct()

Anticipation::__construct (   $p_init,
  $p_id = 0 
)

constructor

Parameters
$p_initDatabase object

Definition at line 47 of file anticipation.class.php.

48 {
49 $this->cn = $p_init;
50 $this->forecast_id = $p_id;
51 }
$input_from cn
Definition: balance.inc.php:66

References $p_id, and cn.

Member Function Documentation

◆ display()

Anticipation::display ( )

Display the result of the forecast.

Parameters
$p_periode
Returns
HTML String with the code

Definition at line 183 of file anticipation.class.php.

184 {
185 bcscale(4);
186 $forecast = new Forecast_SQL($this->cn, $this->forecast_id);
187 $forecast->load();
188 $str_name = h($forecast->getp('f_name'));
189
190 $start = $forecast->getp('f_start_date');
191 $end = $forecast->getp('f_end_date');
192
193 if ($start == '') throw new Exception (_('Période de début non valable'));
194 if ($end == '') throw new Exception (_('Période de fin non valable'));
195
196 $per = new Periode($this->cn, $start);
197 $str_start = format_date($per->first_day());
198
199 $per = new Periode($this->cn, $end);
200 $str_end = format_date($per->last_day());
201
202
203 $r = "";
204 $aCat = $this->cn->get_array('select fc_id,fc_desc from forecast_category where f_id=$1 order by fc_order',
205 array($this->forecast_id));
206 $aItem = array();
207 $aReal = array();
208 $poste = new Acc_Account_Ledger($this->cn, 0);
209
210 $aPeriode = $this->cn->get_array("select p_id,to_char(p_start,'MM.YYYY') as myear from parm_periode
211 where p_start >= (select p_start from parm_periode where p_id=$1)
212 and p_end <= (select p_end from parm_periode where p_id=$2)
213 order by p_start",[$start,$end]);
214 $error = array();
215 for ($j = 0; $j < count($aCat); $j++) {
216
217 // Item of the category,montly estimation
218 $aItem[$j] = $this->cn->get_array('select fi_account,fi_text,fi_amount,
219 fi_amount_initial
220 from forecast_item where fc_id=$1 and fi_pid=0 order by fi_order ',
221 array($aCat[$j]['fc_id']));
222
223 // Item of the category, estimation for a specific month
224 $aPerMonth[$j] = $this->cn->get_array('select fi_pid,fi_account,fi_text,fi_amount
225 from forecast_item where fc_id=$1 and fi_pid !=0 order by fi_order ',
226 array($aCat[$j]['fc_id']));
227
228 /* compute the real amount for periode */
229 for ($k = 0; $k < count($aItem[$j]); $k++) {
230 /* for each periode */
231 for ($l = 0; $l < count($aPeriode); $l++) {
232 if ($aItem[$j][$k]['fi_account'] != '') {
233
234 $poste->id = $aItem[$j][$k]['fi_account'];
235 $aresult = Impress::parse_formula($this->cn, "OK", $poste->id, $aPeriode[$l]['p_id'], $aPeriode[$l]['p_id']);
236 $tmp_label = $aresult['desc'];
237 $amount['solde'] = $aresult['montant'];
238
239 if ($tmp_label != 'OK') {
240 $error[] = "<li> " . $aItem[$j][$k]['fi_text'] . $poste->id . '</li>';
241 }
242 }
243 $aReal[$j][$k][$l] = $amount['solde'];
244 }
245 }
246
247 }
248 if ( DEBUGNOALYSS < 2 ) { ob_start(); }
249 require_once NOALYSS_TEMPLATE . '/anticipation-display.php';
250 $r .= ob_get_contents();
251 if ( DEBUGNOALYSS < 2 ) { ob_end_clean(); }
252 return $r;
253 }
format_date($p_date, $p_from_format='YYYY-MM-DD', $p_to_format='DD.MM.YYYY')
format the date, when taken from the database the format is MM-DD-YYYY
Definition: ac_common.php:852
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
Manage the account from the table jrn, jrnx or tmp_pcmn.
ORM abstract of the table public.forecast.
static parse_formula($p_cn, $p_label, $p_formula, $p_start, $p_end, $p_eval=true, $p_type_date=0, $p_sql="")
For the periode tables parm_periode and jrn_periode.
$str_end
Definition: fiche.inc.php:57
$str_start
Definition: fiche.inc.php:56

References $amount, $aPeriode, $end, $error, $forecast, $l, $per, $poste, $r, $start, $str_end, $str_name, $str_start, cn, format_date(), h, and Impress\parse_formula().

+ Here is the call graph for this function:

◆ div()

static Anticipation::div ( )
static

Definition at line 255 of file anticipation.class.php.

256 {
257 $r = '<div id="div_anti" style="display:none">';
258 $r .= '</div>';
259 return $r;
260 }

References $r.

◆ getCat()

Anticipation::getCat ( )
Returns
mixed

Definition at line 56 of file anticipation.class.php.

57 {
58 return $this->cat;
59 }

References $cat.

◆ getForecastId()

Anticipation::getForecastId ( )
Returns
int|mixed

Definition at line 88 of file anticipation.class.php.

89 {
90 return $this->forecast_id;
91 }
$forecast_id
forecast.f_id

References $forecast_id.

Referenced by input_form().

◆ getItem()

Anticipation::getItem ( )
Returns
mixed

Definition at line 72 of file anticipation.class.php.

73 {
74 return $this->item;
75 }

References $item.

◆ input_category()

Anticipation::input_category ( )

Definition at line 106 of file anticipation.class.php.

107 {
108 $visible=uniqid();
109 echo '<h2>';
110 echo _("Catégorie");
111 echo '<span style="margin-left:5em;font-style:normal;font-size:150%">';
112 echo Icon_Action::less($visible, "");
113 echo '</span>';
114 echo '</h2>';
115
116 echo '<div id="anticipation_input_category" >';
118 $forecast_category->set_forecast_id($this->forecast_id);
119 $forecast_category->display_table(" where f_id = $1"
120 . " order by fc_order",
121 [$this->forecast_id]);
122 echo $forecast_category->create_js_script();
123 echo '</div>';
124 echo <<<EOF
125 <script>
126 var visible=true;
127 var icon=document.getElementById('{$visible}');
128icon.onclick=function () {
129
130 if ( visible ) { visible = false; $("anticipation_input_category").hide();icon.innerHTML="&#xe824;"}
131 else { visible = true;$("anticipation_input_category").show();icon.innerHTML="&#xe827;"}
132 }
133</script>
134EOF;
135
136 }
catch(Exception $e) $forecast_category
static less($p_id, $p_javascript)

References $forecast_category, Forecast_Category_MTable\build(), and Icon_Action\less().

Referenced by input_form().

+ Here is the call graph for this function:

◆ input_form()

Anticipation::input_form ( )

display the detail for the forecast , for modifying item, category or name

Definition at line 142 of file anticipation.class.php.

143 {
144 $this->input_title();
145
146 $this->input_category();
147 $http=new HttpInput();
148 $ac=$http->request("ac");
149 echo h2(_("Eléments"));
151 $forecast_item->set_forecast_id($this->forecast_id);
152 $forecast_item->display_table();
153 echo '<hr>';
154 $href="do.php?".http_build_query(array('ac'=>$ac, 'sa'=>'vw','gDossier'=>Dossier::id(),'f_id'=>$this->forecast_id));
155
156
157 $form=dossier::hidden();
158 $form.=HtmlInput::hidden('action', '');
159 $form.=HtmlInput::hidden('f_id', $this->getForecastId());
161
162 echo '<form method="get" id="form_del" onsubmit="return confirm_box(this,content[\'47\'])" style="display:inline-block">';
163 echo $form;
164 echo HtmlInput::hidden("action","del");
165 echo HtmlInput::submit('del_bt', _('Effacer'));
166 echo '</form>';
167
168 echo '<form method="get" id="form_clone" onsubmit="return confirm_box(this,content[\'47\']) " style="display:inline-block" >';
169 echo $form;
170 echo HtmlInput::hidden("action","clone");
171 echo HtmlInput::submit("clone_bt",_("Clone"));
172 echo '</form>';
173
174 echo HtmlInput::button_anchor(_("Retour"), $href);
175
176 }
h2($p_string, $p_class="", $raw="")
Definition: ac_common.php:68
$href
Definition: adm.inc.php:31
catch(Exception $e) $forecast_item
if(isset( $_REQUEST[ 'show'])) if(isset($_REQUEST['del'])) $ac
static id()
return the 'gDossier' value after a check
static hidden($p_name, $p_value, $p_id="")
static button_anchor($p_label, $p_value, $p_name="", $p_javascript="", $p_class="smallbutton")
create a button with a ref
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array

References $ac, $forecast_item, $form, $href, $http, Forecast_Item_MTable\build(), HtmlInput\button_anchor(), getForecastId(), h2(), HtmlInput\hidden(), Dossier\id(), input_category(), input_title(), and HtmlInput\submit().

+ Here is the call graph for this function:

◆ input_title()

Anticipation::input_title ( )

Definition at line 101 of file anticipation.class.php.

102 {
103 require_once NOALYSS_TEMPLATE . "/anticipation-input_title.php";
104 }

Referenced by input_form().

◆ object_clone()

Anticipation::object_clone ( )

Clone completely Forecast and returns the new forecast_id.

Returns
type

Definition at line 266 of file anticipation.class.php.

267 {
268 $this->cn->start();
269 /* save into the table forecast */
270 $sql = "insert into forecast(f_name,f_start_date,f_end_date) select 'clone '||f_name,f_start_date,f_end_date
271 from forecast
272 where f_id=$1 returning f_id";
273 $new = $this->cn->get_value($sql, array($this->forecast_id));
274
275 /* save into forecast_cat */
276 $sql = "insert into forecast_category(fc_desc,f_id,fc_order)
277 select fc_desc,$1,fc_order
278 from forecast_category
279 where f_id=$2 returning fc_id";
280 $array = $this->cn->get_array($sql, array($new, $this->forecast_id));
281
282 $old = $this->cn->get_array("select fc_id from forecast_category where f_id=$1", array($this->forecast_id));
283 /* save into forecast_item */
284 for ($i = 0; $i < count($array); $i++) {
285 $this->cn->exec_sql("insert into forecast_item (fi_text,fi_account,fi_order,fc_id,
286 fi_amount,fi_pid) " .
287 " select fi_text,fi_account,fi_order,$1,fi_amount,fi_pid " .
288 " from forecast_item where fc_id=$2", array($array[$i]['fc_id'], $old[$i]['fc_id']));
289 }
290 $this->cn->commit();
291 return $new;
292 }

References $array, $i, $old, $sql, and cn.

◆ setCat()

Anticipation::setCat (   $cat)
Parameters
mixed$cat

Definition at line 64 of file anticipation.class.php.

65 {
66 $this->cat = $cat;
67 }

References $cat.

◆ setForecastId()

Anticipation::setForecastId (   $forecast_id)
Parameters
int | mixed$forecast_id

Definition at line 96 of file anticipation.class.php.

97 {
98 $this->forecast_id = $forecast_id;
99 }

References $forecast_id.

◆ setItem()

Anticipation::setItem (   $item)
Parameters
mixed$item

Definition at line 80 of file anticipation.class.php.

81 {
82 $this->item = $item;
83 }

References $item.

Field Documentation

◆ $cat

Anticipation::$cat

array of object categorie (forecast_category)

Definition at line 39 of file anticipation.class.php.

Referenced by getCat(), and setCat().

◆ $cn

Anticipation::$cn
private

Definition at line 38 of file anticipation.class.php.

◆ $forecast_id

Anticipation::$forecast_id
private

forecast.f_id

Definition at line 41 of file anticipation.class.php.

Referenced by getForecastId(), and setForecastId().

◆ $item

Anticipation::$item

Definition at line 40 of file anticipation.class.php.

Referenced by getItem(), and setItem().


The documentation for this class was generated from the following file: