noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Operation_Exercice Class Reference

Special operations end or start of exercice. More...

+ Inheritance diagram for Operation_Exercice:
+ Collaboration diagram for Operation_Exercice:

Public Member Functions

 __construct ($p_id=-1)
 
 display_result ()
 
 display_row ($data, $row_tr=true)
 let display one row
 
 display_total ($with_span=true)
 display the balance (total) of the operation
 
 get_operation_exercice_sql ()
 
 input_transfer ()
 input data for transfering
 
 set_operation_exercice_sql (Operation_Exercice_SQL $operation_exercice_sql)
 
 submit_transfer ($ledger_id)
 transfer to accountancy
 
 transform ($ledger_id)
 Transform the data in table OPERATION_EXERCICE and OPERATION_EXERCICE_DETAIL into an array usable by Acc_Ledger, the result will be stored into the global variable $oe_data @globals $oe_data array with the data transformed.
 

Static Public Member Functions

static delete ($aOperation_id)
 
static input_row (Operation_Exercice_Detail_SQL $operation_detail_sql)
 input one row of operation_exercice
 
static input_source ()
 input the source of the data : folder, exercice, closing or opening operation
 
static list_draft ()
 

Protected Attributes

 $operation_exercice_sql
 

Detailed Description

Special operations end or start of exercice.

Definition at line 29 of file operation_exercice.class.php.

Constructor & Destructor Documentation

◆ __construct()

Operation_Exercice::__construct ( $p_id = -1)

Reimplemented in Operation_Closing, and Operation_Opening.

Definition at line 34 of file operation_exercice.class.php.

35 {
36 $this->operation_exercice_sql = new Operation_Exercice_SQL(Dossier::connect(), $p_id);
37 }

References $p_id.

Member Function Documentation

◆ delete()

static Operation_Exercice::delete ( $aOperation_id)
static

Definition at line 293 of file operation_exercice.class.php.

294 {
296 foreach ($aOperation_id as $operation_id)
297 {
298 $cn->exec_sql("delete from operation_exercice where oe_id=$1",[$operation_id]);
299 }
300 }
static connect()

References $cn, and $operation_id.

◆ display_result()

Operation_Exercice::display_result ( )

Reimplemented in Operation_Closing, and Operation_Opening.

Definition at line 48 of file operation_exercice.class.php.

