/** * @covers Acc_Account::set_parameter * @todo Implement testSet_parameter(). * @backupGlobals enabled */ public function testSet_parameter() { $this->object->set_parameter("value", 500); $value = $this->object->get_parameter("value"); $this->assertEquals($value, 500); }
$ctl = 'ok'; extract($_GET); //---------------------------------------------------------------------- // Modification //---------------------------------------------------------------------- $message = _("opération réussie"); if ($action == "update" && $acc_delete == 0) { // Check if the data are correct try { $p_val = trim($p_valu); $p_lib = trim($p_libu); $p_parent = trim($p_parentu); $old_line = trim($p_oldu); $p_type = htmlentities($p_typeu); $acc = new Acc_Account($cn); $acc->set_parameter('libelle', $p_lib); $acc->set_parameter('value', $p_val); $acc->set_parameter('parent', $p_parent); $acc->set_parameter('type', $p_type); $acc->check(); } catch (Exception $e) { $message = _("Valeurs invalides, pas de changement") . " \n " . $e->getMessage(); $ctl = 'nok'; } if (strlen($p_val) != 0 && strlen($p_lib) != 0 && strlen($old_line) != 0) { if (strlen($p_val) == 1) { $p_parent = 0; } else { if (strlen($p_parent) == 0) { $p_parent = substr($p_val, 0, strlen($p_val) - 1); }
// not set } $action = 'new'; $val = new IText('p_valu'); $parent = new IText('p_parentu'); $lib = new IText('p_libu'); $lib->css_size = "100%"; $type = new ISelect('p_typeu'); $type->value = Acc_Account::$type; if ($pcmn_val != "") { $action = 'update'; /* * Not empty, show the default value */ $account = new Acc_Account($cn); $account->set_parameter('value', $pcmn_val); $account->load(); $val->value = $account->get_parameter('value'); $parent->value = $account->get_parameter('parent'); $lib->value = $account->get_parameter('libelle'); $type->selected = $account->get_parameter('type'); } require 'template/pcmn_update.php'; $response = ob_get_clean(); $html = escape_xml($response); if (headers_sent()) { echo $response; echo $html; } else { header('Content-type: text/xml; charset=UTF-8'); echo <<<EOF
/** * @brief Show the form to encode your operation * @param$p_array if you correct or use a predef operation (default = null) * @param$p_readonly 1 for readonly 0 for writable (default 0) *@exception if ledger not found * \return a string containing the form */ function input($p_array = null, $p_readonly = 0) { global $g_parameter, $g_user; $this->nb = $this->get_min_row(); if ($p_readonly == 1) { return $this->confirm($p_array); } if ($p_array != null) { extract($p_array); } $add_js = ""; if ($g_parameter->MY_PJ_SUGGEST == 'Y') { $add_js = "update_pj();"; } if ($g_parameter->MY_DATE_SUGGEST == 'Y') { $add_js .= 'get_last_date();'; } $add_js .= 'update_row("quick_item");'; $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', $this->id); $f_add_button->javascript = " this.jrn=\$('p_jrn').value;select_card_type(this);"; $f_add_button->input(); } $wLedger = $this->select_ledger('ODS', 2); if ($wLedger == null) { throw new Exception(_('Pas de journal disponible')); } $wLedger->javascript = "onChange='update_name();update_predef(\"ods\",\"t\",\"" . $_REQUEST['ac'] . "\");{$add_js}'"; $label = " Journal " . HtmlInput::infobulle(2); $ret .= $label . $wLedger->input(); // Load the javascript // $ret .= "<table>"; $ret .= '<tr ><td colspan="2" style="width:auto">'; $wDate = new IDate('e_date'); $wDate->readonly = $p_readonly; $e_date = isset($e_date) && trim($e_date) != '' ? $e_date : ''; $wDate->value = $e_date; $ret .= _("Date") . ' : ' . $wDate->input(); $ret .= '</td>'; /* insert periode if needed */ // Periode //-- if ($this->check_periode() == true) { $l_user_per = $g_user->get_periode(); $def = isset($periode) ? $periode : $l_user_per; $period = new IPeriod("period"); $period->user = $g_user; $period->cn = $this->db; $period->value = $def; $period->type = OPEN; try { $l_form_per = $period->input(); } catch (Exception $e) { if ($e->getCode() == 1) { echo _("Aucune période ouverte"); exit; } } $label = HtmlInput::infobulle(3); $f_periode = _("Période comptable") . " {$label} " . $l_form_per; $ret .= td($f_periode); } $wPJ = new IText('e_pj'); $wPJ->readonly = false; $wPJ->size = 10; /* suggest PJ ? */ $default_pj = ''; if ($g_parameter->MY_PJ_SUGGEST == 'Y') { $default_pj = $this->guess_pj(); } $wPJ->value = isset($e_pj) ? $e_pj : $default_pj; $ret .= '</tr>'; $ret .= '<tr >'; $ret .= '<td colspan="2" style="width:auto"> ' . _('Pièce') . ' : ' . $wPJ->input(); $ret .= HtmlInput::hidden('e_pj_suggest', $default_pj); $ret .= '</tr>'; $ret .= '</td>'; $ret .= '<tr>'; $ret .= '<td colspan="2" style="width:auto">'; $ret .= _('Libellé'); $wDescription = new IText('desc'); $wDescription->readonly = $p_readonly; $wDescription->size = "50"; $wDescription->value = isset($desc) ? $desc : ''; $ret .= $wDescription->input(); $ret .= '</td>'; $ret .= '</tr>'; $ret .= '</table>'; $nb_row = isset($nb_item) ? $nb_item : $this->nb; $ret .= HtmlInput::hidden('nb_item', $nb_row); $ret .= dossier::hidden(); $ret .= dossier::hidden(); $ret .= HtmlInput::hidden('jrn_type', $this->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="position:float;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); // 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->value = isset(${'qc_' . $i}) ? ${'qc_' . $i} : ""; $quick_code->readonly = $p_readonly; $label = ''; if ($quick_code->value != '') { $Fiche = new Fiche($this->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', $this->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(); $poste->readonly = $p_readonly; if ($poste->value != '') { $Poste = new Acc_Account($this->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->readonly = $p_readonly; $amount->javascript = ' onChange="format_number(this);checkTotalDirect()"'; // D/C $deb = new ICheckBox(); $deb->name = 'ck' . $i; $deb->selected = isset(${'ck' . $i}) ? true : false; $deb->readonly = $p_readonly; $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>'; if (isset($this->with_concerned) && $this->with_concerned == true) { $oRapt = new Acc_Reconciliation($this->db); $w = $oRapt->widget(); $w->name = 'jrn_concerned'; $w->value = isset($jrn_concerned) ? $jrn_concerned : ""; $ret .= "Réconciliation/rapprochements : " . $w->input(); } $ret .= create_script("\$('" . $wDate->id . "').focus()"); return $ret; }
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 .= '<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; }