noalyss Version-9
Public Member Functions | Static Public Member Functions | Protected Attributes
Operation_Exercice Class Reference
+ 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 More...
 
 display_total ($with_span=true)
 display the balance (total) of the operation More...
 
 get_operation_exercice_sql ()
 
 input_transfer ()
 input data for transfering More...
 
 set_operation_exercice_sql (Operation_Exercice_SQL $operation_exercice_sql)
 
 submit_transfer ($ledger_id)
 transfer to accountancy More...
 
 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. More...
 

Static Public Member Functions

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

Protected Attributes

 $operation_exercice_sql
 

Detailed Description

Definition at line 25 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 30 of file operation_exercice.class.php.

31 {
32 $this->operation_exercice_sql = new Operation_Exercice_SQL(Dossier::connect(), $p_id);
33 }
static connect()

References $p_id, and Dossier\connect().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

static Operation_Exercice::delete (   $aOperation_id)
static

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

290 {
292 foreach ($aOperation_id as $operation_id)
293 {
294 $cn->exec_sql("delete from operation_exercice where oe_id=$1",[$operation_id]);
295 }
296 }

References $cn, and Dossier\connect().

+ Here is the call graph for this function:

◆ display_result()

Operation_Exercice::display_result ( )

Reimplemented in Operation_Closing, and Operation_Opening.

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

