noalyss
Version-6.7.2
|
concerns the predefined operation for the operation from 'Ecriture direct' More...
Public Member Functions | |
compute_array () | |
compute an array accordingly with the FormVenView function | |
display ($p_array) | |
get_post () | |
load () | |
load the data from the database and return an array | |
Pre_Op_Advanced ($cn) | |
save () | |
save the detail and op in the database | |
set_od_id ($p_id) | |
Data Fields | |
$op |
concerns the predefined operation for the operation from 'Ecriture direct'
Definition at line 30 of file class_pre_op_advanced.php.
compute an array accordingly with the FormVenView function
Definition at line 96 of file class_pre_op_advanced.php.
References $array, $count, $p_array, $row, and load().
{ $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; }
Pre_Op_Advanced::display | ( | $ | p_array | ) |
Definition at line 144 of file class_pre_op_advanced.php.
References $amount, $deb, $Fiche, $g_parameter, $g_user, $label, $p_array, $poste, $quick_code, $ret, db, HtmlInput\hidden(), Dossier\id(), HtmlInput\infobulle(), table, td(), tr(), trim(), and value.
{ global $g_parameter, $g_user; require_once '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.='<table id="quick_item" style="width:100%">'; $ret.='<tr>' . '<th style="text-align:left">Quickcode' . $info . '</th>' . '<th style="text-align:left">' . _('Poste') . $info_poste . '</th>' . '<th style="text-align:left">' . _('Libellé') . '</th>' . '<th style="text-align:left">' . _('Montant') . '</th>' . '<th style="text-align:left">' . _('Débit') . '</th>' . '</tr>'; for ($i = 0; $i < $nb_row; $i++) { // Quick Code $quick_code = new ICard('qc_' . $i); $quick_code->set_dblclick("fill_ipopcard(this);"); $quick_code->set_attribute('ipopup', 'ipopcard'); // name of the field to update with the name of the card $quick_code->set_attribute('label', "ld" . $i); $quick_code->set_attribute('jrn', $legder->id); // name of the field to update with the name of the card $quick_code->set_attribute('typecard', 'filter'); // Add the callback function to filter the card on the jrn $quick_code->set_callback('filter_card'); $quick_code->set_function('fill_data'); $quick_code->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $quick_code->name); $quick_code->jrn = $legder->id; $quick_code->value = (isset(${'qc_' . $i})) ? ${'qc_' . $i} : ""; $label = ''; if ($quick_code->value != '') { $Fiche = new Fiche($legder->db); $Fiche->get_by_qcode($quick_code->value); $label = $Fiche->strAttribut(ATTR_DEF_NAME); } // Account $poste = new IPoste(); $poste->name = 'poste' . $i; $poste->set_attribute('jrn', $legder->id); $poste->set_attribute('ipopup', 'ipop_account'); $poste->set_attribute('label', 'ld' . $i); $poste->set_attribute('account', 'poste' . $i); $poste->set_attribute('dossier', Dossier::id()); $poste->value = (isset(${'poste' . $i})) ? ${"poste" . $i} : '' ; $poste->dbl_click_history(); if ($poste->value != '') { $Poste = new Acc_Account($legder->db); $Poste->set_parameter('value', $poste->value); $label = $Poste->get_lib(); } // Description of the line $line_desc = new IText(); $line_desc->name = 'ld' . $i; $line_desc->size = 30; $line_desc->value = (isset(${"ld" . $i})) ? ${"ld" . $i} : $label; // Amount $amount = new INum(); $amount->size = 10; $amount->name = 'amount' . $i; $amount->value = (isset(${'amount' . $i})) ? ${"amount" . $i} : '' ; $amount->javascript = ' onChange="format_number(this);checkTotalDirect()"'; // D/C $deb = new ICheckBox(); $deb->name = 'ck' . $i; $deb->selected = (isset(${'ck' . $i})) ? true : false; $deb->javascript = ' onChange="checkTotalDirect()"'; $ret.='<tr>'; $ret.='<td>' . $quick_code->input() . $quick_code->search() . '</td>'; $ret.='<td>' . $poste->input() . '<script> document.getElementById(\'poste' . $i . '\').onblur=function(){ if (trim(this.value) !=\'\') {document.getElementById(\'qc_' . $i . '\').value="";}}</script>' . '</td>'; $ret.='<td>' . $line_desc->input() . '</td>'; $ret.='<td>' . $amount->input() . '</td>'; $ret.='<td>' . $deb->input() . '</td>'; $ret.='</tr>'; // If readonly == 1 then show CA } $ret.='</table>'; return $ret; }
Reimplemented from Pre_operation_detail.
Definition at line 38 of file class_pre_op_advanced.php.
References trim().
{ parent::get_post(); extract($_POST); for ($i=0;$i<$this->operation->nb_item;$i++) { if ( ! isset ($_POST['poste'.$i]) && ! isset ($_POST['qc_'.$i])) continue; $this->{'poste'.$i}=(trim($_POST['qc_'.$i]) != "" )?$_POST['qc_'.$i]:$_POST['poste'.$i]; $this->{'isqc'.$i}=(trim($_POST['qc_'.$i]) != "")?'t':'f'; $this->{"amount".$i}=$_POST['amount'.$i]; $this->{"ck".$i}=(isset($_POST['ck'.$i]))?'t':'f'; } }
load the data from the database and return an array
Definition at line 131 of file class_pre_op_advanced.php.
References $array, $res, $sql, db, and Database\fetch_all().
Referenced by compute_array().
Pre_Op_Advanced::Pre_Op_Advanced | ( | $ | cn | ) |
Definition at line 33 of file class_pre_op_advanced.php.
References $cn, and Pre_operation_detail\__construct().
{ parent::__construct($cn); $this->operation->od_direct='t'; }
save the detail and op in the database
Definition at line 59 of file class_pre_op_advanced.php.
References $e, $sql, db, echo, and false.
{ try { $this->db->start(); if ($this->operation->save() == false ) return; // 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); } } catch (Exception $e) { echo ($e->getMessage()); $this->db->rollback(); } }
Pre_Op_Advanced::set_od_id | ( | $ | p_id | ) |
Definition at line 140 of file class_pre_op_advanced.php.
{ $this->operation->od_id=$p_id; }
Pre_Op_Advanced::$op |
Definition at line 32 of file class_pre_op_advanced.php.