57 $this->display_mode=
'window';
61 return "card_property".var_export($this,
true);
65 if ( ! in_array($p_mode,array(
"window",
"large"))) {
66 throw new Exception(
"FIC70 invalide display mode");
68 $this->display_mode=$p_mode;
158 $result = [
'msg' =>
'',
'input' =>
null,
'label' =>
'',
'class' =>
'input_text',
'bulle'=>
''];
160 $result[
'class'] =
" input_text highlight info";
163 if ( $p_fiche_def ==
null ) {
164 throw new \Exception (
"CP162.p_fiche_def is null");
167 $result[
'input']->id = uniqid(
'accounting');
168 $result[
'input']->set_attribute(
'ipopup',
'ipop_account');
169 $result[
'input']->set_attribute(
'jrn',
'0');
171 $result[
'input']->dbl_click_history();
174 $sql =
"select account_auto($p_fiche_def->id)";
175 $ret_sql = $this->
cn->exec_sql(
$sql);
178 $result[
'label']->name =
"av_text" . $this->ad_id .
"_label";
179 $p_fiche_def->load();
180 if (
$a[
'account_auto'] ==
't') {
181 $result[
'msg'] .=
$result[
'label']->input() .
" <span style=\"color:red;font-size:80%;display:block\">" .
182 _(
"Rappel: Poste créé automatiquement à partir de ")
183 . $p_fiche_def->class_base .
" </span> ";
188 $result[
'msg'] .=
" <span style=\"color:red;font-size:80%;display:block\">" .
_(
"Rappel: Poste par défaut sera ") .
189 $p_fiche_def->class_base .
194 $result[
'label']=
_(
"Poste comptable");
195 $result[
'class']=
" highlight input_text";
211 switch ($this->ad_type) {
214 $result[
'input']->css_size =
"100%";
228 $result[
'input'] =
new ITextArea();
229 $result[
'input']->style =
' class="itextarea" style="margin:0px;width:100%"';
234 $result[
'input']->set_attribute(
'ipopup',
'ipop_account');
235 $result[
'input']->set_attribute(
'account',
"av_text" . $this->ad_id);
242 $result[
'input']->value = (empty($this->av_text) ) ? 0 : 1;
246 $result[
'input']->value = $this->
cn->make_array($this->ad_extra);
247 $result[
'input']->style =
'style="width:100%"';
255 $result[
'input']->id = uniqid();
262 $result[
'label']->name =
"av_text" . $this->ad_id .
$result[
'input']->id .
"_label";
263 $result[
'input']->set_attribute(
'ipopup',
'ipopcard');
264 $result[
'input']->set_attribute(
'typecard', $this->ad_extra);
266 $result[
'input']->set_attribute(
'label',
"av_text" . $this->ad_id .
$result[
'input']->
id .
"_label");
267 $result[
'input']->autocomplete = 1;
268 $result[
'input']->dblclick =
"fill_ipopcard(this);";
280 if ($this->ad_id == 21 || $this->ad_id == 22 || $this->ad_id == 20 || $this->ad_id == 31) {
308 $fiche->attribut=$aProperty;
318 natural join fiche_detail
319 join jnt_fic_attr on (jnt_fic_attr.fd_id=fiche.fd_id and fiche_detail.ad_id=jnt_fic_attr.ad_id)
320 join attr_def on (attr_def.ad_id=fiche_detail.ad_id) where f_id= $1".
321 " order by jnt_order";
333 $t->ad_text=
$row[
'ad_text'];
334 $t->av_text=
$row[
'ad_value'];
335 $t->ad_type=
$row[
'ad_type'];
336 $t->ad_size=
$row[
'ad_size'];
337 $t->ad_extra=
$row[
'ad_extra'];
338 $t->jnt_order=
$row[
'jnt_order'];
344 if (
sizeof(
$fiche->attribut)!=
sizeof(
$e->attribut))
350 foreach (
$e->attribut as
$f)
353 foreach (
$fiche->attribut as $g)
355 if ($g->ad_id==
$f->ad_id)
363 $t->ad_text=
$f->ad_text;
364 $t->jnt_order=
$f->jnt_order;
365 $t->ad_type=
$f->ad_type;
366 $t->ad_size=
$f->ad_size;
368 $t->ad_extra=
$f->ad_extra;
387 $url=
'<td>'.$this->add_link($this->ad_id,$this->av_text).
'</td>';
390 ' class="'.
$result[
'class'].
'" ').
412 if ($this->ad_id==21||$this->ad_id==22||$this->ad_id==20||$this->ad_id==31)
424 $class=
" input_text highlight info";
430 switch ($this->ad_type)
434 $x->value=$this->
cn->make_array($this->ad_extra);
442 $w->value=(trim(
$w->value)==
"")?1:
$w->value;
447 $url=
"<td>".$this->add_link($this->ad_id,$this->av_text).
'</td>';
448 $ret.=
"<TR>".td(
_($this->ad_text).
" $bulle",
' class="'.
$class.
'" ').td(
$value.
" $msg",
449 'style="border:1px solid blue"').
'<td>'.
$url.
'</td>'.
" </TR>";
469 if ($p_fiche->cn->status()==PGSQL_TRANSACTION_IDLE)
471 $p_fiche->cn->start();
475 $p_fiche->cn->exec_sql(
"update fiche set f_enable=$1 where f_id=$2",
481 foreach ($p_fiche->attribut as
$value)
484 $sql=
" select jft_id from fiche_detail where ad_id=$1 and f_id=$2";
485 $Ret=$p_fiche->cn->exec_sql(
$sql, [
$value->ad_id, $p_fiche->id]);
491 $jft_id=$p_fiche->cn->get_next_seq(
's_jnt_fic_att_value');
493 $sql2=
"insert into fiche_detail(jft_id,ad_id,f_id,ad_value) values ($1,$2,$3,NULL)";
495 $ret2=$p_fiche->cn->exec_sql($sql2, array($jft_id,
$value->ad_id, $p_fiche->id));
501 $jft_id=
$tmp[
'jft_id'];
508 $used = $p_fiche->cn->get_value(
"select count(*) from jrnx where j_qcode= $1",[
$value->av_text]);
511 $p_fiche->cn->exec_sql(
$sql);
523 $v=mb_strtoupper(
$value->av_text??
"");
527 if (strpos($v,
',')!=0)
529 $ac_array=explode(
",", $v);
530 if (count($ac_array)<>2)
531 throw new Exception(
'Désolé, il y a trop de virgule dans le poste comptable '.
h($v));
534 $part1=$p_fiche->cn->get_value(
'select format_account($1)', array($part1));
535 $part2=$p_fiche->cn->get_value(
'select format_account($1)', array($part2));
537 if (mb_strlen($part1)>40)
538 throw new Exception(
"CP475.".
_(
"Poste comptable trop long"), 1);
539 if (mb_strlen($part2)>40)
540 throw new Exception(
"CP476.".
_(
"Poste comptable trop long"), 1);
542 $acc_account1=
new Acc_Account($p_fiche->cn, $part1);
544 if ($acc_account1->get_parameter(
"id")==-1)
547 $acc_account1->set_parameter(
"pcm_lib", $account_name);
548 $acc_account1->set_parameter(
'pcm_direct_use',
"Y");
549 $parent=$acc_account1->find_parent();
550 $acc_account1->set_parameter(
"pcm_val_parent", $parent);
551 $acc_account1->save();
554 if ($acc_account1->get_parameter(
'pcm_direct_use')==
'N')
556 throw new Exception(
"CP493.".
_(
"Utilisation directe interdite du poste comptable $part1"));
559 $acc_account2=
new Acc_Account($p_fiche->cn, $part2);
561 if ($acc_account2->get_parameter(
"id")==-1)
564 $acc_account2->set_parameter(
"pcm_lib", $account_name);
565 $acc_account2->set_parameter(
'pcm_direct_use',
"Y");
566 $parent=$acc_account2->find_parent();
567 $acc_account2->set_parameter(
"pcm_val_parent", $parent);
568 $acc_account2->save();
572 if ($acc_account2->get_parameter(
'pcm_direct_use')==
'N')
574 throw new Exception(
"CP511.".
_(
"Utilisation directe interdite du poste comptable $part2"));
576 $v=$part1.
','.$part2;
580 if (mb_strlen($v)>40)
581 throw new Exception(
"CP520.".
_(
"Poste comptable trop long"), 1);
584 if ($acc_account->get_parameter(
"id")==-1)
587 $acc_account->set_parameter(
"pcm_lib", $account_name);
589 $acc_account->set_parameter(
'pcm_direct_use',
"Y");
590 $parent=$acc_account->find_parent();
591 $acc_account->set_parameter(
"pcm_val_parent", $parent);
592 $acc_account->save();
596 if ($acc_account->get_parameter(
'pcm_direct_use')==
'N')
598 throw new Exception(
"CP537.".
_(
"Utilisation directe interdite du poste comptable $v"));
601 $sql=sprintf(
"select account_insert(%d,'%s')", $p_fiche->id, $v);
604 $p_fiche->cn->exec_sql(
$sql);
608 throw new Exception(
"CP546.".
_(
"opération annulée").
" ".
$e->getMessage());
615 $sql=sprintf(
"select account_insert(%d,null)", $p_fiche->id);
618 $Ret=$p_fiche->cn->exec_sql(
$sql);
622 throw new Exception(
"CP560.".
_(
"Erreur : Aucun compte parent ").
"[$v]");
635 if ($acc_tva->tva_id==-1)
642 $sql=
"update fiche_detail set ad_value=$1 where jft_id=$2";
647 $p_fiche->cn->commit();
652 echo
'<span class="error">'.
655 record_log(
"CP597.".
$e->getMessage().$e->getTraceAsString());
656 if ($commit) { $p_fiche->cn->rollback(); }
690 $nb = count($a_property);
692 if ($a_property[
$i]->
get_ad_id() == $attr_def_id)
return $a_property[
$i];
mailTo($p_email)
compose a HTML string with email
noalyss_strip_tags($p_string)
noalyss_strlentrim($p_string)
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
sql_string($p_string)
Fix the problem with the quote char for the database.
td($p_string='', $p_extra='')
surround the string with td
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
foreach($array as $idx=> $m) $w
_("actif, passif,charge,...")
Manage the account from the table tmp_pcmn.
static build($db, $p_code)
retrieve TVA rate thanks the code that could be the tva_id or tva_code.
contains the attributes of a card , manage them, save them , ...
$display_mode
display mode values are large , window , display Property depending of this mode.
build_input($p_fiche_def=null)
build the needed elements to display
static update(Fiche $p_fiche)
update all the data of the card , including f_enable. if we are in a transaction we don't commit here...
set_jnt_order($jnt_order)
$ad_extra
ad_extra extra info for a attribute
$ad_text
ad_text string label of the attribute attr_def.ad_def
$jnt_order
jnt_order order to display
$ad_size
ad_size int size of the attribute
$av_text
av_text string value of this attribute
$ad_type
ad_type string : type of this attribute (select, text ,...)
$ad_id
ad_id int id of the attribute attr_def.ad_id
print()
Compute a HTML string in a TR element with information of this card property.
static load(Fiche $fiche)
Load all the attribute of a card , it modifies the parameter $fiche.
static findProperty($attr_def_id, $a_property)
return the Property of an array of property with the right ad_id
input($p_fiche_def=null)
input a property of a card
__construct($cn, $ad_id=0)
add_link($p_ad_id, $p_text)
add a link
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
define Class fiche and fiche def, those class are using class attribut
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
strAttribut($p_ad_id, $p_return=1)
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
This class handles only the numeric input, the input will call a javascript to change comma to period...
show a button, for selecting a account and a input text for manually inserting an account the differe...
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
static warnbulle($p_comment)
Display a warning in a bubble, text is in message_javascript.
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
if( $delta< 0) elseif( $delta==0)