45 {
46 $date = new IDate("exercice_date");
47 $date->id = "exercice_date";
48 $date->value = format_date($this->operation_exercice_sql->getp("oe_date"), "DD.MM.YYYY");
49 $inplace_date = new Inplace_Edit($date);
50 $inplace_date->add_json_param("op", "operation_exercice+date");
51 $inplace_date->add_json_param("gDossier", Dossier::id());
52 $inplace_date->add_json_param("oe_id", $this->operation_exercice_sql->oe_id);
53 $inplace_date->set_callback("ajax_misc.php");
54 echo _("Date"), $inplace_date->input();
55
56 $text_operation = new IText("text_operation");
57 $text_operation->id = uniqid("text");
58 $text_operation->size = 80;
59 $text_operation->value = $this->operation_exercice_sql->getp("oe_text");
60 $inplace_text = new Inplace_Edit($text_operation);
61 $inplace_text->add_json_param("op", "operation_exercice+text");
62 $inplace_text->add_json_param("gDossier", Dossier::id());
63 $inplace_text->add_json_param("oe_id", $this->operation_exercice_sql->oe_id);
64 $inplace_text->set_callback("ajax_misc.php");
65 echo $inplace_text->input();
66
68 // get data
69 $a_data = $cn->get_array("
70 SELECT oed_id
71 , oe_id
72 , oed_poste
73 , oed_qcode
74 , oed_label
75 , oed_amount
76 , oed_debit
77 FROM public.operation_exercice_detail
78 where
79 oe_id=$1
80 order by oed_debit desc,oed_poste,oed_qcode
81
82 ", [$this->operation_exercice_sql->oe_id]);
83 $aheader = array(_("Poste"), _("Fiche"), _("Libellé"), _("Montant"), _("Débit/Crédit"));
84 echo '<div></div>';
85 echo \HtmlInput::filter_table("operation_exercice_tb", '0,1,2,3,4', 1);
86 echo \HtmlInput::button_action(_("Ajouter une ligne"), sprintf("operation_exercice.modify_row('-1','%s')", $this->operation_exercice_sql->oe_id));
87 echo '<table class="result" id="operation_exercice_tb">';
88 foreach ($aheader as $header) echo th($header, 'style="text-align:center"');
89 echo th("");
90
91 foreach ($a_data as $data) {
92 $this->display_row($data);
93 }
94 echo '</table>';
95 echo \HtmlInput::button_action(_("Ajouter une ligne"), sprintf("operation_exercice.modify_row('-1','%s')", $this->operation_exercice_sql->oe_id));
96 $this->display_total();
97 echo Dossier::hidden();
98 $js = <<<EOF
99(function() {
100 $$(".op-exercice").forEach(item=>item.addEventListener("click",function(event) {operation_exercice.click_modify_row(item)}));
101 })();
102EOF;
103 echo create_script($js);
104 }
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
th($p_string, $p_extra='', $raw='')
Definition: ac_common.php:58
static id()
return the 'gDossier' value after a check
static hidden()
return a string to set gDossier into a FORM
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Definition: idate.class.php:34
Html Input.
Definition: itext.class.php:30
Inplace_edit class for ajax update of HtmlInput object.
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, Dossier\connect(), create_script(), display_row(), display_total(), format_date(), Dossier\hidden(), Dossier\id(), 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 153 of file operation_exercice.class.php.

154 {
155 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']);
156 echo td($data['oed_poste']);
157 echo td($data['oed_qcode']);
158 echo td(h($data['oed_label']));
159 echo td(nbm($data['oed_amount']), 'class="num"');
160 echo td(($data['oed_debit'] == 'f' ? _("Crédit") : _("Débit")), 'style="text-align:center"');
161 echo td(\Icon_Action::modify(uniqid(), sprintf("operation_exercice.modify_row('%s','%s')", $data['oed_id'], $data['oe_id'])));
162
163
164 if ($row_tr) print ('</tr >');
165 }
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.
Definition: ac_common.php:137
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 110 of file operation_exercice.class.php.

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

References $cn, $s, $style, $total, Dossier\connect(), 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 ( )

◆ 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 174 of file operation_exercice.class.php.

175 {
176 $operation=new Operation_Exercice_SQL($operation_detail_sql->get_cn(),$operation_detail_sql->getp("oe_id"));
177 if ( $operation->getp("oe_transfer_date") !="") {
178 require_once NOALYSS_TEMPLATE . "/operation_exercice-input_row-error.php";
179 return;
180 }
181
182 require_once NOALYSS_TEMPLATE . "/operation_exercice-input_row.php";
183 }
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 39 of file operation_exercice.class.php.

40 {
41 require NOALYSS_TEMPLATE . "/operation_exercice-input_source.php";
42 }

◆ input_transfer()

Operation_Exercice::input_transfer ( )

input data for transfering

Returns
void

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

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

References $operation, and $operation_exercice_sql.

◆ list_draft()

static Operation_Exercice::list_draft ( )
static

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

283 {
284
285 require_once NOALYSS_TEMPLATE."/operation_exercice-list_draft.php";
286
287 }

◆ set_operation_exercice_sql()

Operation_Exercice::set_operation_exercice_sql ( Operation_Exercice_SQL  $operation_exercice_sql)

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

304 {
305 $this->operation_exercice_sql = $operation_exercice_sql;
306 return $this;
307
308 }

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 207 of file operation_exercice.class.php.

208 {
209 global $oe_result; // result of operation
210 global $oe_data; // transform data to array used by Acc_Ledger::insert
211 global $oe_status ; // status OK or NOK
213
214 $this->transform($ledger_id);
215
216 $oe_status = "OK";
218 try {
219 $cn->start();
220 if ($this->operation_exercice_sql->getp("oe_transfer_date")!="") throw new \Exception("duplicate",EXC_DUPLICATE);
221 if ( empty($oe_data['e_date'] ) ) throw new \Exception ("Date null",2);
222 $ledger->verify_operation($oe_data);
223 $ledger->save($oe_data);
224 $oe_result=_("Détail opération");
225 $oe_result.=sprintf('<a class="detail" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a><hr>',
226 $ledger->jr_id, dossier::id(), $ledger->internal);
227
228 $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",
229 [date('d.m.Y H:i'),$ledger->internal,$this->operation_exercice_sql->oe_id]);
230
231 $cn->commit();
232 return true;
233 } catch (\Exception $e) {
234 $oe_result=$e->getMessage();
235
236 $oe_status='NOK';
237 $cn->rollback();
238 }
239 return false;
240
241 }
$ledger_id
$input_from id
Definition: balance.inc.php:63
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, Dossier\connect(), EXC_DUPLICATE, id, 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 251 of file operation_exercice.class.php.

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

References $cn, $ledger_id, $nb, and Dossier\connect().

Referenced by submit_transfer().

+ Here is the call graph for this function:

Field Documentation

◆ $operation_exercice_sql

Operation_Exercice::$operation_exercice_sql
protected

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