49 {
50 $date = new IDate("exercice_date");
51 $date->id = "exercice_date";
52 $date->value = format_date($this->operation_exercice_sql->getp("oe_date"), "DD.MM.YYYY");
53 $inplace_date = new Inplace_Edit($date);
54 $inplace_date->add_json_param("op", "operation_exercice+date");
55 $inplace_date->add_json_param("gDossier", Dossier::id());
56 $inplace_date->add_json_param("oe_id", $this->operation_exercice_sql->oe_id);
57 $inplace_date->set_callback("ajax_misc.php");
58 echo _("Date"), $inplace_date->input();
59
60 $text_operation = new IText("text_operation");
61 $text_operation->id = uniqid("text");
62 $text_operation->size = 80;
63 $text_operation->value = $this->operation_exercice_sql->getp("oe_text");
64 $inplace_text = new Inplace_Edit($text_operation);
65 $inplace_text->add_json_param("op", "operation_exercice+text");
66 $inplace_text->add_json_param("gDossier", Dossier::id());
67 $inplace_text->add_json_param("oe_id", $this->operation_exercice_sql->oe_id);
68 $inplace_text->set_callback("ajax_misc.php");
69 echo $inplace_text->input();
70
72 // get data
73 $a_data = $cn->get_array("
74 SELECT oed_id
75 , oe_id
76 , oed_poste
77 , oed_qcode
78 , oed_label
79 , oed_amount
80 , oed_debit
81 FROM public.operation_exercice_detail
82 where
83 oe_id=$1
84 order by oed_debit desc,oed_poste,oed_qcode
85
86 ", [$this->operation_exercice_sql->oe_id]);
87 $aheader = array(_("Poste"), _("Fiche"), _("Libellé"), _("Montant"), _("Débit/Crédit"));
88 echo '<div></div>';
89 echo \HtmlInput::filter_table("operation_exercice_tb", '0,1,2,3,4', 1);
90 echo \HtmlInput::button_action(_("Ajouter une ligne"), sprintf("operation_exercice.modify_row('-1','%s')", $this->operation_exercice_sql->oe_id));
91 echo '<table class="result" id="operation_exercice_tb">';
92 foreach ($aheader as $header) echo th($header, 'style="text-align:center"');
93 echo th("");
94
95 foreach ($a_data as $data) {
96 $this->display_row($data);
97 }
98 echo '</table>';
99 echo \HtmlInput::button_action(_("Ajouter une ligne"), sprintf("operation_exercice.modify_row('-1','%s')", $this->operation_exercice_sql->oe_id));
100 $this->display_total();
101 echo Dossier::hidden();
102 $js = <<<EOF
103(function() {
104 $$(".op-exercice").forEach(item=>item.addEventListener("click",function(event) {operation_exercice.click_modify_row(item)}));
105 })();
106EOF;
107 echo create_script($js);
108 }
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
th($p_string, $p_extra='', $raw='')
Definition ac_common.php:58
_("actif, passif,charge,...")
static hidden()
return a string to set gDossier into a FORM
display_row($data, $row_tr=true)
let display one row
display_total($with_span=true)
display the balance (total) of the operation
if(count($a_accounting)==0) $header
create_script($p_string)
create the HTML for adding the script tags around of the script

References $cn, $data, $date, $header, $js, _, create_script(), display_row(), display_total(), format_date(), and th().

+ Here is the call graph for this function:

◆ display_row()

Operation_Exercice::display_row ( $data,
$row_tr = true )

let display one row

Parameters
$dataarray row of operation_exercice_detail [oed_id, oe_id, oed_poste, oed_qcode oed_label oed_amount oed_debit]
Returns
void
See also
Operation_Exercice_Detail_SQL

Definition at line 157 of file operation_exercice.class.php.

158 {
159 if ($row_tr) printf('<tr class="op-exercice even" id="oe_%s" oed_id="%s" oe_id="%s">', $data['oed_id'], $data['oed_id'], $data['oe_id']);
160 echo td($data['oed_poste']);
161 echo td($data['oed_qcode']);
162 echo td(h($data['oed_label']));
163 echo td(nbm($data['oed_amount']), 'class="num"');
164 echo td(($data['oed_debit'] == 'f' ? _("Crédit") : _("Débit")), 'style="text-align:center"');
165 echo td(\Icon_Action::modify(uniqid(), sprintf("operation_exercice.modify_row('%s','%s')", $data['oed_id'], $data['oe_id'])));
166
167
168 if ($row_tr) print ('</tr >');
169 }
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83
nbm($p_number, $p_dec=2)
format the number with a sep.
h( $row[ 'oa_description'])
static modify($p_id, $p_javascript)
Display the icon to modify a idem.
print
Type of printing.

References $data, _, h, Icon_Action\modify(), nbm(), print, and td().

Referenced by display_result().

+ Here is the call graph for this function:

◆ display_total()

Operation_Exercice::display_total ( $with_span = true)

display the balance (total) of the operation

Parameters
bool$with_spanif yes add the span wrapper , otherwise doesn't add it

Definition at line 114 of file operation_exercice.class.php.

115 {
117 $sql_total = "
118 with saldo_deb_cred as
119(
120 select
121 case when oed_debit is true then oed_amount else 0-oed_amount end signed_amount ,
122 case when oed_debit is true then oed_amount end debit,
123 case when oed_debit is false then oed_amount end credit
124 from public.operation_exercice_detail
125 where oe_id=$1
126)
127select sum(signed_amount) delta,sum(debit) debit,sum(credit) credit from saldo_deb_cred
128 ";
129 $total = $cn->get_row($sql_total, [$this->operation_exercice_sql->oe_id]);
130 if ($with_span) {
131 echo '<span id="tot_ope_exe" style="margin-left:20%">';
132 }
133 $style = 'style="display:inline-block;padding:1rem;margin:1rem;border:1px solid navy;width:20%;text-align:center;font-size:140%"';
134
135 echo span(sprintf(_("Débit %s"), nbm($total['debit'])), $style);
136 echo span(sprintf(_("Crédit %s"), nbm($total['credit'])), $style);
137 $s = "";
138 if ($total['delta'] > 0) {
139 $s = " Solde débiteur ";
140 }
141 if ($total['delta'] < 0) {
142 $s = " Solde créditeur ";
143 }
144 echo span($s . " " . nbm($total['delta']), $style);
145 if ($with_span) {
146 echo '</span>';
147 }
148 }
span($p_string, $p_extra='')
Definition ac_common.php:43
if( $t !=-1) $total
Definition compute.php:80

References $cn, $s, $style, $total, _, nbm(), and span().

Referenced by display_result().

+ Here is the call graph for this function:

◆ get_operation_exercice_sql()

Operation_Exercice::get_operation_exercice_sql ( )

Definition at line 302 of file operation_exercice.class.php.

302 : Operation_Exercice_SQL
303 {
305 }

References $operation_exercice_sql.

◆ input_row()

static Operation_Exercice::input_row ( Operation_Exercice_Detail_SQL $operation_detail_sql)
static

input one row of operation_exercice

Parameters
$dataarray row of operation_exercice_detail [oed_id, oe_id, oed_poste, oed_qcode oed_label oed_amount oed_debit]
Returns
void
See also
Operation_Exercice_Detail_SQL

Definition at line 178 of file operation_exercice.class.php.

179 {
180 $operation=new Operation_Exercice_SQL($operation_detail_sql->get_cn(),$operation_detail_sql->getp("oe_id"));
181 if ( $operation->getp("oe_transfer_date") !="") {
182 require_once NOALYSS_TEMPLATE . "/operation_exercice-input_row-error.php";
183 return;
184 }
185
186 require_once NOALYSS_TEMPLATE . "/operation_exercice-input_row.php";
187 }
getp($p_string)
set the value thanks the alias name instead of the colum name

References $operation, Data_SQL\get_cn(), and Data_SQL\getp().

+ Here is the call graph for this function:

◆ input_source()

static Operation_Exercice::input_source ( )
static

input the source of the data : folder, exercice, closing or opening operation

Returns
void

Definition at line 43 of file operation_exercice.class.php.

44 {
45 require NOALYSS_TEMPLATE . "/operation_exercice-input_source.php";
46 }

◆ input_transfer()

Operation_Exercice::input_transfer ( )

input data for transfering

Returns
void

Definition at line 193 of file operation_exercice.class.php.

194 {
196 if ( $operation->getp("oe_transfer_date") !="") {
197 echo '<span class="warning">';
198 printf(_("Opération transférée le %s")
199 ,$operation->getp("oe_transfer_date") );
200 echo '</span>';
201 return;
202 }
203 require_once NOALYSS_TEMPLATE . "/operation_exercice-input_transfer.php";
204 }

References $operation, $operation_exercice_sql, and _.

◆ list_draft()

static Operation_Exercice::list_draft ( )
static

Definition at line 286 of file operation_exercice.class.php.

287 {
288
289 require_once NOALYSS_TEMPLATE."/operation_exercice-list_draft.php";
290
291 }

◆ set_operation_exercice_sql()

Operation_Exercice::set_operation_exercice_sql ( Operation_Exercice_SQL $operation_exercice_sql)

Definition at line 307 of file operation_exercice.class.php.

307 : Operation_Exercice_SQL
308 {
309 $this->operation_exercice_sql = $operation_exercice_sql;
310 return $this;
311
312 }

References $operation_exercice_sql.

◆ submit_transfer()

Operation_Exercice::submit_transfer ( $ledger_id)

transfer to accountancy

Parameters
$ledger_idint the ledger id (jrn_def_id)
Returns
void

Definition at line 211 of file operation_exercice.class.php.

212 {
213 global $oe_result; // result of operation
214 global $oe_data; // transform data to array used by Acc_Ledger::insert
215 global $oe_status ; // status OK or NOK
217
218 $this->transform($ledger_id);
219
220 $oe_status = "OK";
221 $ledger = new Acc_Ledger($cn, $ledger_id);
222 try {
223 $cn->start();
224 if ($this->operation_exercice_sql->getp("oe_transfer_date")!="") throw new \Exception("duplicate",EXC_DUPLICATE);
225 if ( empty($oe_data['e_date'] ) ) throw new \Exception ("Date null",2);
226 $ledger->verify_operation($oe_data);
227 $ledger->save($oe_data);
228 $oe_result=_("Détail opération");
229 $oe_result.=sprintf('<a class="detail" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a><hr>',
230 $ledger->jr_id, dossier::id(), $ledger->internal);
231
232 $cn->exec_sql("update operation_exercice set oe_transfer_date=to_timestamp($1,'DD.MM.YY HH24:MI') , jr_internal=$2 where oe_id=$3",
233 [date('d.m.Y H:i'),$ledger->internal,$this->operation_exercice_sql->oe_id]);
234
235 $cn->commit();
236 return true;
237 } catch (\Exception $e) {
238 $oe_result=$e->getMessage();
239
240 $oe_status='NOK';
241 $cn->rollback();
242 }
243 return false;
244
245 }
if(isNumber($jr_id)==0) $ledger_id
transform($ledger_id)
Transform the data in table OPERATION_EXERCICE and OPERATION_EXERCICE_DETAIL into an array usable by ...
const EXC_DUPLICATE
Definition constant.php:345

References $cn, $e, $ledger, $ledger_id, _, EXC_DUPLICATE, and transform().

+ Here is the call graph for this function:

◆ transform()

Operation_Exercice::transform ( $ledger_id)

Transform the data in table OPERATION_EXERCICE and OPERATION_EXERCICE_DETAIL into an array usable by Acc_Ledger, the result will be stored into the global variable $oe_data @globals $oe_data array with the data transformed.

Parameters
$ledger_id
Returns
void
Exceptions
Exception

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

256 {
257 global $oe_data; // transform data to array used by Acc_Ledger::verify_operation
259 $acc_ledger=new \Acc_Ledger($cn, $ledger_id);
260 $oe_data = array();
261 $oe_data['p_currency_code'] = 0;
262 $oe_data['p_currency_rate'] = 1;
263 $oe_data['p_jrn'] = $ledger_id;
264 $oe_data['e_date'] = $this->operation_exercice_sql->oe_date;
265 $oe_data['desc']=$this->operation_exercice_sql->getp("oe_text");
266 $operation_detail_sql = new Operation_Exercice_Detail_SQL($cn);
267 $all_operation = $operation_detail_sql->collect_objects(' where oe_id = $1',[$this->operation_exercice_sql->oe_id]);
268 $nb = 0;
269 foreach ($all_operation as $item) {
270 $oe_data['qc_' . $nb] = $item->oed_qcode;
271 $oe_data['poste' . $nb] = $item->oed_poste;
272 $oe_data['ld' . $nb] = $item->oed_label;
273 $oe_data['amount' . $nb] = $item->oed_amount;
274
275 if ($item->oed_debit == "t") $oe_data['ck' . $nb] = 't';
276 $nb++;
277 }
278 $oe_data['nb_item']=$nb;
279 $oe_data['e_pj']=$acc_ledger->guess_pj();
280 $oe_data['e_pj_suggest']=$acc_ledger->guess_pj();
281 $oe_data['mt']=microtime(true);
282 $oe_data['jr_optype']=($this->operation_exercice_sql->getp('oe_type')=='opening')?'OPE':'CLO';
283
284 }

References $cn, $ledger_id, and $nb.

Referenced by submit_transfer().

Field Documentation

◆ $operation_exercice_sql

Operation_Exercice::$operation_exercice_sql
protected

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