/** * @covers Acc_Ledger_Sold::input * @todo Implement testInput(). */ public function testInput() { $_REQUEST['ac'] = 'VEN'; $info = $this->object->input(); if (!is_string($info)) { $this->assertTrue(FALSE); } }
} } else { // warning because date is invalid echo '<p class="notice">' . _('Date invalide, opération non extournée') . '</p>'; } } echo $Ledger->button_new_operation(); echo '</div>'; return; } } // ------------------------------ /* Display a blank form or a form with predef operation */ // ------------------------------ $array = isset($_POST['correct']) || isset($correct) ? $_POST : null; $Ledger = new Acc_Ledger_Sold($cn, 0); // // pre defined operation // if (is_msie() == 0) { echo '<div style="position:absolute" class="content">'; } else { echo '<div class="content">'; } if (!isset($_REQUEST['p_jrn'])) { $def_ledger = $Ledger->get_first('ven', 2); if (empty($def_ledger)) { exit('Pas de journal disponible'); } $Ledger->id = $def_ledger['jrn_def_id']; } else {
NoAccess(); exit; } $Jrn = new Acc_Ledger($cn, $get_jrn); $Jrn->get_name(); $jrn_type = $Jrn->get_type(); // // With Detail per item which is possible only for VEN or ACH // if ($get_option == 2) { if ($jrn_type != 'ACH' && $jrn_type != 'VEN' || $Jrn->id == 0) { $get_option = 0; } else { switch ($jrn_type) { case 'VEN': $ledger = new Acc_Ledger_Sold($cn, $get_jrn); $ret_detail = $ledger->get_detail_sale($get_from_periode, $get_to_periode); $a_heading = Acc_Ledger_Sold::heading_detail_sale(); break; case 'ACH': $ledger = new Acc_Ledger_Purchase($cn, $get_jrn); $ret_detail = $ledger->get_detail_purchase($get_from_periode, $get_to_periode); $a_heading = Acc_Ledger_Purchase::heading_detail_purchase(); break; default: die(__FILE__ . ":" . __LINE__ . 'Journal invalide'); break; } if ($ret_detail == null) { return; }
static function test_me($p_string = '') { $cn = new Database(dossier::id()); $a = new Acc_Ledger_Sold($cn, 2); echo $a->input(); }
function display($p_array) { global $g_parameter, $g_user; if ($p_array != null) { extract($p_array); } require_once NOALYSS_INCLUDE . '/class_acc_ledger_sold.php'; $ledger = new Acc_Ledger_Sold($this->db, $this->jrn_def_id); $flag_tva = $g_parameter->MY_TVA_USE; /* Add button */ $f_add_button = new IButton('add_card'); $f_add_button->tabindex = -1; $f_add_button->label = _('Créer une nouvelle fiche'); $f_add_button->set_attribute('ipopup', 'ipop_newcard'); $f_add_button->set_attribute('jrn', $ledger->id); $f_add_button->javascript = "this.jrn=\$('p_jrn').value; select_card_type(this);"; $f_add_button2 = new IButton('add_card2'); $f_add_button2->tabindex = -1; $f_add_button2->label = _('Créer une nouvelle fiche'); $f_add_button2->set_attribute('ipopup', 'ipop_newcard'); $f_add_button2->set_attribute('filter', $ledger->get_all_fiche_def()); // $f_add_button2->set_attribute('jrn',$ledger->id); $f_add_button2->javascript = " this.jrn=\$('p_jrn').value;select_card_type(this);"; $str_add_button = ""; $str_add_button2 = ""; if ($g_user->check_action(FICADD) == 1) { $str_add_button = $f_add_button->input(); $str_add_button2 = $f_add_button2->input(); } $r = ''; $r .= dossier::hidden(); $f_legend = _('En-tête facture client'); /* if we suggest the next pj, then we need a javascript */ // Display the customer //-- $fiche = 'deb'; // Save old value and set a new one //-- $e_client = isset($e_client) ? $e_client : ""; $e_client_label = " "; //str_pad("",100,"."); // retrieve e_client_label //-- if (strlen(trim($e_client)) != 0) { $fClient = new Fiche($ledger->db); $fClient->get_by_qcode($e_client); $e_client_label = $fClient->strAttribut(ATTR_DEF_NAME) . ' ' . ' Adresse : ' . $fClient->strAttribut(ATTR_DEF_ADRESS) . ' ' . $fClient->strAttribut(ATTR_DEF_CP) . ' ' . $fClient->strAttribut(ATTR_DEF_CITY) . ' '; } $W1 = new ICard(); $W1->label = "Client " . HtmlInput::infobulle(0); $W1->name = "e_client"; $W1->tabindex = 3; $W1->value = $e_client; $W1->table = 0; $W1->set_dblclick("fill_ipopcard(this);"); $W1->set_attribute('ipopup', 'ipopcard'); // name of the field to update with the name of the card $W1->set_attribute('label', 'e_client_label'); // name of the field to update with the name of the card $W1->set_attribute('typecard', 'deb'); // Add the callback function to filter the card on the jrn $W1->set_callback('filter_card'); $W1->set_function('fill_data'); $W1->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $W1->name); $f_client_qcode = $W1->input(); $client_label = new ISpan(); $client_label->table = 0; $f_client = $client_label->input("e_client_label", $e_client_label); $f_client_bt = $W1->search(); // Record the current number of article $min = $ledger->get_min_row(); $p_article = isset($nb_item) ? $nb_item : $min; $max = $p_article < $min ? $min : $p_article; $e_comment = isset($e_comment) ? $e_comment : ""; $Hid = new IHidden(); $r .= $Hid->input("nb_item", $p_article); $f_legend_detail = _("Détail articles vendus"); // For each article //-- for ($i = 0; $i < $max; $i++) { // Code id, price & vat code //-- $march = isset(${"e_march{$i}"}) ? ${"e_march{$i}"} : ""; $march_price = isset(${"e_march" . $i . "_price"}) ? ${"e_march" . $i . "_price"} : ""; if ($flag_tva == 'Y') { $march_tva_id = isset(${"e_march{$i}" . "_tva_id"}) ? ${"e_march{$i}" . "_tva_id"} : ""; $march_tva_amount = isset(${"e_march{$i}" . "_tva_amount"}) ? ${"e_march{$i}" . "_tva_amount"} : ""; } $march_label = isset(${"e_march" . $i . "_label"}) ? ${"e_march" . $i . "_label"} : ""; // retrieve the tva label and name //-- if (strlen(trim($march)) != 0 && strlen(trim($march_label)) == 0) { $fMarch = new Fiche($ledger->db); $fMarch->get_by_qcode($march); $march_label = $fMarch->strAttribut(ATTR_DEF_NAME); if ($flag_tva == 'Y') { if (!isset(${"e_march{$i}" . "_tva_id"})) { $march_tva_id = $fMarch->strAttribut(ATTR_DEF_TVA); } } } // Show input //-- $W1 = new ICard(); $W1->label = ""; $W1->name = "e_march" . $i; $W1->value = $march; $W1->table = 1; $W1->set_attribute('typecard', 'cred'); $W1->set_dblclick("fill_ipopcard(this);"); $W1->set_attribute('ipopup', 'ipopcard'); // name of the field to update with the name of the card $W1->set_attribute('label', 'e_march' . $i . '_label'); // name of the field with the price $W1->set_attribute('price', 'e_march' . $i . '_price'); // name of the field with the TVA_ID $W1->set_attribute('tvaid', 'e_march' . $i . '_tva_id'); // Add the callback function to filter the card on the jrn $W1->set_callback('filter_card'); $W1->set_function('fill_data'); $W1->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $W1->name); $W1->readonly = false; $array[$i]['quick_code'] = $W1->input(); $array[$i]['bt'] = $W1->search(); // For computing we need some hidden field for holding the value $array[$i]['hidden'] = ''; if ($flag_tva == 'Y') { $array[$i]['hidden'] .= HtmlInput::hidden('tva_march' . $i, 0); } $htva = new INum('htva_march' . $i); $htva->readOnly = 1; $htva->value = 0; $array[$i]['htva'] = $htva->input(); if ($g_parameter->MY_TVA_USE == 'Y') { $tvac = new INum('tvac_march' . $i); } else { $tvac = new IHidden('tvac_march' . $i); } $tvac->readOnly = 1; $tvac->value = 0; $array[$i]['tvac'] = $tvac->input(); if ($g_parameter->MY_UPDLAB == 'Y') { $Span = new IText("e_march" . $i . "_label"); $Span->css_size = "100%"; } else { $Span = new ISpan("e_march" . $i . "_label"); } $Span->value = $march_label; $Span->setReadOnly(false); // card's name, price //-- $array[$i]['denom'] = $Span->input("e_march" . $i . "_label", $march_label); // price $Price = new INum(); $Price->setReadOnly(false); $Price->size = 9; $Price->javascript = "onBlur='format_number(this);clean_tva({$i});compute_ledger({$i})'"; $array[$i]['pu'] = $Price->input("e_march" . $i . "_price", $march_price); $array[$i]['tva'] = ''; $array[$i]['amount_tva'] = ''; // if tva is not needed then no tva field if ($flag_tva == 'Y') { // vat label //-- $Tva = new ITva_Popup($ledger->db); $Tva->in_table = true; $Tva->set_attribute('compute', $i); $Tva->js = 'onblur="format_number(this);clean_tva(' . $i . ');compute_ledger(' . $i . ')"'; $Tva->value = $march_tva_id; $array[$i]['tva'] = $Tva->input("e_march{$i}" . "_tva_id"); // vat amount //-- $wTva_amount = new INum(); $wTva_amount->readOnly = false; $wTva_amount->size = 6; $wTva_amount->javascript = "onBlur='format_number(this);compute_ledger({$i})'"; $array[$i]['amount_tva'] = $wTva_amount->input("e_march" . $i . "_tva_amount", $march_tva_amount); } // quantity //-- $quant = isset(${"e_quant{$i}"}) ? ${"e_quant{$i}"} : "1"; $Quantity = new INum(); $Quantity->setReadOnly(false); $Quantity->size = 8; $Quantity->javascript = "onChange='format_number(this);clean_tva({$i});compute_ledger({$i})'"; $array[$i]['quantity'] = $Quantity->input("e_quant" . $i, $quant); } // foreach article $f_type = _('Client'); ob_start(); require_once NOALYSS_INCLUDE . '/template/predf_ledger_detail.php'; $r .= ob_get_contents(); ob_end_clean(); // Set correctly the REQUEST param for jrn_type $r .= HtmlInput::hidden('jrn_type', 'VEN'); $r .= HtmlInput::button('add_item', _('Ajout article'), ' onClick="ledger_add_row()"'); return $r; }
/** *@brief export the ledger in PDF */ function export() { bcscale(2); $jrn_type = $this->ledger->get_type(); switch ($jrn_type) { case 'VEN': $ledger = new Acc_Ledger_Sold($this->cn, $this->ledger->jrn_def_id); $ret_detail = $ledger->get_detail_sale($_GET['from_periode'], $_GET['to_periode']); break; case 'ACH': $ledger = new Acc_Ledger_Purchase($this->cn, $this->ledger->jrn_def_id); $ret_detail = $ledger->get_detail_purchase($_GET['from_periode'], $_GET['to_periode']); break; default: die(__FILE__ . ":" . __LINE__ . 'Journal invalide'); break; } if ($ret_detail == null) { return; } $nb = Database::num_row($ret_detail); $this->SetFont('DejaVu', '', 6); $internal = ""; $this->SetFillColor(220, 221, 255); $high = 4; for ($i = 0; $i < $nb; $i++) { $row = Database::fetch_array($ret_detail, $i); if ($internal != $row['jr_internal']) { // Print the general info line width=270mm $this->LongLine(20, $high, $row['jr_date'], 1, 'L', true); $this->Cell(20, $high, $row['jr_internal'], 1, 0, 'L', true); $this->LongLine(50, $high, $row['quick_code'] . " " . $row['tiers_name'], 1, 'L', true); $this->LongLine(80, $high, $row['jr_comment'], 1, 'L', true); $this->Cell(20, $high, nbm($row['htva']), 1, 0, 'R', true); $this->Cell(20, $high, nbm($row['tot_tva_np']), 1, 0, 'R', true); $this->Cell(20, $high, "", 1, 0, 'R', true); $this->Cell(20, $high, nbm($row['tot_vat']), 1, 0, 'R', true); $sum = bcadd($row['htva'], $row['tot_vat']); $sum = bcsub($sum, $row['tot_tva_np']); $this->Cell(20, $high, nbm($sum), 1, 0, 'R', true); $internal = $row['jr_internal']; $this->Ln(6); // on the first line, the code for each column is displaid if ($this->show_col == true) { // // Header detail $this->LongLine(30, $high, 'QuickCode'); $this->Cell(30, $high, 'Poste'); $this->LongLine(70, $high, 'Libellé'); $this->Cell(20, $high, 'Prix/Unit', 0, 0, 'R'); $this->Cell(20, $high, 'Quant.', 0, 0, 'R'); $this->Cell(20, $high, 'HTVA', 0, 0, 'R'); $this->Cell(20, $high, 'TVA NP', 0, 0, 'R'); $this->Cell(20, $high, 'Code TVA'); $this->Cell(20, $high, 'TVA', 0, 0, 'R'); $this->Cell(20, $high, 'TVAC', 0, 0, 'R'); $this->Ln(6); $this->show_col = false; } } // Print detail sale / purchase $this->LongLine(30, $high, $row['j_qcode']); $this->Cell(30, $high, $row['j_poste']); $comment = $row['j_text'] == "" ? $row['item_name'] : $row['j_text']; $this->LongLine(70, $high, $comment); $this->Cell(20, $high, nbm($row['price_per_unit']), 0, 0, 'R'); $this->Cell(20, $high, nbm($row['quantity']), 0, 0, 'R'); $this->Cell(20, $high, nbm($row['price']), 0, 0, 'R'); $this->Cell(20, $high, nbm($row['vat_sided']), 0, 0, 'R'); $this->Cell(20, $high, $row['vat_code'] . " " . $row['tva_label']); $this->Cell(20, $high, nbm($row['vat']), 0, 0, 'R'); $sum = bcadd($row['price'], $row['vat']); $this->Cell(20, $high, nbm($sum), 0, 0, 'R'); $this->Ln(6); } }