/** * @covers Acc_Ledger::get_type * @todo Implement testGet_type(). */ public function testGet_type() { $this->object->id = 0; $type = $this->object->get_type(); $this->assertEquals('GL', $type); $this->object->id = 1; $type = $this->object->get_type(); $this->assertEquals('FIN', $type); $this->object->id = 2; $type = $this->object->get_type(); $this->assertEquals('VEN', $type); $this->object->id = 3; $type = $this->object->get_type(); $this->assertEquals('ACH', $type); }
public function __construct($p_cn, Acc_Ledger $p_jrn) { if ($p_cn == null) { die("No database connection. Abort."); } parent::__construct($p_cn, 'L', 'mm', 'A4'); $this->ledger = $p_jrn; $this->a_Tva = $this->ledger->existing_vat(); foreach ($this->a_Tva as $line_tva) { //initialize Amount TVA $tmp1 = $line_tva['tva_id']; $this->rap_tva[$tmp1] = 0; } $this->jrn_type = $p_jrn->get_type(); //---------------------------------------------------------------------- /* report * * get rappel to initialize amount rap_xx *the easiest way is to compute sum from quant_ */ $this->previous = $this->ledger->previous_amount($_GET['from_periode']); /* initialize the amount to report */ foreach ($this->previous['tva'] as $line_tva) { //initialize Amount TVA $tmp1 = $line_tva['tva_id']; $this->rap_tva[$tmp1] = $line_tva['sum_vat']; } $this->rap_htva = $this->previous['price']; $this->rap_tvac = $this->previous['price'] + $this->previous['vat']; $this->rap_priv = $this->previous['priv']; $this->rap_nd = $this->previous['tva_nd']; $this->rap_tva_np = $this->previous['tva_np']; }
function __construct($p_cn, Acc_Ledger $p_jrn) { parent::__construct($p_cn, 'P', 'mm', 'A4'); $this->ledger = $p_jrn; $this->jrn_type = $p_jrn->get_type(); // report from begin exercice $this->rap_amount = 0; // total page $this->tp_amount = 0; $amount = $this->ledger->previous_amount($_GET['from_periode']); $this->rap_amount = $amount['amount']; }
/** * This function create a ledger object and return the right one. * It uses the factory pattern * @param Database $p_cn * @param type $ledger_id * @return Acc_Ledger * @throws Exception */ function factory_Ledger(Database &$p_cn, $ledger_id) { include_once 'class_acc_ledger_sold.php'; include_once 'class_acc_ledger_purchase.php'; include_once 'class_acc_ledger_fin.php'; $ledger = new Acc_Ledger($p_cn, $ledger_id); $type = $ledger->get_type(); switch ($type) { case 'VEN': $obj = new Acc_Ledger_Sold($p_cn, $ledger_id); break; case 'ACH': $obj = new Acc_Ledger_Purchase($p_cn, $ledger_id); break; case 'FIN': $obj = new Acc_Ledger_Fin($p_cn, $ledger_id); break; case 'ODS': $obj = $ledger; break; default: throw new Exception('Ledger type not found'); } return $obj; }
/** *@brief retrieve data from the table QUANT_* *@return return an object or null if there is no * data from the QUANT table *@see Acc_Sold Acc_Purchase Acc_Fin Acc_Detail Acc_Misc */ function get_quant() { $ledger_id = $this->get_ledger(); if ($ledger_id == '') { throw new Exception(_('Journal non trouvé')); } $oledger = new Acc_Ledger($this->db, $ledger_id); // retrieve info from jrn_info switch ($oledger->get_type()) { case 'VEN': $ret = new Acc_Sold($this->db, $this->jr_id); break; case 'ACH': $ret = new Acc_Purchase($this->db, $this->jr_id); break; case 'FIN': $ret = new Acc_Fin($this->db, $this->jr_id); break; default: $ret = new Acc_Misc($this->db, $this->jr_id); break; } $ret->get(); if (empty($ret->det->array)) { $ret = new Acc_Misc($this->db, $this->jr_id); $ret->get(); } $ret->get_info(); return $ret; }
/** * Create an object Print_Ledger* depending on $p_type_export ( 0 => accounting * 1-> one row per operation 2-> detail of item) * @param type $cn * @param type $p_type_export * @param type $p_format_output CSV or PDF * @param Acc_Ledger $ledger */ static function factory(Database $cn, $p_type_export, $p_format_output, Acc_Ledger $p_ledger) { /** * For PDF output */ if ($p_format_output == 'PDF') { switch ($p_type_export) { case 0: //--------------------------------------------- // Detailled Printing (accounting ) //--------------------------------------------- return new Print_Ledger_Detail($cn, $p_ledger); break; case 1: //---------------------------------------------------------------------- // Simple Printing Purchase Ledger //--------------------------------------------------------------------- $own = new Own($cn); $jrn_type = $p_ledger->get_type(); if ($jrn_type == 'ACH' || $jrn_type == 'VEN') { if ($jrn_type == 'ACH' && $cn->get_value('select count(qp_id) from quant_purchase') == 0 || $jrn_type == 'VEN' && $cn->get_value('select count(qs_id) from quant_sold') == 0) { $pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger); $pdf->set_error(_('Ce journal ne peut être imprimé en mode simple')); return $pdf; } if ($own->MY_TVA_USE == 'Y') { $pdf = new Print_Ledger_Simple($cn, $p_ledger); return $pdf; } if ($own->MY_TVA_USE == 'N') { $pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger); return $pdf; } } if ($jrn_type == 'FIN') { $pdf = new Print_Ledger_Financial($cn, $p_ledger); return $pdf; } if ($jrn_type == 'ODS' || $p_ledger->id == 0) { $pdf = new Print_Ledger_Misc($cn, $p_ledger); return $pdf; } break; case 2: /********************************************************** * Print Detail Operation + Item ********************************************************** */ $own = new Own($cn); $jrn_type = $p_ledger->get_type(); if ($jrn_type == 'FIN') { $pdf = new Print_Ledger_Financial($cn, $p_ledger); return $pdf; } if ($jrn_type == 'ODS' || $p_ledger->id == 0) { $pdf = new Print_Ledger_Misc($cn, $p_ledger); return $pdf; } if ($jrn_type == 'ACH' && $cn->get_value('select count(qp_id) from quant_purchase') == 0 || $jrn_type == 'VEN' && $cn->get_value('select count(qs_id) from quant_sold') == 0) { $pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger); $pdf->set_error('Ce journal ne peut être imprimé en mode simple'); return $pdf; } $pdf = new Print_Ledger_Detail_Item($cn, $p_ledger); return $pdf; } // end switch } // end $p_format == PDF }
require_once NOALYSS_INCLUDE . '/class_database.php'; require_once NOALYSS_INCLUDE . '/class_impress.php'; require_once NOALYSS_INCLUDE . '/class_acc_ledger.php'; require_once NOALYSS_INCLUDE . '/class_own.php'; require_once NOALYSS_INCLUDE . '/class_periode.php'; require_once NOALYSS_INCLUDE . '/class_print_ledger.php'; $cn = new Database($gDossier); $periode = new Periode($cn); $l_type = "JRN"; $own = new Own($cn); $Jrn = new Acc_Ledger($cn, $_GET['jrn_id']); $Jrn->get_name(); $g_user->Check(); $g_user->check_dossier($gDossier); // Security if ($_GET['jrn_id'] != 0 && $g_user->check_jrn($_GET['jrn_id']) == 'X') { /* Cannot Access */ NoAccess(); } $ret = ""; $jrn_type = $Jrn->get_type(); $pdf = Print_Ledger::factory($cn, $_REQUEST['p_simple'], "PDF", $Jrn); $pdf->setDossierInfo($Jrn->name); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetAuthor('NOALYSS'); $pdf->setTitle(_("Journal"), true); $pdf->export(); $fDate = date('dmy-Hi'); $pdf->Output('journal-' . $fDate . '.pdf', 'D'); exit(0);
$r .= $q->input(); $r .= HtmlInput::submit('fs', _('Recherche'), "", "smallbutton"); $r .= '</span>'; $r .= dossier::hidden() . HtmlInput::hidden('op', 'fs'); $array = array(); foreach (array('query', 'inp', 'jrn', 'label', 'typecard', 'price', 'tvaid') as $i) { if (isset(${$i})) { $r .= HtmlInput::hidden($i, ${$i}); $sql_array[$i] = ${$i}; } } /* what is the type of the ledger */ $type = "GL"; if (isset($jrn) && $jrn > 1) { $ledger = new Acc_Ledger($cn, $jrn); $type = $ledger->get_type(); } $fiche = new Fiche($cn); /* Build the SQL and show result */ $sql = $fiche->build_sql($sql_array); if (strpos($sql, " in ()") != 0) { $html = HtmlInput::anchor_close('search_card'); $html .= '<div> ' . h2info(_('Recherche de fiche')) . '</div>'; $html .= '<h3 class="notice">'; $html .= _("Aucune catégorie de fiche ne correspond à" . " votre demande, le journal pourrait n'avoir accès à aucune fiche"); $html .= '</h3>'; break; } /* We limit the search to MAX_SEARCH_CARD records */ $sql = $sql . ' order by vw_name limit ' . MAX_SEARCH_CARD; $a = $cn->get_array($sql);
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; }
echo "<TD >" . $op['jr_pj_number'] . "</TD>"; if ($op['internal'] != '') { echo "<TD>" . HtmlInput::detail_op($op['jr_id'], $op['internal']) . "</TD>"; } else { echo td(); } echo "<TD >" . $op['poste'] . "</TD>" . "<TD >" . $op['description'] . "</TD>" . "<TD style=\"text-align:right\">" . nbm($op['deb_montant']) . "</TD>" . "<TD style=\"text-align:right\">" . nbm($op['cred_montant']) . "</TD>" . "</TR>"; } // end loop echo "</table>"; // show the saldo $solde = $Jrn->get_solde($_GET['from_periode'], $_GET['to_periode']); echo "solde débiteur:" . $solde[0] . "<br>"; echo "solde créditeur:" . $solde[1]; } elseif ($_GET['p_simple'] == 1) { if ($Jrn->get_type() != 'ACH' && $Jrn->get_type() != 'VEN') { // Simple printing //--- echo '<TABLE class="result">'; echo "<TR>" . "<th> operation </td>" . "<th>Date</th>" . "<th> n° de pièce </th>" . "<th>internal</th>" . th('Tiers') . "<th>Commentaire</th>" . "<th>Total opération</th>" . "</TR>"; // set a filter for the FIN $i = 0; $tot_amount = 0; bcscale(2); foreach ($Row as $line) { $i++; $class = $i % 2 == 0 ? ' class="even" ' : ' class="odd" '; echo "<tr {$class}>"; echo "<TD>" . $line['num'] . "</TD>"; echo "<TD>" . $line['date'] . "</TD>"; echo "<TD>" . h($line['jr_pj_number']) . "</TD>";