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\">" .
182 _(
"Rappel: Poste créé automatiquement à partir de ")
183 . $p_fiche_def->class_base .
" </span> ";
188 $result[
'msg'] .=
" <span style=\"color:red\">" . _(
"Rappel: Poste par défaut sera ") .
189 $p_fiche_def->class_base .
194 $result[
'label']=_(
"Poste comptable");
195 $result[
'class']=
" highlight input_text";
203 switch ($this->ad_type) {
206 $result[
'input']->css_size =
"100%";
211 $result[
'input']->prec = ($this->ad_extra ==
"") ? 2 : $this->ad_extra;
220 $result[
'input'] =
new ITextArea();
221 $result[
'input']->style =
' class="itextarea" style="margin:0px;width:100%"';
226 $result[
'input']->set_attribute(
'ipopup',
'ipop_account');
227 $result[
'input']->set_attribute(
'account',
"av_text" . $this->ad_id);
234 $result[
'input']->value = (empty($this->av_text) ) ? 0 : 1;
238 $result[
'input']->value = $this->
cn->make_array($this->ad_extra);
239 $result[
'input']->style =
'style="width:100%"';
247 $result[
'input']->id = uniqid();
254 $result[
'label']->name =
"av_text" . $this->ad_id .
$result[
'input']->id .
"_label";
255 $result[
'input']->set_attribute(
'ipopup',
'ipopcard');
256 $result[
'input']->set_attribute(
'typecard', $this->ad_extra);
258 $result[
'input']->set_attribute(
'label',
"av_text" . $this->ad_id .
$result[
'input']->
id .
"_label");
259 $result[
'input']->autocomplete = 1;
260 $result[
'input']->dblclick =
"fill_ipopcard(this);";
272 if ($this->ad_id == 21 || $this->ad_id == 22 || $this->ad_id == 20 || $this->ad_id == 31) {
300 $fiche->attribut=$aProperty;
310 natural join fiche_detail
311 join jnt_fic_attr on (jnt_fic_attr.fd_id=fiche.fd_id and fiche_detail.ad_id=jnt_fic_attr.ad_id)
312 join attr_def on (attr_def.ad_id=fiche_detail.ad_id) where f_id= $1".
313 " order by jnt_order";
324 $t->ad_id=
$row[
'ad_id'];
325 $t->ad_text=
$row[
'ad_text'];
326 $t->av_text=
$row[
'ad_value'];
327 $t->ad_type=
$row[
'ad_type'];
328 $t->ad_size=
$row[
'ad_size'];
329 $t->ad_extra=
$row[
'ad_extra'];
330 $t->jnt_order=
$row[
'jnt_order'];
336 if (
sizeof(
$fiche->attribut)!=
sizeof(
$e->attribut))
342 foreach (
$e->attribut as
$f)
345 foreach (
$fiche->attribut as $g)
347 if ($g->ad_id==
$f->ad_id)
355 $t->ad_text=
$f->ad_text;
356 $t->jnt_order=
$f->jnt_order;
357 $t->ad_type=
$f->ad_type;
358 $t->ad_size=
$f->ad_size;
360 $t->ad_extra=
$f->ad_extra;
379 $url=
'<td>'.$this->add_link($this->ad_id,$this->av_text).
'</td>';
382 ' class="'.
$result[
'class'].
'" ').
404 if ($this->ad_id==21||$this->ad_id==22||$this->ad_id==20||$this->ad_id==31)
416 $class=
" input_text highlight info";
422 switch ($this->ad_type)
426 $x->value=$this->
cn->make_array($this->ad_extra);
434 $w->value=(trim(
$w->value)==
"")?1:
$w->value;
437 $w->value=$this->av_text;
439 $url=
"<td>".$this->add_link($this->ad_id,$this->av_text).
'</td>';
440 $ret.=
"<TR>".td(_($this->ad_text).
" $bulle",
' class="'.$class.
'" ').td(
$value.
" $msg",
441 'style="border:1px solid blue"').
'<td>'.
$url.
'</td>'.
" </TR>";
461 if ($p_fiche->cn->status()==PGSQL_TRANSACTION_IDLE)
463 $p_fiche->cn->start();
467 $p_fiche->cn->exec_sql(
"update fiche set f_enable=$1 where f_id=$2",
473 foreach ($p_fiche->attribut as
$value)
476 $sql=
" select jft_id from fiche_detail where ad_id=$1 and f_id=$2";
477 $Ret=$p_fiche->cn->exec_sql(
$sql, [
$value->ad_id, $p_fiche->id]);
483 $jft_id=$p_fiche->cn->get_next_seq(
's_jnt_fic_att_value');
485 $sql2=
"insert into fiche_detail(jft_id,ad_id,f_id,ad_value) values ($1,$2,$3,NULL)";
487 $ret2=$p_fiche->cn->exec_sql($sql2, array($jft_id,
$value->ad_id, $p_fiche->id));
493 $jft_id=
$tmp[
'jft_id'];
500 $used = $p_fiche->cn->get_value(
"select count(*) from jrnx where j_qcode= $1",[
$value->av_text]);
503 $p_fiche->cn->exec_sql(
$sql);
515 $v=mb_strtoupper(
$value->av_text??
"");
519 if (strpos($v,
',')!=0)
521 $ac_array=explode(
",", $v);
522 if (count($ac_array)<>2)
523 throw new Exception(
'Désolé, il y a trop de virgule dans le poste comptable '.
h($v));
526 $part1=$p_fiche->cn->get_value(
'select format_account($1)', array($part1));
527 $part2=$p_fiche->cn->get_value(
'select format_account($1)', array($part2));
529 if (mb_strlen($part1)>40)
530 throw new Exception(
"CP475."._(
"Poste comptable trop long"), 1);
531 if (mb_strlen($part2)>40)
532 throw new Exception(
"CP476."._(
"Poste comptable trop long"), 1);
534 $acc_account1=
new Acc_Account($p_fiche->cn, $part1);
536 if ($acc_account1->get_parameter(
"id")==-1)
539 $acc_account1->set_parameter(
"pcm_lib", $account_name);
540 $acc_account1->set_parameter(
'pcm_direct_use',
"Y");
541 $parent=$acc_account1->find_parent();
542 $acc_account1->set_parameter(
"pcm_val_parent", $parent);
543 $acc_account1->save();
546 if ($acc_account1->get_parameter(
'pcm_direct_use')==
'N')
548 throw new Exception(
"CP493."._(
"Utilisation directe interdite du poste comptable $part1"));
551 $acc_account2=
new Acc_Account($p_fiche->cn, $part2);
553 if ($acc_account2->get_parameter(
"id")==-1)
556 $acc_account2->set_parameter(
"pcm_lib", $account_name);
557 $acc_account2->set_parameter(
'pcm_direct_use',
"Y");
558 $parent=$acc_account2->find_parent();
559 $acc_account2->set_parameter(
"pcm_val_parent", $parent);
560 $acc_account2->save();
564 if ($acc_account2->get_parameter(
'pcm_direct_use')==
'N')
566 throw new Exception(
"CP511."._(
"Utilisation directe interdite du poste comptable $part2"));
568 $v=$part1.
','.$part2;
572 if (mb_strlen($v)>40)
573 throw new Exception(
"CP520."._(
"Poste comptable trop long"), 1);
576 if ($acc_account->get_parameter(
"id")==-1)
579 $acc_account->set_parameter(
"pcm_lib", $account_name);
581 $acc_account->set_parameter(
'pcm_direct_use',
"Y");
582 $parent=$acc_account->find_parent();
583 $acc_account->set_parameter(
"pcm_val_parent", $parent);
584 $acc_account->save();
588 if ($acc_account->get_parameter(
'pcm_direct_use')==
'N')
590 throw new Exception(
"CP537."._(
"Utilisation directe interdite du poste comptable $v"));
593 $sql=sprintf(
"select account_insert(%d,'%s')", $p_fiche->id, $v);
596 $p_fiche->cn->exec_sql(
$sql);
600 throw new Exception(
"CP546."._(
"opération annulée").
" ".
$e->getMessage());
607 $sql=sprintf(
"select account_insert(%d,null)", $p_fiche->id);
610 $Ret=$p_fiche->cn->exec_sql(
$sql);
614 throw new Exception(
"CP560."._(
"Erreur : Aucun compte parent ").
"[$v]");
626 if ($p_fiche->cn->get_value(
"select count(*) from tva_rate where tva_id=$1",[
$value->av_text])==0)
633 $sql=
"update fiche_detail set ad_value=$1 where jft_id=$2";
638 $p_fiche->cn->commit();
643 echo
'<span class="error">'.
646 record_log(
"CP597.".
$e->getMessage().$e->getTraceAsString());
647 if ($commit) { $p_fiche->cn->rollback(); }
681 $nb = count($a_property);
683 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.
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
if($action=='add_line') if( $action=='remove_line') if($action=='remove_cat') if(isset($_POST['change_name'])) if($action=='save_line') if(isset($_POST['add_modele'])) $fiche_def
Manage the account from the table tmp_pcmn.
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)