/** * Insert a new ledger * @param type $array normally $_POST * @see verify_ledger */ function save_new($array) { $this->load(); extract($array); $this->jrn_def_id = -1; $this->jrn_def_name = $p_jrn_name; $this->jrn_def_ech_lib = $p_ech_lib; $this->jrn_def_max_line_deb = $p_jrn_deb_max_line; $this->jrn_def_type = $p_jrn_type; $this->jrn_def_pj_pref = $jrn_def_pj_pref; $this->jrn_def_fiche_deb = isset($FICHEDEB) ? join($FICHEDEB, ',') : ""; $this->jrn_deb_max_line = $min_row; $this->jrn_def_code = sprintf("%s%02d", trim(substr($this->jrn_def_type, 0, 1)), Acc_Ledger::next_number($this->db, $this->jrn_def_type)); $this->jrn_def_description = $p_description; switch ($this->jrn_def_type) { case 'ACH': case 'VEN': $this->jrn_def_fiche_cred = isset($FICHECRED) ? join($FICHECRED, ',') : ''; break; case 'ODS': $this->jrn_def_class_deb = $p_jrn_class_deb; $this->jrn_def_fiche_cred = null; break; case 'FIN': $a = new Fiche($this->db); $result = $a->get_by_qcode(trim(strtoupper($_POST['bank'])), false); $bank = $a->id; $this->jrn_def_bank = $bank; if ($result == -1) { throw new Exception(_("Aucun compte en banque n'est donné")); } $this->jrn_def_num_op = isset($numb_operation) ? 1 : 0; break; } parent::insert(); }