operation->od_direct='t'; } function get_post() { parent::get_post(); extract($_POST); for ($i=0;$i<$this->operation->nb_item;$i++) { $poste=HtmlInput::default_value_post("poste".$i, null); $qcode=HtmlInput::default_value_post("qc_".$i, null); if ( $poste == null && $qcode == null ) continue; if ($poste != null && trim ($poste) != "") { $this->{'poste'.$i}=$poste; $this->{'isqc'.$i}='f'; } if ( $qcode != null && trim ($qcode) != "") { $this->{'isqc'.$i}=(trim($_POST['qc_'.$i]) != "")?'t':'f'; $this->{'poste'.$i}=trim ($qcode); } $this->{"amount".$i}=$_POST['amount'.$i]; $this->{"ck".$i}=(isset($_POST['ck'.$i]))?'t':'f'; } } /*! * \brief save the detail and op in the database * */ function save() { try { if ($this->operation->save() == false ) return; $this->db->start(); // save the selling for ($i=0;$i<$this->operation->nb_item;$i++) { if ( ! isset ($this->{"poste".$i})) continue; $sql=sprintf('insert into op_predef_detail (opd_poste,opd_amount,'. 'opd_debit,od_id,opd_qc)'. ' values '. "('%s',%.2f,'%s',%d,'%s')", $this->{"poste".$i}, $this->{"amount".$i}, $this->{"ck".$i}, $this->operation->od_id, $this->{'isqc'.$i} ); $this->db->exec_sql($sql); } $this->db->commit(); } catch (Exception $e) { echo ($e->getMessage()); $this->db->rollback(); } } /*!\brief compute an array accordingly with the FormVenView function */ function compute_array() { $count=0; $a_op=$this->operation->load(); $array=$this->operation->compute_array($a_op); $array['desc']=$array['e_comm']; $p_array=$this->load(); if (empty($p_array)) return array(); foreach ($p_array as $row) { $tmp_array=array("qc_".$count=>'', "poste".$count=>'', "amount".$count=>$row['opd_amount'], 'ck'.$count=>$row['opd_debit'] ); if ( $row['opd_qc'] == 't' ) $tmp_array['qc_'.$count]=$row['opd_poste']; else $tmp_array['poste'.$count]=$row['opd_poste']; if ( $row['opd_debit'] == 'f' ) unset ($tmp_array['ck'.$count]); $array+=$tmp_array; $count++; } return $array; } /*!\brief load the data from the database and return an array * \return an array */ function load() { $sql="select opd_id,opd_poste,opd_amount,opd_debit,". " opd_qc from op_predef_detail where od_id=".$this->operation->od_id. " order by opd_id"; $res=$this->db->exec_sql($sql); $array=Database::fetch_all($res); return $array; } function set_od_id($p_id) { $this->operation->od_id=$p_id; } function display($p_array) { global $g_parameter, $g_user; require_once NOALYSS_INCLUDE.'/class_acc_ledger.php'; $legder=new Acc_Ledger($this->db,$this->jrn_def_id); $legder->nb=$legder->get_min_row(); if ($p_array != null) extract($p_array); $add_js = ""; $ret = ""; if ($g_user->check_action(FICADD) == 1) { /* Add button */ $f_add_button = new IButton('add_card'); $f_add_button->label = _('Créer une nouvelle fiche'); $f_add_button->set_attribute('ipopup', 'ipop_newcard'); $f_add_button->set_attribute('jrn', $legder->id); $f_add_button->javascript = " this.jrn=\$('p_jrn').value;select_card_type(this);"; $f_add_button->input(); } $nb_row = (isset($nb_item) ) ? $nb_item : $legder->nb; $ret.=HtmlInput::hidden('nb_item', $nb_row); $ret.=HtmlInput::hidden('p_jrn', $this->jrn_def_id); $ret.=dossier::hidden(); $ret.=dossier::hidden(); $ret.=HtmlInput::hidden('jrn_type', $legder->get_type()); $info = HtmlInput::infobulle(0); $info_poste = HtmlInput::infobulle(9); if ($g_user->check_action(FICADD) == 1) $ret.=$f_add_button->input(); $ret.='
Quickcode' . $info . ' | ' . '' . _('Poste') . $info_poste . ' | ' . '' . _('Libellé') . ' | ' . '' . _('Montant') . ' | ' . '' . _('Débit') . ' | ' . '
---|---|---|---|---|
' . $quick_code->input() . $quick_code->search() . ' | '; $ret.='' . $poste->input() . '' . ' | '; $ret.='' . $line_desc->input() . ' | '; $ret.='' . $amount->input() . ' | '; $ret.='' . $deb->input() . ' | '; $ret.='