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']; }
require_once NOALYSS_INCLUDE . '/class_dossier.php'; $gDossier = dossier::id(); require_once NOALYSS_INCLUDE . '/class_pdf.php'; require_once NOALYSS_INCLUDE . '/class_user.php'; require_once NOALYSS_INCLUDE . '/ac_common.php'; 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');
*/ if (!defined('ALLOWED')) { die('Appel direct ne sont pas permis'); } require_once NOALYSS_INCLUDE . '/class_icheckbox.php'; require_once NOALYSS_INCLUDE . '/class_acc_ledger.php'; require_once NOALYSS_INCLUDE . '/class_acc_reconciliation.php'; require_once NOALYSS_INCLUDE . '/ac_common.php'; require_once NOALYSS_INCLUDE . '/class_periode.php'; require_once NOALYSS_INCLUDE . '/function_javascript.php'; require_once NOALYSS_INCLUDE . '/class_ipopup.php'; global $g_user; $cn = new Database(dossier::id()); $id_predef = isset($_REQUEST['p_jrn_predef']) ? $_REQUEST['p_jrn_predef'] : -1; $id_ledger = isset($_REQUEST['p_jrn']) ? $_REQUEST['p_jrn'] : $id_predef; $ledger = new Acc_Ledger($cn, $id_ledger); $first_ledger = $ledger->get_first('ODS'); if (empty($first_ledger)) { exit('Pas de journal disponible'); } $ledger->id = $ledger->id == -1 ? $first_ledger['jrn_def_id'] : $id_ledger; /**\brief show a form for quick_writing */ $def = -1; $ledger->with_concerned = true; if ($g_user->check_jrn($ledger->id) == 'X') { NoAccess(); exit - 1; } $p_msg = ""; if (!isset($_POST['summary']) && !isset($_POST['save'])) { require 'operation_ods_new.inc.php';
* * You should have received a copy of the GNU General Public License * along with NOALYSS; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Copyright Author Dany De Bontridder danydb@aevalys.eu /*!\file * \brief history of the accountancy exported in CSV */ if (!defined('ALLOWED')) { die('Appel direct ne sont pas permis'); } header('Pragma: public'); header('Content-type: application/csv'); header('Content-Disposition: attachment;filename="histo-export.csv"', FALSE); $ledger = new Acc_Ledger($cn, 0); list($sql, $where) = $ledger->build_search_sql($_GET); $order = " order by jr_date_order asc,substring(jr_pj_number,'[0-9]+\$')::numeric asc "; $res = $cn->get_array($sql . $order); printf('"%s";', "Internal"); printf('"%s";', "Journal"); printf('"%s";', "Date"); printf('"%s";', "Echeance"); printf('"%s";', "Paiement"); printf('"%s";', "Piece"); printf('"%s";"";', "Tiers"); printf('"%s";', "Description"); printf('"%s";', "Note"); printf('"%s"', "Montant opération"); printf("\r\n"); for ($i = 0; $i < count($res); $i++) {
// Copyright Author Dany De Bontridder danydb@aevalys.eu /*!\file * * * \brief to write into the ledgers ODS a new operation */ if (!defined('ALLOWED')) { die('Appel direct ne sont pas permis'); } require_once NOALYSS_INCLUDE . '/class_pre_op_ods.php'; require_once NOALYSS_INCLUDE . '/class_iconcerned.php'; global $g_user, $g_parameter; $cn = new Database(dossier::id()); $id_predef = isset($_REQUEST['p_jrn_predef']) ? $_REQUEST['p_jrn_predef'] : -1; $id_ledger = isset($_REQUEST['p_jrn']) ? $_REQUEST['p_jrn'] : $id_predef; $ledger = new Acc_Ledger($cn, $id_ledger); $first_ledger = $ledger->get_first('ODS'); $ledger->id = $ledger->id == -1 ? $first_ledger['jrn_def_id'] : $id_ledger; // check if we can write in the ledger if ($g_user->check_jrn($ledger->id) == 'X') { alert(_("Vous ne pouvez pas écrire dans ce journal, contacter votre administrateur")); return; } echo '<div style="position:absolute" class="content">'; echo '<div id="predef_form">'; echo HtmlInput::hidden('p_jrn_predef', $ledger->id); $op = new Pre_op_ods($cn); $op->set('ledger', $ledger->id); $op->set('ledger_type', "ODS"); $op->set('direct', 't'); $url = http_build_query(array('action' => 'use_opd', 'p_jrn_predef' => $ledger->id, 'ac' => $_REQUEST['ac'], 'gDossier' => dossier::id()));
<?php /* * This file is part of NOALYSS. * * NOALYSS is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * NOALYSS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NOALYSS; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Copyright Author Dany De Bontridder danydb@aevalys.eu /** * @file * @brief refresh the area with payment method * -l for the ledger */ if (!defined('ALLOWED')) { die('Appel direct ne sont pas permis'); } require_once NOALYSS_INCLUDE . '/class_acc_ledger.php'; $ledger = new Acc_Ledger($cn, $l); echo $ledger->input_paid(1);
/** *@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; }
*/ if (!defined('ALLOWED')) { die('Appel direct ne sont pas permis'); } require_once NOALYSS_INCLUDE . '/class_dossier.php'; require_once NOALYSS_INCLUDE . '/ac_common.php'; require_once NOALYSS_INCLUDE . '/class_acc_ledger.php'; $gDossier = dossier::id(); require_once NOALYSS_INCLUDE . '/class_database.php'; /* Admin. Dossier */ $cn = new Database($gDossier); require_once NOALYSS_INCLUDE . '/class_user.php'; // display a search box $base = basename($_SERVER['SCRIPT_NAME']); $inside = false; $ledger = new Acc_Ledger($cn, 0); $ledger->type = 'ALL'; if (isset($_GET['amount_id'])) { put_global(array(array("key" => 'amount_min', 'value' => $_GET['amount_id']), array("key" => 'amount_max', 'value' => $_GET['amount_id']))); } $search_box = $ledger->search_form('ALL', 1, 'search_op'); if ($base == 'recherche.php' || $base == 'do.php') { echo '<div class="content" >'; echo '<form method="GET">'; } else { $div = 'search_op'; $action = ""; $callback = ""; echo HtmlInput::title_box(_('Recherche'), $div); echo '<form name="search_form_ajx" id="search_form_ajx" onsubmit="search_operation(this);return false">'; echo HtmlInput::get_to_hidden(array('ctlc', 'ledger', 'target'));
$html .= HtmlInput::submit('x', 'accepter'); $html .= HtmlInput::button_close($div); $html .= '</form>'; break; //////////////////////////////////////////////////////////////////////////// // Reverse an operation //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // Reverse an operation //////////////////////////////////////////////////////////////////////////// case 'reverseop': if ($access == 'W') { ob_start(); try { $cn->start(); $oLedger = new Acc_Ledger($cn, $ledger); $oLedger->jr_id = $_REQUEST['jr_id']; $oLedger->reverse($_REQUEST['ext_date']); $cn->commit(); echo _("Opération extournée"); } catch (Exception $e) { $e->getMessage(); $cn->rollback(); } } $html = ob_get_contents(); ob_end_clean(); break; } $html = escape_xml($html); if (!headers_sent()) {
//--- Check validity if ($get_jrn == -1 || $get_option == -1 || $get_from_periode == null || $get_to_periode == null) { die(_('Options invalides')); } require_once NOALYSS_INCLUDE . '/class_user.php'; $g_user->Check(); $g_user->check_dossier($gDossier); //---------------------------------------------------------------------------- // $get_jrn == 0 when request for all ledger, in that case, we must filter // the legder with the security in Acc_Ledger::get_row //---------------------------------------------------------------------------- if ($get_jrn != 0 && $g_user->check_jrn($get_jrn) == 'X') { 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;
$w->selected = isset($_GET['p_simple']) ? $_GET['p_simple'] : ''; echo '<td>Style d\'impression ' . HtmlInput::infobulle(32) . '</td>' . $w->input('p_simple', $a); print "</TR>"; echo '</TABLE>'; print HtmlInput::submit('bt_html', 'Visualisation'); echo '</FORM>'; echo '<hr>'; //----------------------------------------------------- // If print is asked // First time in html // after in pdf or cvs //----------------------------------------------------- if (isset($_REQUEST['bt_html'])) { require_once NOALYSS_INCLUDE . '/class_acc_ledger.php'; $d = var_export($_GET, true); $Jrn = new Acc_Ledger($cn, $_GET['jrn_id']); $Jrn->get_name(); switch ($_GET['p_simple']) { case "0": $Row = $Jrn->get_row($_GET['from_periode'], $_GET['to_periode']); break; case "1": $Row = $Jrn->get_rowSimple($_GET['from_periode'], $_GET['to_periode']); break; case "2": $Row = $Jrn->get_rowSimple($_GET['from_periode'], $_GET['to_periode']); break; default: var_dump($_GET['p_simple']); die(__FILE__ . ":" . __LINE__ . " error unknown style "); }
public function insert($p_array = null) { global $g_parameter; extract($p_array); $this->verify($p_array); $group = $this->db->get_next_seq("s_oa_group"); /* for analytic */ $seq = $this->db->get_next_seq('s_grpt'); $this->id = $p_jrn; $internal = $this->compute_internal_code($seq); $this->internal = $internal; $oPeriode = new Periode($this->db); $check_periode = $this->check_periode(); if ($check_periode == true) { $tperiode = $period; } else { $tperiode = $oPeriode->find_periode($e_date); } $cust = new Fiche($this->db); $cust->get_by_qcode($e_client); $sposte = $cust->strAttribut(ATTR_DEF_ACCOUNT); // if 2 accounts, take only the debit one for the customer // if (strpos($sposte, ',') != 0) { $array = explode(',', $sposte); $poste = $array[0]; } else { $poste = $sposte; } bcscale(4); try { $tot_amount = 0; $tot_tva = 0; $tot_debit = 0; $this->db->start(); $tva = array(); /* Save all the items without vat */ for ($i = 0; $i < $nb_item; $i++) { $n_both = 0; if (strlen(trim(${'e_march' . $i})) == 0) { continue; } /* First we save all the items without vat */ $fiche = new Fiche($this->db); $fiche->get_by_qcode(${"e_march" . $i}); $amount = bcmul(${'e_march' . $i . '_price'}, ${'e_quant' . $i}); $tot_amount = round(bcadd($tot_amount, $amount), 2); $acc_operation = new Acc_Operation($this->db); $acc_operation->date = $e_date; $sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT); // if 2 accounts, take only the credit one if (strpos($sposte, ',') != 0) { $array = explode(',', $sposte); $poste_val = $array[1]; } else { $poste_val = $sposte; } $acc_operation->poste = $poste_val; $acc_operation->amount = $amount; $acc_operation->grpt = $seq; $acc_operation->jrn = $p_jrn; $acc_operation->type = 'c'; $acc_operation->periode = $tperiode; if ($g_parameter->MY_UPDLAB == 'Y') { $acc_operation->desc = strip_tags(${"e_march" . $i . "_label"}); } else { $acc_operation->desc = null; } $acc_operation->qcode = ${"e_march" . $i}; if ($amount < 0) { $tot_debit = bcadd($tot_debit, abs($amount)); } $j_id = $acc_operation->insert_jrnx(); if ($g_parameter->MY_TVA_USE == 'Y') { /* Compute sum vat */ $oTva = new Acc_Tva($this->db); $idx_tva = ${'e_march' . $i . '_tva_id'}; $tva_item = ${'e_march' . $i . '_tva_amount'}; $oTva->set_parameter("id", $idx_tva); $oTva->load(); /* if empty then we need to compute it */ if (trim($tva_item) == '' || ${'e_march' . $i . '_tva_amount'} == 0) { /* retrieve tva */ $l = new Acc_Tva($this->db, $idx_tva); $l->load(); $tva_item = bcmul($amount, $l->get_parameter('rate')); } if (isset($tva[$idx_tva])) { $tva[$idx_tva] += $tva_item; } else { $tva[$idx_tva] = $tva_item; } if ($oTva->get_parameter("both_side") == 0) { $tot_tva = round(bcadd($tva_item, $tot_tva), 2); } else { $n_both = $tva_item; if ($n_both < 0) { $tot_debit = bcadd($tot_debit, abs($n_both)); } } } /* Save the stock */ /* if the quantity is < 0 then the stock increase (return of * material) */ $nNeg = ${"e_quant" . $i} < 0 ? -1 : 1; // always save quantity but in withStock we can find // what card need a stock management if ($g_parameter->MY_STOCK = 'Y' && isset($repo)) { $dir = ${'e_quant' . $i} < 0 ? 'd' : 'c'; Stock_Goods::insert_goods($this->db, array('j_id' => $j_id, 'goods' => ${'e_march' . $i}, 'quant' => $nNeg * ${'e_quant' . $i}, 'dir' => $dir, 'repo' => $repo)); } if ($g_parameter->MY_ANALYTIC != "nu") { // for each item, insert into operation_analytique */ $op = new Anc_Operation($this->db); $op->oa_group = $group; $op->j_id = $j_id; $op->oa_date = $e_date; $op->oa_debit = 'f'; $op->oa_description = sql_string($e_comm); $op->save_form_plan($_POST, $i, $j_id); } if ($g_parameter->MY_TVA_USE == 'Y') { /* save into quant_sold */ $r = $this->db->exec_sql("select insert_quant_sold (\$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9)", array(null, $j_id, ${'e_march' . $i}, ${'e_quant' . $i}, round($amount, 2), $tva_item, $idx_tva, $e_client, $n_both)); } else { $r = $this->db->exec_sql("select insert_quant_sold (\$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9) ", array(null, $j_id, ${'e_march' . $i}, ${'e_quant' . $i}, $amount, 0, null, $e_client, 0)); } // if ( $g_parameter->MY_TVA_USE=='Y') { } // end loop : save all items /* save total customer */ $cust_amount = bcadd($tot_amount, $tot_tva); $acc_operation = new Acc_Operation($this->db); $acc_operation->date = $e_date; $acc_operation->poste = $poste; $acc_operation->amount = $cust_amount; $acc_operation->grpt = $seq; $acc_operation->jrn = $p_jrn; $acc_operation->type = 'd'; $acc_operation->periode = $tperiode; $acc_operation->qcode = ${"e_client"}; if ($cust_amount > 0) { $tot_debit = bcadd($tot_debit, $cust_amount); } $let_tiers = $acc_operation->insert_jrnx(); /** save all vat * $i contains the tva_id and value contains the vat amount * if if ($g_parameter->MY_TVA_USE == 'Y' ) */ if ($g_parameter->MY_TVA_USE == 'Y') { foreach ($tva as $i => $value) { $oTva = new Acc_Tva($this->db); $oTva->set_parameter('id', $i); $oTva->load(); $poste_vat = $oTva->get_side('c'); $cust_amount = bcadd($tot_amount, $tot_tva); $acc_operation = new Acc_Operation($this->db); $acc_operation->date = $e_date; $acc_operation->poste = $poste_vat; $acc_operation->amount = $value; $acc_operation->grpt = $seq; $acc_operation->jrn = $p_jrn; $acc_operation->type = 'c'; $acc_operation->periode = $tperiode; if ($value < 0) { $tot_debit = bcadd($tot_debit, abs($value)); } $acc_operation->insert_jrnx(); // if TVA is on both side, we deduce it immediately if ($oTva->get_parameter("both_side") == 1) { $poste_vat = $oTva->get_side('d'); $cust_amount = bcadd($tot_amount, $tot_tva); $acc_operation = new Acc_Operation($this->db); $acc_operation->date = $e_date; $acc_operation->poste = $poste_vat; $acc_operation->amount = $value; $acc_operation->grpt = $seq; $acc_operation->jrn = $p_jrn; $acc_operation->type = 'd'; $acc_operation->periode = $tperiode; $acc_operation->insert_jrnx(); $tot_debit = bcadd($tot_debit, $value); $n_both = $value; } } } // if ($g_parameter->MY_TVA_USE=='Y') /* insert into jrn */ $acc_operation = new Acc_Operation($this->db); $acc_operation->date = $e_date; $acc_operation->echeance = $e_ech; $acc_operation->amount = abs(round($tot_debit, 2)); $acc_operation->desc = $e_comm; $acc_operation->grpt = $seq; $acc_operation->jrn = $p_jrn; $acc_operation->periode = $tperiode; $acc_operation->pj = $e_pj; $acc_operation->mt = $mt; $this->jr_id = $acc_operation->insert_jrn(); $this->pj = $acc_operation->set_pj(); /* * = e_pj then do not increment sequence */ /* and e_pj is not null */ if (strcmp($e_pj, $e_pj_suggest) == 0 && strlen(trim($e_pj)) != 0) { $this->inc_seq_pj(); } $this->db->exec_sql("update jrn set jr_internal='" . $internal . "' where " . " jr_grpt_id = " . $seq); /* update quant_sold */ $this->db->exec_sql('update quant_sold set qs_internal = $1 where j_id in (select j_id from jrnx where j_grpt=$2)', array($internal, $seq)); /* Save the attachment or generate doc */ if (isset($_FILES['pj'])) { if (strlen(trim($_FILES['pj']['name'])) != 0) { $this->db->save_upload_document($seq); } else { /* Generate an invoice and save it into the database */ if (isset($_POST['gen_invoice'])) { $file = $this->create_document($internal, $p_array); $this->doc = '<A class="line" HREF="show_pj.php?' . dossier::get() . '&jr_grpt_id=' . $seq . '&jrn=' . $this->id . '">' . $file . '</A>'; } } } //---------------------------------------- // Save the payer //---------------------------------------- if ($e_mp != 0) { /* mp */ $mp = new Acc_Payment($this->db, $e_mp); $mp->load(); /* fiche */ $fqcode = ${'e_mp_qcode_' . $e_mp}; $acfiche = new Fiche($this->db); $acfiche->get_by_qcode($fqcode); /* jrnx */ $acseq = $this->db->get_next_seq('s_grpt'); $acjrn = new Acc_Ledger($this->db, $mp->get_parameter('ledger_target')); $acinternal = $acjrn->compute_internal_code($acseq); /* Insert paid by */ $acc_pay = new Acc_Operation($this->db); $acc_pay->date = $e_date; /* get the account and explode if necessary */ $sposte = $acfiche->strAttribut(ATTR_DEF_ACCOUNT); // if 2 accounts, take only the debit one for customer if (strpos($sposte, ',') != 0) { $array = explode(',', $sposte); $poste_val = $array[0]; } else { $poste_val = $sposte; } $famount = bcsub($cust_amount, $acompte); $acc_pay->poste = $poste_val; $acc_pay->qcode = $fqcode; $acc_pay->amount = abs(round($famount, 2)); $acc_pay->desc = null; $acc_pay->grpt = $acseq; $acc_pay->jrn = $mp->get_parameter('ledger_target'); $acc_pay->periode = $tperiode; $acc_pay->type = $famount >= 0 ? 'd' : 'c'; $acc_pay->insert_jrnx(); /* Insert supplier */ $acc_pay = new Acc_Operation($this->db); $acc_pay->date = $e_date; $acc_pay->poste = $poste; $acc_pay->qcode = $e_client; $acc_pay->amount = abs(round($famount, 2)); $acc_pay->desc = null; $acc_pay->grpt = $acseq; $acc_pay->jrn = $mp->get_parameter('ledger_target'); $acc_pay->periode = $tperiode; $acc_pay->type = $famount >= 0 ? 'c' : 'd'; $let_other = $acc_pay->insert_jrnx(); /* insert into jrn */ $acc_pay->mt = $mt; $acjrn->grpt_id = $acseq; $acc_pay->desc = !isset($e_comm_paiement) || strlen(trim($e_comm_paiement)) == 0 ? $e_comm : $e_comm_paiement; $mp_jr_id = $acc_pay->insert_jrn(); $acjrn->update_internal_code($acinternal); $r1 = $this->get_id($internal); $r2 = $this->get_id($acinternal); /* * add lettering */ $oletter = new Lettering($this->db); $oletter->insert_couple($let_tiers, $let_other); /* set the flag paid */ $Res = $this->db->exec_sql("update jrn set jr_rapt='paid' where jr_id=\$1", array($r1)); /* Reconcialiation */ $rec = new Acc_Reconciliation($this->db); $rec->set_jr_id($r1); $rec->insert($r2); /* * save also into quant_fin */ /* get ledger property */ $ledger = new Acc_Ledger_Fin($this->db, $acc_pay->jrn); $prop = $ledger->get_propertie(); /* if ledger is FIN then insert into quant_fin */ if ($prop['jrn_def_type'] == 'FIN') { $ledger->insert_quant_fin($acfiche->id, $mp_jr_id, $cust->id, bcmul($famount, 1)); } } } catch (Exception $e) { echo '<span class="error">' . 'Erreur dans l\'enregistrement ' . __FILE__ . ':' . __LINE__ . ' ' . $e->getMessage(); echo $e->getTrace(); $this->db->rollback(); throw new Exception($e); } $this->db->commit(); return $internal; }
function get_account_ledger($p_jrn) { $l = new Acc_Ledger($this->db, $p_jrn); $row = $l->get_propertie(); if (strlen(trim($row['jrn_def_class_deb'])) == 0) { return array(); } $valid_account = explode(" ", $row['jrn_def_class_deb']); return $valid_account; }
function __construct($p_cn, $p_init) { parent::__construct($p_cn, $p_init); $this->type = 'FIN'; }
/** * 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 }
/** * 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(); }
$qcode = 'qc_' . $idx; $poste = 'poste' . $idx; $amount = 'amount' . $idx; $ck = 'ck' . $idx; $result[$qcode] = $row['j_qcode']; if (trim($row['j_qcode']) == '') { $result[$poste] = $row['j_poste']; } $result[$amount] = abs($row['solde']); if ($row['solde'] > 0) { $result[$ck] = 'on'; } $idx++; } $cn = new Database(dossier::id()); $jrn = new Acc_Ledger($cn, $_REQUEST['p_jrn']); echo '<form class="print" method="post">'; echo HtmlInput::hidden('ac', $_REQUEST['ac']); echo HtmlInput::hidden('sa', 'step5'); echo HtmlInput::hidden('f', $_REQUEST['f']); echo HtmlInput::hidden('p_periode', $_REQUEST['p_periode']); echo dossier::hidden(); echo HtmlInput::hidden('p_jrn', $_REQUEST['p_jrn']); echo $jrn->input($result, 0); echo '<hr>'; echo '<h2 class="notice">Ne corrigez pas encore, cliquez continuer pour passer à l\'étape suivante</h2>'; echo HtmlInput::submit('correct_it', 'Continuer'); echo '</form>'; echo HtmlInput::button_anchor('Retour', $back); echo '</div>'; }
$input_to->type = ALL; $input_to->cn = $cn; $input_to->user = $g_user; echo " " . _('jusque') . ' :' . $input_to->input(); echo '<br>'; echo HtmlInput::button_action(_('Avancé'), " if (\$('balance_advanced_div').style.display=='none') { \$('balance_advanced_div').show();} else { \$('balance_advanced_div').hide();}"); //------------------------------------------------- echo '<div id="balance_advanced_div" style="display:none">'; /* add a all ledger choice */ echo _('Filtre') . " "; $rad = new IRadio(); $array_ledger = $g_user->get_ledger('ALL', 3); $array = get_array_column($array_ledger, 'jrn_def_id'); $selected = isset($_GET['r_jrn']) ? $_GET['r_jrn'] : null; $select_cat = isset($_GET['r_cat']) ? $_GET['r_cat'] : null; $array_cat = Acc_Ledger::array_cat(); echo '<ul style="list-style-type:none">'; if (!isset($_GET['p_filter']) || $_GET['p_filter'] == 0) { $rad->selected = 't'; } else { $rad->selected = false; } echo '<li>' . $rad->input('p_filter', 0) . _('Aucun filtre, tous les journaux') . '</li>'; if (isset($_GET['p_filter']) && $_GET['p_filter'] == 1) { $rad->selected = 't'; } else { $rad->selected = false; } echo '<li>' . $rad->input('p_filter', 1) . _('Filtré par journal'); echo HtmlInput::button_choice_ledger(array('div' => '', 'type' => 'ALL', 'all_type' => 1)); echo '</li>';
* - gDossier * Must return at least tva, htva and tvac */ if (!defined('ALLOWED')) { die('Appel direct ne sont pas permis'); } require_once NOALYSS_INCLUDE . '/constant.php'; require_once NOALYSS_INCLUDE . '/class_database.php'; require_once NOALYSS_INCLUDE . '/class_dossier.php'; require_once NOALYSS_INCLUDE . '/class_acc_ledger.php'; require_once NOALYSS_INCLUDE . '/class_user.php'; // Check if the needed field does exist extract($_GET); foreach (array('l', 'gDossier') as $a) { if (!isset(${$a})) { echo "error {$a} is not set "; exit; } } if (is_numeric($l) == false) { exit; } $Ledger = new Acc_Ledger($cn, $l); $prop = $Ledger->get_propertie(); $pj_seq = $Ledger->guess_pj(); $string = '{"pj":"' . $pj_seq . '"}'; header("Content-type: text/json; charset: utf8", true); echo $string; ?>
/** * set the $this->jrn to the cat * @todo Cette function semble ne pas fonctionner correctement */ function filter_cat($p_array) { if (empty($p_array)) { $this->jrn = null; return; } /* get the list of jrn of the cat. */ $array = Acc_Ledger::array_cat(); $jrn = array(); for ($e = 0; $e < count($array); $e++) { if (isset($p_array[$e])) { $t_a = $this->db->get_array('select jrn_def_id from jrn_def where jrn_def_type=$1', array($array[$e]['cat'])); for ($f = 0; $f < count($t_a); $f++) { $this->jrn[] = $t_a[$f]['jrn_def_id']; } } } }
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; }
require_once NOALYSS_INCLUDE . '/user_menu.php'; require_once NOALYSS_INCLUDE . '/class_dossier.php'; require_once NOALYSS_INCLUDE . '/class_todo_list.php'; require_once NOALYSS_INCLUDE . '/class_itextarea.php'; require_once NOALYSS_INCLUDE . '/class_calendar.php'; require_once NOALYSS_INCLUDE . '/class_acc_ledger.php'; require_once NOALYSS_INCLUDE . '/class_follow_up.php'; echo '<div class="content">'; global $g_user; /* others report */ $cal = new Calendar(); $cal->get_preference(); $obj = sprintf("{gDossier:%d,invalue:'%s',outdiv:'%s','distype':'%s'}", dossier::id(), 'per', 'calendar_zoom_div', 'cal'); $Operation = new Follow_Up($cn); $last_operation = $Operation->get_today(); $late_operation = $Operation->get_late(); $Ledger = new Acc_Ledger($cn, 0); $last_ledger = array(); $last_ledger = $Ledger->get_last(20); // Supplier late and now $supplier_now = $Ledger->get_supplier_now(); $supplier_late = $Ledger->get_supplier_late(); // Customer late and now $customer_now = $Ledger->get_customer_now(); $customer_late = $Ledger->get_customer_late(); ob_start(); require_once NOALYSS_INCLUDE . '/template/dashboard.php'; $ret = ob_get_contents(); ob_end_clean(); echo $ret; echo '</div>';
$r .= _('Fiche contenant') . HtmlInput::infobulle(19); $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;
/** * 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; }
/** * @covers Acc_Ledger::get_tiers * @todo Implement testGet_tiers(). */ public function testGet_tiers() { $this->object->get_tiers($p_jrn_type, $jr_id); }
include_once NOALYSS_INCLUDE . '/class_user.php'; global $g_user; $g_user = new User($cn); $g_user->Check(); $act = $g_user->check_dossier($gDossier); // AC CODE = SEARCH if ($act == 'P') { redirect("extension.php?" . dossier::get(), 0); exit; } if ($act == 'X') { alert(_('Accès interdit')); exit; } // display a search box $ledger = new Acc_Ledger($cn, 0); $ledger->type = 'ALL'; $search_box = $ledger->search_form('ALL', 1); echo '<div class="content">'; echo '<form method="GET">'; echo $search_box; echo HtmlInput::submit("viewsearch", _("Recherche")); ?> <input type="button" class="smallbutton" onclick="window.close()" value="<?php echo _('Fermer'); ?> "> <?php echo '</form>'; //-----------------------------------------------------
* @brief Create, update and delete ledgers * */ if (!defined('ALLOWED')) { die('Appel direct ne sont pas permis'); } require_once NOALYSS_INCLUDE . '/class_dossier.php'; require_once NOALYSS_INCLUDE . '/ac_common.php'; require_once NOALYSS_INCLUDE . '/class_database.php'; require_once NOALYSS_INCLUDE . '/class_user.php'; require_once NOALYSS_INCLUDE . '/user_menu.php'; require_once NOALYSS_INCLUDE . '/class_acc_ledger.php'; $gDossier = dossier::id(); global $cn; $show_menu = 1; $ledger = new Acc_Ledger($cn, -1); $sa = HtmlInput::default_value("sa", "", $_REQUEST); ////////////////////////////////////////////////////////////////////////// // Perform request action : update ////////////////////////////////////////////////////////////////////////// $action_frm = HtmlInput::default_value_post('action_frm', ''); if ($action_frm == 'update') { try { $ledger->id = $_POST['p_jrn']; if ($ledger->load() == -1) { throw new Exception(_('Journal inexistant')); } $ledger->verify_ledger($_POST); $ledger->update($_POST); $show_menu = 1; } catch (Exception $e) {