PRERELEASE 10A
This commit is contained in:
commit
83efa90a33
1141 changed files with 40635 additions and 85178 deletions
|
|
@ -484,15 +484,15 @@ class Acc_Account_Ledger
|
|||
"<TH style=\"text-align:left\">"._('Pièce')." </TH>".
|
||||
"<TH style=\"text-align:left\">"._('Code')."</TH>".
|
||||
"<TH style=\"text-align:left\">"._('Interne')." </TH>".
|
||||
"<TH style=\"text-align:left\">"._('Tiers')." </TH>".
|
||||
"<TH style=\"text-align:left\">"._('Description')."</TH>".
|
||||
"<TH style=\"text-align:left\">"._('Type')."</TH>".
|
||||
"<TH style=\"text-align:left\">"._('ISO')."</TH>".
|
||||
"<TH style=\"text-align:right\">"._('Dev.')."</TH>".
|
||||
"<TH class=\"visible_gt800\" style=\"text-align:left\">"._('Tiers')." </TH>".
|
||||
"<TH class=\"visible_gt800\" style=\"text-align:left\">"._('Description')."</TH>".
|
||||
"<TH class=\"visible_gt800\" style=\"text-align:left\">"._('Type')."</TH>".
|
||||
"<TH class=\"visible_gt800\" style=\"text-align:left\">"._('ISO')."</TH>".
|
||||
"<TH class=\"visible_gt800\" style=\"text-align:right\">"._('Dev.')."</TH>".
|
||||
"<TH style=\"text-align:right\">"._('Débit')."</TH>".
|
||||
"<TH style=\"text-align:right\">"._("Crédit")."</TH>".
|
||||
th('Prog.','style="text-align:right"').
|
||||
th('Let.','style="text-align:right"');
|
||||
th('Let.',' class="visible_gt800" '.'style="text-align:right"');
|
||||
"</TR>"
|
||||
;
|
||||
$progress=0;$sum_deb=0;$sum_cred=0;
|
||||
|
|
@ -520,28 +520,32 @@ class Acc_Account_Ledger
|
|||
/*
|
||||
* reset prog. balance to zero if we change of exercice
|
||||
*/
|
||||
if ( $old_exercice != $op['p_exercice'])
|
||||
{
|
||||
if ( $old_exercice != '')
|
||||
{
|
||||
$progress=bcsub($sum_deb,$sum_cred);
|
||||
$side=" ".$this->get_amount_side($progress);
|
||||
echo "<TR class=\"highlight\">".
|
||||
"<TD>$old_exercice</TD>".
|
||||
"<TD></TD>".td().td().td().td().td().
|
||||
"<TD>"._("Totaux")."</TD>".td("").
|
||||
"<TD style=\"text-align:right;padding-left:10px;\">".nbm($sum_deb)."</TD>".
|
||||
"<TD style=\"text-align:right;padding-left:10px;\">".nbm($sum_cred)."</TD>".
|
||||
td(nbm(abs($progress)).$side,'style="text-align:right;padding-left:10px;"').
|
||||
td('').
|
||||
"</TR>";
|
||||
$sum_cred=0;
|
||||
$sum_deb=0;
|
||||
$progress=0;
|
||||
|
||||
}
|
||||
}
|
||||
$progress=bcadd($progress,$tmp_diff);
|
||||
if ($old_exercice != $op['p_exercice']) {
|
||||
if ($old_exercice != '') {
|
||||
$progress = bcsub($sum_deb, $sum_cred);
|
||||
$side = " " . $this->get_amount_side($progress);
|
||||
echo "<TR class=\"highlight\">" .
|
||||
td($op['p_exercice']) .
|
||||
td("", ' class="visible_gt800" ') .
|
||||
td("", ' class="visible_gt800" ') .
|
||||
td("", ' class="visible_gt800" ') .
|
||||
td("", ' class="visible_gt800" ') .
|
||||
td("", ' class="visible_gt800" ') .
|
||||
td() .
|
||||
"<TD >Totaux</TD>" . td("") .
|
||||
"<TD style=\"text-align:right\">" . nbm($sum_deb) . "</TD>" .
|
||||
"<TD style=\"text-align:right\">" . nbm($sum_cred) . "</TD>" .
|
||||
td(nbm(abs($progress)).$side,'style="text-align:right;padding-left:10px;"').
|
||||
td("", ' class="visible_gt800" ') .
|
||||
"</TR>";
|
||||
|
||||
|
||||
$sum_cred = 0;
|
||||
$sum_deb = 0;
|
||||
$progress = 0;
|
||||
}
|
||||
}
|
||||
$progress=bcadd($progress,$tmp_diff);
|
||||
$side=" ".$this->get_amount_side($progress);
|
||||
$sum_cred=bcadd($sum_cred,$op['cred_montant']);
|
||||
$sum_deb=bcadd($sum_deb,$op['deb_montant']);
|
||||
|
|
@ -553,9 +557,9 @@ class Acc_Account_Ledger
|
|||
td(h($op['jr_pj_number'])).
|
||||
"<TD>".\HtmlInput::card_detail($op['j_qcode'])."</TD>".
|
||||
"<TD>".$vw_operation."</TD>".
|
||||
"<TD>".$tiers."</TD>".
|
||||
"<TD>".h($op['description']).$op_analytic."</TD>".
|
||||
td($op['jr_optype']);
|
||||
"<TD class=\"visible_gt800\" >".$tiers."</TD>".
|
||||
"<TD class=\"visible_gt800\" >".h($op['description']).$op_analytic."</TD>".
|
||||
td($op['jr_optype'],' class="visible_gt800" ');
|
||||
/// If the currency is not the default one , then show the amount
|
||||
if ( $op['currency_id'] > 0 )
|
||||
{
|
||||
|
|
@ -565,7 +569,7 @@ class Acc_Account_Ledger
|
|||
echo td($op['cr_code_iso']).
|
||||
td(nbm($currency_val,2),'style="text-align:right;padding-left:10px;"');
|
||||
} else {
|
||||
echo td().td();
|
||||
echo td('', 'class="visible_gt800" ').td('',' class="visible_gt800"' );
|
||||
}
|
||||
|
||||
echo
|
||||
|
|
@ -573,7 +577,7 @@ class Acc_Account_Ledger
|
|||
"<TD style=\"text-align:right;padding-left:10px;\">".nbm($op['cred_montant'])."</TD>".
|
||||
td(nbm(abs($progress)).$side,'style="text-align:right"').
|
||||
|
||||
td($html_let, ' style="color:red;text-align:right"') .
|
||||
td($html_let, ' class="visible_gt800" '.' style="color:red;text-align:right"') .
|
||||
"</TR>";
|
||||
$old_exercice=$op['p_exercice'];
|
||||
}
|
||||
|
|
@ -581,14 +585,19 @@ class Acc_Account_Ledger
|
|||
$solde_type=($sum_deb>$sum_cred)?_("solde débiteur"):_("solde créditeur");
|
||||
$diff=bcsub($sum_deb,$sum_cred);
|
||||
$side=" ".$this->get_amount_side($diff);
|
||||
echo "<TR class=\"highlight\">".
|
||||
echo "<TR class=\"highlight\">".
|
||||
td($op['p_exercice']).
|
||||
td().td().td().td().td().td().
|
||||
td("",' class="visible_gt800" ').
|
||||
td("",' class="visible_gt800" ').
|
||||
td("",' class="visible_gt800" ').
|
||||
td("",' class="visible_gt800" ').
|
||||
td("",' class="visible_gt800" ').
|
||||
td().
|
||||
"<TD >Totaux</TD>".td("").
|
||||
"<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
|
||||
"<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
|
||||
"<TD style=\"text-align:right\">".nbm(abs($diff)).$side."</TD>".
|
||||
td().
|
||||
td("",' class="visible_gt800" ').
|
||||
"</TR>";
|
||||
echo "<tr style=\"font-weight:bold\"><TD>$solde_type</TD><td></td>".
|
||||
"<TD style=\"text-align:right\">".nbm(abs($diff))."</TD>".
|
||||
|
|
@ -634,6 +643,7 @@ class Acc_Account_Ledger
|
|||
*/
|
||||
static function HtmlTableHeader($actiontarget="poste")
|
||||
{
|
||||
$http=new \HttpInput();
|
||||
switch($actiontarget)
|
||||
{
|
||||
case 'poste':
|
||||
|
|
@ -651,13 +661,13 @@ class Acc_Account_Ledger
|
|||
|
||||
echo "<table >";
|
||||
echo '<TR>';
|
||||
$str_ople=(isset($_REQUEST['ople']))?HtmlInput::hidden('ople',$_REQUEST['ople']):'';
|
||||
$str_ople=(isset($_REQUEST['ople']))?HtmlInput::hidden('ople',$http->request('ople')):'';
|
||||
if ($actiontarget=='poste')
|
||||
{
|
||||
echo '<TD><form method="GET" ACTION="export.php">'.
|
||||
dossier::hidden().
|
||||
HtmlInput::submit('bt_other',"Autre poste").
|
||||
$hid->input("type","poste").$hid->input('ac',$_REQUEST['ac'])."</form></TD>";
|
||||
$hid->input("type","poste").$hid->input('ac',$http->request('ac'))."</form></TD>";
|
||||
}
|
||||
|
||||
$id=uniqid("pdf_");
|
||||
|
|
@ -668,21 +678,21 @@ class Acc_Account_Ledger
|
|||
HtmlInput::hidden('act',$action_pdf).
|
||||
$hid->input("type","poste").$str_ople.
|
||||
$hid->input('p_action','impress').
|
||||
$hid->input("from_periode",$_REQUEST['from_periode']).
|
||||
$hid->input("to_periode",$_REQUEST['to_periode'])
|
||||
$hid->input("from_periode",$http->request('from_periode')).
|
||||
$hid->input("to_periode",$http->request('to_periode'))
|
||||
;
|
||||
|
||||
if ( isset($_REQUEST['letter'] )) echo HtmlInput::hidden('letter','2');
|
||||
if ( isset($_REQUEST['solded'] )) echo HtmlInput::hidden('solded','1');
|
||||
|
||||
if (isset($_REQUEST['from_poste']))
|
||||
echo HtmlInput::hidden('from_poste',$_REQUEST['from_poste']);
|
||||
echo HtmlInput::hidden('from_poste',$http->request('from_poste'));
|
||||
|
||||
if (isset($_REQUEST['to_poste']))
|
||||
echo HtmlInput::hidden('to_poste',$_REQUEST['to_poste']);
|
||||
echo HtmlInput::hidden('to_poste',$http->request('to_poste'));
|
||||
|
||||
if (isset($_REQUEST['poste_id']))
|
||||
echo HtmlInput::hidden("poste_id",$_REQUEST['poste_id']);
|
||||
echo HtmlInput::hidden("poste_id",$http->request('poste_id'));
|
||||
|
||||
if (isset($_REQUEST['poste_fille']))
|
||||
echo $hid->input('poste_fille','on');
|
||||
|
|
@ -697,17 +707,17 @@ class Acc_Account_Ledger
|
|||
HtmlInput::hidden('act',$action_csv).
|
||||
$hid->input("type","poste").$str_ople.
|
||||
$hid->input('p_action','impress').
|
||||
$hid->input("from_periode",$_REQUEST['from_periode']).
|
||||
$hid->input("to_periode",$_REQUEST['to_periode']);
|
||||
$hid->input("from_periode",$http->request('from_periode')).
|
||||
$hid->input("to_periode",$http->request('to_periode'));
|
||||
|
||||
if (isset($_REQUEST['from_poste']))
|
||||
echo HtmlInput::hidden('from_poste',$_REQUEST['from_poste']);
|
||||
echo HtmlInput::hidden('from_poste',$http->request('from_poste'));
|
||||
|
||||
if (isset($_REQUEST['to_poste']))
|
||||
echo HtmlInput::hidden('to_poste',$_REQUEST['to_poste']);
|
||||
echo HtmlInput::hidden('to_poste',$http->request('to_poste'));
|
||||
|
||||
if (isset($_REQUEST['poste_id']))
|
||||
echo HtmlInput::hidden("poste_id",$_REQUEST['poste_id']);
|
||||
echo HtmlInput::hidden("poste_id",$http->request('poste_id'));
|
||||
|
||||
if ( isset($_REQUEST['letter'] )) echo HtmlInput::hidden('letter','2');
|
||||
if ( isset($_REQUEST['solded'] )) echo HtmlInput::hidden('solded','1');
|
||||
|
|
@ -716,7 +726,7 @@ class Acc_Account_Ledger
|
|||
echo $hid->input('poste_fille','on');
|
||||
if (isset($_REQUEST['oper_detail']))
|
||||
echo $hid->input('oper_detail','on');
|
||||
if (isset($_REQUEST['poste_id'])) echo $hid->input("poste_id",$_REQUEST['poste_id']);
|
||||
if (isset($_REQUEST['poste_id'])) echo $hid->input("poste_id",$http->request('poste_id'));
|
||||
|
||||
echo "</form></TD>";
|
||||
echo '<td style="vertical-align:top">';
|
||||
|
|
|
|||
436
include/class/acc_document.class.php
Normal file
436
include/class/acc_document.class.php
Normal file
|
|
@ -0,0 +1,436 @@
|
|||
<?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 28/08/25
|
||||
use Noalyss\XMLDocument\XMLInvoice_Reader;
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Document used in accountancy : invoice , credit note, ...It is
|
||||
* a specialization of Document used in Follow-UP
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @brief Document used in accountancy : invoice , credit note, ... It is
|
||||
* a specialization of Document used in Follow-UP.
|
||||
* property :
|
||||
* - d_id JRN.JR_ID
|
||||
* - d_name name Receipt number
|
||||
- d_description Comment of the operation
|
||||
- d_mimetype mimetype of the document JRN.JR_PJ_TYPE
|
||||
- d_filename filename JRN.JR_PJ_NAME
|
||||
- document_xml oid of the XML invoice (including PDF) JRN.JR_DOCUMENT_XML
|
||||
- d_lob = JRN.JR_PJ
|
||||
*
|
||||
*/
|
||||
class Acc_Document extends Document {
|
||||
private $document_xml; ///< $document_xml (oid) XML document e-invoice
|
||||
|
||||
public function get_document_xml() {
|
||||
return $this->document_xml;
|
||||
}
|
||||
|
||||
public function set_document_xml($document_xml) {
|
||||
$this->document_xml = $document_xml;
|
||||
return $this;
|
||||
}
|
||||
/*!
|
||||
* \brief insert the generated Document into the database, update the $this->d_id
|
||||
* that is the PK of document. and load the PDF into the database.
|
||||
* \param $p_file is the generated file (full path)
|
||||
* \return 0 if no error otherwise 1
|
||||
*/
|
||||
protected function saveGenerated($p_file)
|
||||
{
|
||||
|
||||
$this->db->start();
|
||||
$this->d_filename= basename($p_file);
|
||||
$this->d_mimetype= mime_content_type($p_file);
|
||||
$this->d_lob=$this->db->lo_import($p_file);
|
||||
if ($this->d_lob==false)
|
||||
{
|
||||
echo "ne peut pas importer [$p_file]";
|
||||
return 1;
|
||||
}
|
||||
$sql="update jrn set jr_pj=$1,jr_pj_name=$2,jr_pj_type=$3 where jr_id=$4 returning jr_id";
|
||||
$id=$this->db->get_value($sql, array($this->d_lob, $this->d_filename, $this->d_mimetype, $this->d_id));
|
||||
$this->db->commit();
|
||||
if ( $id == "") {
|
||||
throw new Exception("AD99 FILE NOT SAVED INTO DB",99);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief constructor
|
||||
* @param $cn \Database
|
||||
* @param $jr_id (int) JRN.JRID will be in d_id
|
||||
*/
|
||||
function __construct($cn, $jr_id=0)
|
||||
{
|
||||
$this->db=$cn;
|
||||
$this->set_id($jr_id);
|
||||
// counter for MARCH_NEXT
|
||||
$this->counter=0;
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief set_id fill up d_filename, d_mimetype,d_lob,d_description,jr_pj_number
|
||||
*/
|
||||
function set_id($jr_id) {
|
||||
$this->d_id=$jr_id;
|
||||
if ( $jr_id == 0 ){
|
||||
return $this;
|
||||
}
|
||||
$row = $this->db->get_row("select jr_comment
|
||||
,jr_pj
|
||||
,jr_pj_name
|
||||
,jr_pj_type
|
||||
,jr_pj_number
|
||||
,jr_document_xml
|
||||
from jrn
|
||||
where
|
||||
jr_id=$1", [$this->d_id]);
|
||||
if ( empty ($row)) {
|
||||
return $this;
|
||||
}
|
||||
$this->d_name=$row['jr_pj_number'];
|
||||
$this->d_description=$row['jr_comment'];
|
||||
$this->d_mimetype=$row['jr_pj_type'];
|
||||
$this->d_filename=$row['jr_pj_name'];
|
||||
$this->d_lob=$row['jr_pj'];
|
||||
$this->document_xml=$row['jr_document_xml'];
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @brief save the file into DB, will create a large object if there
|
||||
* is no document to replace. It will change the d_filename, d_mimetype
|
||||
*
|
||||
* @param $d_filename (string) full path to the file to load into DB
|
||||
*
|
||||
* @returns false if d_id = 0 or the file doesn't exist, true for success
|
||||
*/
|
||||
function update($filename) {
|
||||
if ($this->d_id == 0) return false;
|
||||
if ( ! file_exists($filename)) return false;
|
||||
$this->db->start();
|
||||
$this->d_mimetype= mime_content_type($filename);
|
||||
$this->d_filename= basename($filename);
|
||||
if ( $this->d_lob == "") {
|
||||
$this->db->lo_unlink($this->d_lob);
|
||||
}
|
||||
|
||||
$this->d_lob=$this->db->lo_import($filename);
|
||||
$this->db->exec_sql(
|
||||
"update jrn set jr_pj=$1,jr_pj_name=$2,jr_pj_type=$3
|
||||
where jr_id=$4",
|
||||
[$this->d_lob,$this->d_filename,$this->d_mimetype,$this->d_id]
|
||||
);
|
||||
$this->db->commit();
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* @brief for FACTURX we replace the PDF save in DB by this one, always
|
||||
* a PDF (since it is a FACTURX document)
|
||||
*/
|
||||
function replace_receipt($new_oid)
|
||||
{
|
||||
if ($this->d_lob != "")
|
||||
{
|
||||
$this->db->lo_unlink($this->d_lob);
|
||||
}
|
||||
$this->d_lob=$new_oid;
|
||||
$this->db->exec_sql("
|
||||
update jrn
|
||||
set
|
||||
jr_pj = $1
|
||||
,jr_pj_name =$2
|
||||
,jr_pj_type =$3
|
||||
where jr_id=$4
|
||||
",
|
||||
[$this->d_lob
|
||||
,$this->d_filename
|
||||
,$this->d_mimetype
|
||||
,$this->d_id]
|
||||
);
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief save the Large Object $oid in the column JRN.JR_DOCUMENT_XML
|
||||
* @param $oid( OID) PostgreSQL Object ID
|
||||
*/
|
||||
function update_document_xml($oid){
|
||||
$this->db->exec_sql("update jrn set jr_document_xml=$1 where
|
||||
jr_id=$2",[
|
||||
$oid,
|
||||
$this->d_id
|
||||
]);
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief create the invoice and saved it as attachment to the
|
||||
* operation,
|
||||
* @param $p_array is normally the $_POST
|
||||
@verbatim
|
||||
Array
|
||||
(
|
||||
[ledger_type] => VEN
|
||||
[gDossier] => x
|
||||
[nb_item] => 1 (number of item used to numerate e_marchX, e_quantX ,...)
|
||||
[p_jrn] => 2
|
||||
[p_jrn_predef] => 2
|
||||
[jrn_type] => VEN or ACH
|
||||
[e_date] => 10.06.2025 (date)
|
||||
[e_ech] => limite date
|
||||
[e_client] => CLIENT
|
||||
[e_pj] => 25.827
|
||||
[e_pj_suggest] => 25.827
|
||||
[e_comm] => E-INVOICE
|
||||
[p_currency_code] => 0
|
||||
[p_currency_rate] => 1 (rate if 1 for EURO)
|
||||
[jrn_note_input] =>
|
||||
[e_march0] => 7DVINV
|
||||
[e_march0_label] => Label of the operation
|
||||
[e_march0_price] => 10.0000
|
||||
[e_quant0] => 1.0000
|
||||
[htva_march0] => 10
|
||||
[e_march0_tva_id] => 1
|
||||
[e_march0_tva_amount] => 2.1
|
||||
[tva_march0] => 2.1
|
||||
[tvac_march0] => 12.1
|
||||
...
|
||||
[mp_date] => (dd.mm.yyyy date of payment)
|
||||
[acompte] => 0 (amount to deduce as advance payment)
|
||||
[e_comm_paiement] => (string : comment of the payment)
|
||||
[e_mp] => 0 (method of payment it is the XX in e_mp_qcode_XX)
|
||||
[e_mp_qcode_16] => Banque 1
|
||||
[e_mp_qcode_17] => Banque 2
|
||||
[view_invoice] => Enregistrer
|
||||
[gen_doc] => int DOCUMENT_MODELE.MD_ID , document template to use
|
||||
)
|
||||
* @endverbatim
|
||||
* @todo rewrite code : remove extract and +SQL value
|
||||
* @returns void
|
||||
*/
|
||||
function create_document($internal, $p_array) {
|
||||
$this->f_id = $p_array['e_client'];
|
||||
// var md_id (int) DOCUMENT_MODELE.MD_ID
|
||||
$this->md_id = $p_array['gen_doc'];
|
||||
// var ag_id == 0 fake follow-up
|
||||
$this->ag_id = 0;
|
||||
// var e_pj (string) receipt nb
|
||||
$p_array['e_pj'] = $this->db->get_value("select jr_pj_number from jrn where jr_id=$1"
|
||||
, [$this->d_id]);
|
||||
$filename = "";
|
||||
|
||||
// generate the document and set d_lob,d_mimetype,
|
||||
// this function will call saveGenerated and save in DB
|
||||
$this->generate($p_array, $p_array['e_pj']);
|
||||
|
||||
// Update the comment with invoice number, if the comment is empty
|
||||
if (!isset($p_array['e_comm']) || noalyss_strlentrim($p_array['e_comm']) == 0) {
|
||||
$sql = "update jrn set jr_comment=' document " . $this->d_number . "' where jr_internal=$1";
|
||||
$this->db->exec_sql($sql, [$internal]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief export the file to the file system and complet $this->d_mimetype, d_filename and
|
||||
* @param $destination_file (string) full path to document
|
||||
* @return bool false for failure and string (the full path_name) for success
|
||||
*/
|
||||
function export_file($destination_file) {
|
||||
|
||||
if (empty($this->d_filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->db->start();
|
||||
if ($this->db->lo_export($this->d_lob, $destination_file) == false) {
|
||||
record_log("ACD122. cannot export");
|
||||
$this->db->commit();
|
||||
return false;
|
||||
}
|
||||
$this->db->commit();
|
||||
|
||||
return $destination_file;
|
||||
}
|
||||
/**
|
||||
* \brief Save a "piece justificative" , the name must be a receipt. If it
|
||||
* is a XML document, split it into 2 parts : PDF and XML
|
||||
* the PDF be stored in JR_PJ and the XML into JR_DOCUMENT_XML
|
||||
*
|
||||
*
|
||||
* \return $oid of the lob file if success null if a error occurs
|
||||
*
|
||||
*/
|
||||
function save_receipt()
|
||||
{
|
||||
$this->db->start();
|
||||
/**
|
||||
* pj is the $_FILES key
|
||||
*/
|
||||
if ( $_FILES['pj']['name']=="") {
|
||||
return false;
|
||||
}
|
||||
$a_file= $this->db->upload('pj',only_oid:false);
|
||||
if ($a_file == false) {
|
||||
return false;
|
||||
}
|
||||
$oid=$a_file['oid'];
|
||||
// Remove old document if any
|
||||
$old_oid = $this->db->get_value("select jr_pj from jrn where jr_id=$1"
|
||||
,[$this->d_id]);
|
||||
|
||||
if ( $old_oid != "")
|
||||
{
|
||||
$this->db->lo_unlink( $old_oid);
|
||||
}
|
||||
|
||||
// if there is a e-invoice in XML
|
||||
if ( $_FILES['pj']['type'] == 'text/xml'
|
||||
|| $_FILES['pj']['type'] == 'application/xml'
|
||||
)
|
||||
{
|
||||
// save the XML
|
||||
$this->db->exec_sql("update jrn set jr_document_xml = $1
|
||||
where
|
||||
jr_id=$2",
|
||||
[$oid,$this->d_id]);
|
||||
|
||||
$xmlreader= \Noalyss\XMLDocument\XML_Reader::build_from_file($a_file['filename']);
|
||||
|
||||
//@var $embedded_file (array) keys = filecontent: binary data
|
||||
//,mimecode mimetype and filename (string)
|
||||
try
|
||||
{
|
||||
|
||||
// create a PDF with standard information
|
||||
$pdf=$xmlreader->to_pdf($this->db);
|
||||
$file_oid=$this->db->lo_write($pdf->Output("S"));
|
||||
|
||||
//@var $file_oid OID of the large object saved in DB
|
||||
$this->d_name="invoice.pdf";
|
||||
$this->d_description="Auto generated invoice";
|
||||
$this->d_lob=$file_oid;
|
||||
$this->d_mimetype="application/pdf";
|
||||
|
||||
// save extracted document into DB
|
||||
$this->db->exec_sql("update jrn set jr_pj=$1 , jr_pj_name=$2,
|
||||
jr_pj_type=$3 where jr_id=$4",
|
||||
array(
|
||||
$this->d_lob
|
||||
, $this->d_name
|
||||
, $this->d_description
|
||||
, $this->d_id
|
||||
)
|
||||
);
|
||||
// save all the documents into the DB
|
||||
// @var embedded_file (array of Noalyss\XML\Document_Reference)
|
||||
$embedded_file=$xmlreader->get_embedded_document();
|
||||
$nb_file = count($embedded_file);
|
||||
for ($i=0;$i <$nb_file ; $i++)
|
||||
{
|
||||
// other documents save in jrn_sup_document
|
||||
// @var $file (Binary File from XML)
|
||||
$binary=$embedded_file[$i]->getBinary_object();
|
||||
|
||||
//@var $sup_oid : oid of the supplemental
|
||||
$sup_oid=$this->db->lo_write($binary->filecontent);
|
||||
|
||||
$jrn_sup_document=new Jrn_Sup_Document_SQL($this->db);
|
||||
$jrn_sup_document->jr_id=$this->d_id;
|
||||
$jrn_sup_document->js_mimetype=$binary->mimecode;
|
||||
$jrn_sup_document->js_filename=$binary->filename;
|
||||
$jrn_sup_document->js_lob=$sup_oid;
|
||||
$jrn_sup_document->js_description=$embedded_file[$i]->getDescription();
|
||||
$jrn_sup_document->js_cbc_id=$embedded_file[$i]->getId();
|
||||
$jrn_sup_document->save();
|
||||
}
|
||||
|
||||
} catch (\Exception $e ) {
|
||||
\record_log($e);
|
||||
throw new \Exception("X281 ",281,$e);
|
||||
}
|
||||
}
|
||||
$this->db->commit();
|
||||
|
||||
return $oid;
|
||||
}
|
||||
/**
|
||||
* @brief return a string with a link download XML or an empty string
|
||||
* if there is no XML to download
|
||||
*/
|
||||
function link_download_xml():string
|
||||
{
|
||||
$xml_oid=$this->db->get_value("select jr_document_xml from jrn where jr_id=$1",
|
||||
[$this->d_id]);
|
||||
if ($xml_oid == "") { return "";}
|
||||
$url= "export.php?".http_build_query(
|
||||
[
|
||||
"gDossier"=>\Dossier::id(),
|
||||
"jr_id"=>$this->d_id,
|
||||
"act"=>'RAW:xml-invoice'
|
||||
]);
|
||||
$r = sprintf('<a class="mtitle line" href="%s">',$url);
|
||||
$r .= _("XML")
|
||||
.'<i class="icon-download">'
|
||||
.'</i>'
|
||||
.'</a>';
|
||||
return $r;
|
||||
}
|
||||
static function display_supplementary_doc($cn,$div,$jr_id)
|
||||
{
|
||||
$gDossier=\Dossier::id();
|
||||
$q=new Jrn_Sup_Document_SQL($cn);
|
||||
$a_row=$q->collect_objects(" where jr_id=$1 order by js_cbc_id", [$jr_id]);
|
||||
|
||||
if ( count($a_row) > 0)
|
||||
{
|
||||
foreach ($a_row as $item) {
|
||||
$export="export.php?";
|
||||
$script="Supplement_Document.delete_document('$gDossier','$div','{$item->js_id}','$jr_id')";
|
||||
$rowid=sprintf("row_js_%s_%s",$div,$item->js_id);
|
||||
// @var $download (url) to send file
|
||||
$download="export.php?". http_build_query(
|
||||
[
|
||||
"act"=>"RAW:suppl-document"
|
||||
,"js_id"=>$item->js_id
|
||||
,"gDossier"=>$gDossier
|
||||
]);
|
||||
?>
|
||||
<div class="row" id="<?=$rowid?>">
|
||||
<div class="col">
|
||||
<a href="<?=$download?>" download> <?=$item->js_filename?></a>
|
||||
</div>O
|
||||
<div class="col">
|
||||
<?=$item->js_description?>
|
||||
</div>
|
||||
<div class="col">
|
||||
<?=\Icon_Action::trash(uniqid("sdd"),$script)?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}// end foreach $a_row
|
||||
}// end if count
|
||||
//download ALL files from this operation
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -35,16 +35,37 @@ require_once NOALYSS_INCLUDE.'/database/operation_currency_sql.class.php';
|
|||
class Acc_Ledger extends jrn_def_sql
|
||||
{
|
||||
|
||||
var $id; /**!< jrn_def.jrn_def_id */
|
||||
var $db; /**!< database connextion */
|
||||
var $row; /**!< row of the ledger */
|
||||
var $ledger_type; /**!< type of the ledger ACH ODS FIN VEN or GL */
|
||||
var $nb; /**!< default number of rows by default 10 */
|
||||
var $currency_id;
|
||||
/**!< is_loaded true the ledger definition is loaded or false, it is not */
|
||||
var $id; /*!< jrn_def.jrn_def_id */
|
||||
var $db; /*!< database connextion */
|
||||
var $row; /*!< row of the ledger */
|
||||
var $ledger_type; /*!< type of the ledger ACH ODS FIN VEN or GL */
|
||||
var $nb; /*!< default number of rows by default 10 */
|
||||
var $currency_id;/*!< $currency_id (int) SQL:CURRENCY.ID default 0 */
|
||||
/*!< is_loaded true the ledger definition is loaded or false, it is not */
|
||||
protected $is_loaded ;
|
||||
|
||||
|
||||
var $ledger_name;
|
||||
var $jr_internal ; /*!< $jr_internal (string) internal number for an operation */
|
||||
var $jr_id; /*!< $jr_id (int) SQL : PK JRN.JR_ID */
|
||||
var $jrn_def_max_line_deb ; /*!< $jr_id (int) PK.JRN */
|
||||
var $jrn_def_id; /*!< $jrn_def_id(INT) jrn_def.jrn_def_id */
|
||||
var $jrn_def_name; /*!< $jrn_def_name(string) ledger name */
|
||||
var $jrn_def_ech_lib; /*!< $jrn_def_ech_lib (string) text for limit date */
|
||||
var $jrn_def_type; /*!< $jrn_def_type(string) type of the ledger ACH,VEN,ODS,FIN */
|
||||
var $jrn_def_pj_pref; /*!< $jrn_def_pj_pref(string) prefix for receipt */
|
||||
var $jrn_deb_max_line;/*!< $jrn_deb_max_line(int) max rows to display*/
|
||||
var $jrn_def_description; /*!< $jrn_def_description(string) ledger description */
|
||||
var $jrn_enable; /*!< $jrn_enable (0 or 1)0:ledger not available, 1:ledger available */
|
||||
var $jrn_def_negative_amount; /*!< $jrn_def_negative_amount (0-1) 0: ledger use positive or negative amount, 1: ledger should use negative amount */
|
||||
var $jrn_def_negative_warning; /*!<$jrn_def_negative_warning (string) string to display if the amount is not positive (see $jrn_def_negative_amount) */
|
||||
var $jrn_def_quantity; /*!< $jrn_def_quantity (0-1) 0 no quantity for operations
|
||||
* 1 has quantity */
|
||||
var $with_concerned; /*!< $with_concerned(bool) : true is operation comes with
|
||||
another one, */
|
||||
var $jr_grpt_id ; /**! $jr_grpt_id (int) SQL JRN.JR_GRP_ID group rows
|
||||
of an operations */
|
||||
var $pj; /*!< $pj (string) nb receipt of the operation */
|
||||
|
||||
var $doc; /*!< $doc (string) HTML with an anchor to the doc. of operation*/
|
||||
/**
|
||||
* @brief construct
|
||||
* @param $p_cn database connexion
|
||||
|
|
@ -781,10 +802,10 @@ class Acc_Ledger extends jrn_def_sql
|
|||
{
|
||||
$oqc=new Fiche($this->db);
|
||||
$oqc->get_by_qcode(${'qc_'.$i}, false);
|
||||
$strPoste=$oqc->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$strPoste=$oqc->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
$ret.="<td>".
|
||||
${'qc_'.$i}.' - '.
|
||||
$oqc->strAttribut(ATTR_DEF_NAME).HtmlInput::hidden('qc_'.$i,
|
||||
$oqc->get_attribute(ATTR_DEF_NAME).HtmlInput::hidden('qc_'.$i,
|
||||
${'qc_'.$i}).
|
||||
'</td>';
|
||||
}
|
||||
|
|
@ -1092,13 +1113,12 @@ class Acc_Ledger extends jrn_def_sql
|
|||
|
||||
$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);
|
||||
$label=$Fiche->get_attribute(ATTR_DEF_NAME);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1317,7 +1337,7 @@ class Acc_Ledger extends jrn_def_sql
|
|||
if (noalyss_strlentrim(${'qc_'.$i})!=0&&isNumber(${'amount'.$i})==0)
|
||||
throw new Exception(_('Montant invalide'), 3);
|
||||
|
||||
$strPoste=$f->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$strPoste=$f->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
if ($strPoste=='')
|
||||
throw new Exception(sprintf(_("La fiche %s n'a pas de poste comptable"),
|
||||
${"qc_".$i}));
|
||||
|
|
@ -1351,8 +1371,8 @@ class Acc_Ledger extends jrn_def_sql
|
|||
for ($x=0; $x<$max; $x++)
|
||||
{
|
||||
$card=new Fiche($this->db, $card_id[$x]['f_id']);
|
||||
$str_msg.=HtmlInput::card_detail($card->strAttribut(ATTR_DEF_QUICKCODE),
|
||||
$card->strAttribut(ATTR_DEF_NAME),
|
||||
$str_msg.=HtmlInput::card_detail($card->get_attribute(ATTR_DEF_QUICKCODE),
|
||||
$card->get_attribute(ATTR_DEF_NAME),
|
||||
'style="color:red;display:inline;text-decoration:underline"');
|
||||
$str_msg.=" ";
|
||||
}
|
||||
|
|
@ -1463,7 +1483,7 @@ class Acc_Ledger extends jrn_def_sql
|
|||
{
|
||||
$qc=new Fiche($this->db);
|
||||
$qc->get_by_qcode(${'qc_'.$i}, false);
|
||||
$sposte=$qc->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$qc->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
/* if there are 2 accounts take following the deb or cred */
|
||||
if (strpos($sposte, ',')!=0)
|
||||
{
|
||||
|
|
@ -1589,6 +1609,7 @@ class Acc_Ledger extends jrn_def_sql
|
|||
$acc_end->currency_rate=$currency_rate;
|
||||
$acc_end->currency_rate_ref=$currency_rate_ref->get_rate();
|
||||
|
||||
// @var $jr_id (int) JRN.JR_ID
|
||||
$jr_id=$acc_end->insert_jrn();
|
||||
|
||||
$this->jr_id=$jr_id;
|
||||
|
|
@ -1607,7 +1628,7 @@ class Acc_Ledger extends jrn_def_sql
|
|||
$this->db->exec_sql("update jrn set jr_internal=$1
|
||||
where jr_grpt_id = $2",array($internal,$seq));
|
||||
|
||||
$this->internal=$internal;
|
||||
$this->jr_internal=$internal;
|
||||
// Save now the predef op
|
||||
//------------------------
|
||||
if (isset($opd_name)&&trim($opd_name)!="")
|
||||
|
|
@ -1630,7 +1651,8 @@ class Acc_Ledger extends jrn_def_sql
|
|||
*/
|
||||
if (isset($_FILES["pj"]))
|
||||
{
|
||||
$this->db->save_receipt($seq);
|
||||
$acc_document=new Acc_Document($this->db, $jr_id);
|
||||
$acc_document->save_receipt();
|
||||
}
|
||||
/*----------------------------------------------
|
||||
* Save the note
|
||||
|
|
@ -1712,10 +1734,10 @@ class Acc_Ledger extends jrn_def_sql
|
|||
|
||||
function update_internal_code($p_internal)
|
||||
{
|
||||
if (!isset($this->grpt_id))
|
||||
throw new Exception(('ERREUR '.__FILE__.":".__LINE__));
|
||||
if (!isset($this->jr_grpt_id))
|
||||
throw new Exception(('ERREUR jr_grpt_id not set '.__FILE__.":".__LINE__));
|
||||
$Res=$this->db->exec_sql("update jrn set jr_internal=$1 where
|
||||
jr_grpt_id = $2 ",array($p_internal,$this->grpt_id));
|
||||
jr_grpt_id = $2 ",array($p_internal,$this->jr_grpt_id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1952,31 +1974,22 @@ class Acc_Ledger extends jrn_def_sql
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief create the invoice and saved it as attachment to the
|
||||
* operation,
|
||||
* @brief alias for Acc_Document->create_document
|
||||
* @param $internal is the internal code
|
||||
* @param $p_array is normally the $_POST
|
||||
* \return a string
|
||||
@see Acc_Document::create_document
|
||||
* @return html string
|
||||
*/
|
||||
function create_document($internal, $p_array)
|
||||
{
|
||||
extract($p_array, EXTR_SKIP);
|
||||
$doc=new Document($this->db);
|
||||
$doc->f_id=$e_client;
|
||||
$doc->md_id=$gen_doc;
|
||||
$doc->ag_id=0;
|
||||
$p_array['e_pj']=$this->pj;
|
||||
$filename="";
|
||||
$doc->Generate($p_array, $p_array['e_pj']);
|
||||
// Move the document to the jrn
|
||||
$doc->moveDocumentPj($internal);
|
||||
// Update the comment with invoice number, if the comment is empty
|
||||
if (!isset($e_comm)||noalyss_strlentrim($e_comm)==0)
|
||||
{
|
||||
$sql="update jrn set jr_comment=' document ".$doc->d_number."' where jr_internal='$internal'";
|
||||
$this->db->exec_sql($sql);
|
||||
$id=$this->db->get_value('select jr_id from jrn where jr_internal=$1',
|
||||
[$internal]);
|
||||
if ( $id == "") {
|
||||
return;
|
||||
}
|
||||
return h($doc->d_name.' ('.$doc->d_filename.')');
|
||||
$acc_document=new Acc_Document($this->db,$id);
|
||||
$acc_document->create_document($internal,$p_array);
|
||||
return h($acc_document->d_name.' ('.$acc_document->d_filename.')');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1998,7 +2011,7 @@ class Acc_Ledger extends jrn_def_sql
|
|||
20);
|
||||
}
|
||||
/* get the account and explode if necessary */
|
||||
$sposte=$empl->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$empl->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts, take only the debit one for customer
|
||||
if (strpos($sposte, ',')!=0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
|
|||
|
||||
class Acc_Ledger_Fin extends Acc_Ledger
|
||||
{
|
||||
|
||||
public $bank_id; //! bank_id (int) FICHE.F_ID for bank
|
||||
function __construct($p_cn, $p_init)
|
||||
{
|
||||
parent::__construct($p_cn, $p_init);
|
||||
|
|
@ -73,7 +73,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
throw new Exception("Ce journal n'a pas de compte en banque, allez dans paramètre->journal pour régler cela");
|
||||
/* check if the accounting of the bank is correct */
|
||||
$fBank=new Fiche($this->db, $bank_id);
|
||||
$bank_accounting=$fBank->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$bank_accounting=$fBank->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
if (trim($bank_accounting)=='')
|
||||
throw new Exception('Le poste comptable du compte en banque de ce journal est invalide');
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT)==true)
|
||||
throw new Exception('La fiche '.${'e_other'.$i}.'n\'a pas de poste comptable', 8);
|
||||
|
||||
$sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$fiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts, take only the debit one for customer
|
||||
if (strpos($sposte, ',')!=0)
|
||||
{
|
||||
|
|
@ -520,7 +520,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
|
||||
$filter_year=" j_tech_per in (select p_id from parm_periode where p_exercice='".$exercice."')";
|
||||
|
||||
$acc_account=new Acc_Account_Ledger($this->db, $fBank->strAttribut(ATTR_DEF_ACCOUNT));
|
||||
$acc_account=new Acc_Account_Ledger($this->db, $fBank->get_attribute(ATTR_DEF_ACCOUNT));
|
||||
$asolde=$acc_account->get_solde_detail($filter_year);
|
||||
$deb=$asolde['debit'];
|
||||
$cred=$asolde['credit'];
|
||||
|
|
@ -596,7 +596,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
$fTiers=new Fiche($this->db);
|
||||
$fTiers->get_by_qcode($tiers);
|
||||
|
||||
$tiers_label=$fTiers->strAttribut(ATTR_DEF_NAME);
|
||||
$tiers_label=$fTiers->get_attribute(ATTR_DEF_NAME);
|
||||
|
||||
$r.="<TR>";
|
||||
if ($chdate==2)
|
||||
|
|
@ -604,7 +604,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
$r.="<td>".${'e_other'.$i}."</TD>";
|
||||
// label
|
||||
$r.='<TD style="width:25%;border-bottom:1px dotted grey;">';
|
||||
$r.=$fTiers->strAttribut(ATTR_DEF_NAME);
|
||||
$r.=$fTiers->get_attribute(ATTR_DEF_NAME);
|
||||
$r.='</td>';
|
||||
// Comment
|
||||
$r.='<td style="width:40%">'.$tiers_comment.'</td>';
|
||||
|
|
@ -624,7 +624,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
}
|
||||
$r.='</td>';
|
||||
// encode the pa
|
||||
if ($g_parameter->MY_ANALYTIC!='nu'&&$g_parameter->match_analytic($fTiers->strAttribut(ATTR_DEF_ACCOUNT))==1) // use of AA
|
||||
if ($g_parameter->MY_ANALYTIC!='nu'&&$g_parameter->match_analytic($fTiers->get_attribute(ATTR_DEF_ACCOUNT))==1) // use of AA
|
||||
{
|
||||
// show form
|
||||
$anc_op=new Anc_Operation($this->db);
|
||||
|
|
@ -759,10 +759,10 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
// Debit = banque
|
||||
$bank_id=$this->get_bank();
|
||||
$fBank=new Fiche($this->db, $bank_id);
|
||||
$e_bank_account=$fBank->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$e_bank_account=$fBank->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
// Get the saldo
|
||||
$pPeriode=new Periode($this->db);
|
||||
$sposte=$fBank->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$fBank->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts, take only the debit one for customer
|
||||
if (strpos($sposte, ',')!=0)
|
||||
{
|
||||
|
|
@ -869,7 +869,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
|
||||
$acc_operation=new Acc_Operation($this->db);
|
||||
$acc_operation->date=$e_date;
|
||||
$sposte=$fPoste->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$fPoste->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts
|
||||
if (strpos($sposte, ',')!=0)
|
||||
{
|
||||
|
|
@ -912,7 +912,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
|
||||
$acc_operation=new Acc_Operation($this->db);
|
||||
$acc_operation->date=$e_date;
|
||||
$sposte=$fBank->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$fBank->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
|
||||
// if 2 accounts, use the first one if DEB otherwise the second one
|
||||
if (strpos($sposte, ',')!=0)
|
||||
|
|
@ -948,8 +948,8 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
if (sql_string(${"e_other$i"."_comment"})==null)
|
||||
{
|
||||
// if comment is blank set a default one
|
||||
$comment=sprintf(_(" compte : %s a %s "), $fBank->strAttribut(ATTR_DEF_NAME),
|
||||
$fPoste->strAttribut(ATTR_DEF_NAME)
|
||||
$comment=sprintf(_(" compte : %s a %s "), $fBank->get_attribute(ATTR_DEF_NAME),
|
||||
$fPoste->get_attribute(ATTR_DEF_NAME)
|
||||
);
|
||||
}
|
||||
else
|
||||
|
|
@ -983,6 +983,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
throw new Exception (_("Erreur de balance"),EXC_BALANCE);
|
||||
|
||||
// $acc_operation->update_receipt();
|
||||
$this->jr_id=&$jr_id;
|
||||
$this->db->exec_sql('update jrn set jr_pj_number=$1 where jr_id=$2', array($acc_operation->pj, $jr_id));
|
||||
$internal=$this->compute_internal_code($seq);
|
||||
|
||||
|
|
@ -1040,7 +1041,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
}
|
||||
|
||||
// Set Internal code
|
||||
$this->grpt_id=$seq;
|
||||
$this->jr_grpt_id=$seq;
|
||||
/**
|
||||
* save also into quant_fin
|
||||
*/
|
||||
|
|
@ -1067,27 +1068,24 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
$row=td($e_date)
|
||||
.td($js_detail)
|
||||
.td(${"e_other$i"})
|
||||
.td($fPoste->strAttribut(ATTR_DEF_NAME))
|
||||
.td($fPoste->get_attribute(ATTR_DEF_NAME))
|
||||
.td(${"e_other".$i."_comment"})
|
||||
.td(nbm(${"e_other$i"."_amount"}), 'class="num"');
|
||||
$class=($i%2==0)?' class="even" ':' class="odd" ';
|
||||
$ret.=tr($row, $class);
|
||||
|
||||
if ($i==0)
|
||||
if ($i==0 && isset($_FILES['pj']) )
|
||||
{
|
||||
// first record we upload the files and
|
||||
// keep variable to update other row of jrn
|
||||
if (isset($_FILES['pj']))
|
||||
$oid=$this->db->save_receipt($seq);
|
||||
$acc_document=new Acc_Document($this->db,$jr_id);
|
||||
$oid=$acc_document->save_receipt();
|
||||
}
|
||||
else
|
||||
elseif ($oid != 0 )
|
||||
{
|
||||
if ($oid!=0)
|
||||
{
|
||||
$this->db->exec_sql("update jrn set jr_pj=$1 , jr_pj_name=$2,
|
||||
jr_pj_type=$3 where jr_grpt_id=$4",
|
||||
array($oid, $_FILES['pj']['name'], $_FILES['pj']['type'], $seq));
|
||||
}
|
||||
$this->db->exec_sql("update jrn set jr_pj=$1 , jr_pj_name=$2,
|
||||
jr_pj_type=$3 where jr_grpt_id=$4",
|
||||
array($oid, $_FILES['pj']['name'], $_FILES['pj']['type'], $seq));
|
||||
}
|
||||
} // for nbitem
|
||||
// increment pj
|
||||
|
|
@ -1132,9 +1130,9 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
{
|
||||
$this->bank_id=$this->db->get_value('select jrn_def_bank from jrn_def where jrn_def_id=$1', array($this->id));
|
||||
$fBank=new Fiche($this->db, $this->bank_id);
|
||||
$e_bank_account=" : ".$fBank->strAttribut(ATTR_DEF_BQ_NO);
|
||||
$e_bank_name=" : ".$fBank->strAttribut(ATTR_DEF_NAME);
|
||||
$e_bank_qcode=": ".$fBank->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$e_bank_account=" : ".$fBank->get_attribute(ATTR_DEF_BQ_NO);
|
||||
$e_bank_name=" : ".$fBank->get_attribute(ATTR_DEF_NAME);
|
||||
$e_bank_qcode=": ".$fBank->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
return $e_bank_qcode.$e_bank_name.$e_bank_account;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ abstract class Acc_Ledger_History
|
|||
public $db; //!< database connx
|
||||
protected $ledger_type; //! type of ledger VEN , ACH , ODS, FIN
|
||||
protected $filter_operation; //!< to filter paid, unpaid or all operation
|
||||
protected $data;//!< array of rows
|
||||
protected $data; //!< Contains data see acc_ledger_history_financial->get_row
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Database $cn
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
class Acc_Ledger_History_Generic extends Acc_Ledger_History
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param Database $cn
|
||||
|
|
@ -428,6 +427,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History
|
|||
jrn.jr_def_id as jr_def_id,
|
||||
jrn.jr_montant as montant,
|
||||
substr(jrn.jr_comment,1,35) as comment,
|
||||
jrn.jr_comment str_comment,
|
||||
to_char(jrn.jr_date,'DD-MM-YYYY') as date,
|
||||
to_char(jrn.jr_date_paid,'DD-MM-YYYY') as date_paid,
|
||||
jr_pj_number,
|
||||
|
|
@ -561,7 +561,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History
|
|||
$fiche=new Fiche($this->db);
|
||||
if ($fiche->get_by_qcode($line['j_qcode'], false)==0)
|
||||
{
|
||||
$line['description']=$fiche->strAttribut(ATTR_DEF_NAME);
|
||||
$line['description']=$fiche->get_attribute(ATTR_DEF_NAME);
|
||||
}
|
||||
}
|
||||
if ($case!=$line['grp'])
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
class Acc_Ledger_History_Purchase extends Acc_Ledger_History
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
class Acc_Ledger_History_Sale extends Acc_Ledger_History
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function __construct(\Database $cn, $pa_ledger, $p_from, $p_to,
|
||||
$p_mode)
|
||||
|
|
|
|||
|
|
@ -29,9 +29,86 @@ require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
|
|||
|
||||
/*!
|
||||
* \class Acc_Ledger_Purchase
|
||||
* \brief Handle the ledger of purchase,
|
||||
*
|
||||
*
|
||||
** @brief : input, confirm and save new operations in edger of purchase
|
||||
the $_POST data is an array with these keys
|
||||
@code
|
||||
Array
|
||||
(
|
||||
|
||||
// =====================
|
||||
// ANALYTIC PART
|
||||
// =====================
|
||||
[pa_id] => Array
|
||||
(
|
||||
[0] => 1
|
||||
)
|
||||
|
||||
[op] => Array
|
||||
(
|
||||
[0] => 0
|
||||
)
|
||||
|
||||
[amount_t0] => 10
|
||||
[hplan] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => -1
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[val] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => 10
|
||||
)
|
||||
|
||||
)
|
||||
// =====================
|
||||
// SALES DATA
|
||||
// =====================
|
||||
|
||||
[e_client] => QuickCode supplier
|
||||
[nb_item] => number of items (lines of invoice)
|
||||
[p_jrn] => JRN_DEF.JRN_DEF_ID id of the ledger
|
||||
[jrn_note_input] => Note JRN_NOTE.N_TEXT
|
||||
[mt] => 1759130008.8134
|
||||
[p_currency_rate] => Currency Rate
|
||||
[p_currency_code] => Currency Code
|
||||
[e_comm] => Description of invoice
|
||||
[e_date] => date invoice
|
||||
[e_ech] => limit date
|
||||
[e_pj] => Receipt number
|
||||
[e_pj_suggest] => suggested receipt number
|
||||
[e_mp] => payment means (
|
||||
[jrn_type] => Type of ledger (always ACH)
|
||||
//---------------------------------------------
|
||||
// For each invoice line
|
||||
//---------------------------------------------
|
||||
[e_march0] => QuickCode of the item
|
||||
[e_march0_label] => label
|
||||
[e_march0_price] => unit price
|
||||
[e_march0_tva_id] => VAT ID
|
||||
[e_march0_tva_amount] => amount of VAT
|
||||
[e_quant0] => quantity of item
|
||||
//========================
|
||||
// MISC
|
||||
//========================
|
||||
[repo] => 1 (repository)
|
||||
[gen_invoice] => on (it is asked to generate an invoice
|
||||
[gen_doc] => Document template id
|
||||
[bon_comm] => JRN_INFO.
|
||||
[other_info] = JRN_INFO.>
|
||||
[opd_name] => Name of operation template
|
||||
[od_description] => Description of operation template
|
||||
[reverse_date] => if reverse is asked
|
||||
[ext_label] => Label for revese operation
|
||||
[jr_optype] => Type of operation NOR:Normal,, EXT; reverse, ..
|
||||
)
|
||||
@endcode
|
||||
|
||||
*/
|
||||
class Acc_Ledger_Purchase extends Acc_Ledger
|
||||
{
|
||||
|
|
@ -125,7 +202,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
|
||||
|
||||
/* get the account and explode if necessary */
|
||||
$sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$fiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts, take only the credit one for supplier
|
||||
if ( strpos($sposte,',') != 0 )
|
||||
{
|
||||
|
|
@ -202,7 +279,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
throw new Exception(_('La fiche ').${'e_march'.$i}._('n\'a pas de poste comptable'),8);
|
||||
|
||||
/* get the account and explode if necessary */
|
||||
$sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$fiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts, take only the debit
|
||||
if ( strpos($sposte,',') != 0 )
|
||||
{
|
||||
|
|
@ -246,7 +323,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
}
|
||||
if ( ! $fiche->empty_attribute($key[0]) && ! $fiche->empty_attribute($key[2]))
|
||||
{
|
||||
$nd_str=$fiche->strAttribut($key[2]);
|
||||
$nd_str=$fiche->get_attribute($key[2]);
|
||||
if ( $nd_str != '')
|
||||
{
|
||||
$poste_nd=new Acc_Account_Ledger($this->db,$nd_str);
|
||||
|
|
@ -305,23 +382,23 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
{
|
||||
if (!$p_fiche->empty_attribute(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE))
|
||||
{
|
||||
$p_nd_amount->amount_nd_rate = $p_fiche->strAttribut(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE);
|
||||
$p_nd_amount->amount_nd_rate = $p_fiche->get_attribute(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE);
|
||||
$p_nd_amount->compute_nd();
|
||||
}
|
||||
if (!$p_fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE) )
|
||||
{
|
||||
$p_nd_amount->nd_vat_rate = $p_fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE);
|
||||
$p_nd_amount->nd_vat_rate = $p_fiche->get_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE);
|
||||
$p_nd_amount->compute_nd_vat();
|
||||
}
|
||||
if (!$p_fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP) )
|
||||
{
|
||||
$p_nd_amount->nd_ded_vat_rate = $p_fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP);
|
||||
$p_nd_amount->nd_ded_vat_rate = $p_fiche->get_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP);
|
||||
$p_nd_amount->compute_ndded_vat();
|
||||
}
|
||||
|
||||
if (!$p_fiche->empty_attribute(ATTR_DEF_DEP_PRIV))
|
||||
{
|
||||
$p_nd_amount->amount_perso_rate = $p_fiche->strAttribut(ATTR_DEF_DEP_PRIV);
|
||||
$p_nd_amount->amount_perso_rate = $p_fiche->get_attribute(ATTR_DEF_DEP_PRIV);
|
||||
$p_nd_amount->compute_perso();
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +434,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
/* save op. */
|
||||
if (!$p_fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND))
|
||||
{
|
||||
$dna = $p_fiche->strAttribut(ATTR_DEF_ACCOUNT_ND);
|
||||
$dna = $p_fiche->get_attribute(ATTR_DEF_ACCOUNT_ND);
|
||||
} else
|
||||
{
|
||||
$dna = $dna_default->p_value;
|
||||
|
|
@ -368,7 +445,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$p_acc_operation->amount = $p_nd_amount->amount_nd;
|
||||
$p_acc_operation->poste = $dna;
|
||||
$p_acc_operation->qcode = '';
|
||||
$p_acc_operation->desc=$this->find_label($dna)." ND ".$p_fiche->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$p_acc_operation->desc=$this->find_label($dna)." ND ".$p_fiche->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
if ($p_nd_amount->amount_nd > 0)
|
||||
$p_tot_debit = bcadd($p_tot_debit, $p_nd_amount->amount_nd );
|
||||
$j_id = $p_acc_operation->insert_jrnx();
|
||||
|
|
@ -384,7 +461,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$p_acc_operation->type = 'd';
|
||||
if (!$p_fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_PERSO))
|
||||
{
|
||||
$dna = $p_fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_PERSO);
|
||||
$dna = $p_fiche->get_attribute(ATTR_DEF_ACCOUNT_ND_PERSO);
|
||||
} else
|
||||
{
|
||||
$dna = $dna_default->p_value;
|
||||
|
|
@ -394,7 +471,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$p_acc_operation->amount = $p_nd_amount->amount_perso ;
|
||||
$p_acc_operation->poste = $dna;
|
||||
$p_acc_operation->qcode = '';
|
||||
$p_acc_operation->desc=$this->find_label($dna)." ND_PRIV ".$p_fiche->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$p_acc_operation->desc=$this->find_label($dna)." ND_PRIV ".$p_fiche->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
if ($p_nd_amount->amount_perso> 0)
|
||||
$p_tot_debit = bcadd($p_tot_debit, $p_nd_amount->amount_perso);
|
||||
$j_id = $p_acc_operation->insert_jrnx();
|
||||
|
|
@ -408,7 +485,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$p_acc_operation->qcode = '';
|
||||
if (!$p_fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_TVA_ND) )
|
||||
{
|
||||
$dna = $p_fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_TVA_ND);
|
||||
$dna = $p_fiche->get_attribute(ATTR_DEF_ACCOUNT_ND_TVA_ND);
|
||||
} else
|
||||
{
|
||||
$dna = $dna_default->p_value;
|
||||
|
|
@ -417,10 +494,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
|
||||
$p_acc_operation->amount = $p_nd_amount->nd_vat;
|
||||
$p_acc_operation->poste = $dna;
|
||||
$p_acc_operation->desc=$this->find_label($dna)." ND_TVA ".$p_fiche->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$p_acc_operation->desc=$this->find_label($dna)." ND_TVA ".$p_fiche->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
$j_id = $p_acc_operation->insert_jrnx();
|
||||
if ( $g_parameter->MY_ANALYTIC != "nu"
|
||||
&& $g_parameter->match_analytic($p_fiche->strAttribut(ATTR_DEF_ACCOUNT))
|
||||
&& $g_parameter->match_analytic($p_fiche->get_attribute(ATTR_DEF_ACCOUNT))
|
||||
)
|
||||
{
|
||||
$op=new Anc_Operation($this->db);
|
||||
|
|
@ -443,7 +520,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
/* save op. */
|
||||
if (!$p_fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_TVA) )
|
||||
{
|
||||
$dna = $p_fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_TVA);
|
||||
$dna = $p_fiche->get_attribute(ATTR_DEF_ACCOUNT_ND_TVA);
|
||||
} else
|
||||
{
|
||||
$dna = $dna_default->p_value;
|
||||
|
|
@ -456,12 +533,12 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$p_acc_operation->qcode = '';
|
||||
$p_acc_operation->amount = $p_nd_amount->nd_ded_vat;
|
||||
$p_acc_operation->poste = $dna;
|
||||
$p_acc_operation->desc=$this->find_label($dna)." DED_TVA ".$p_fiche->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$p_acc_operation->desc=$this->find_label($dna)." DED_TVA ".$p_fiche->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
if ($p_nd_amount->nd_ded_vat > 0)
|
||||
$p_tot_debit = bcadd($p_tot_debit, $p_nd_amount->nd_ded_vat);
|
||||
$j_id = $p_acc_operation->insert_jrnx();
|
||||
if ( $g_parameter->MY_ANALYTIC != "nu"
|
||||
&& $g_parameter->match_analytic($p_fiche->strAttribut(ATTR_DEF_ACCOUNT))
|
||||
&& $g_parameter->match_analytic($p_fiche->get_attribute(ATTR_DEF_ACCOUNT))
|
||||
)
|
||||
{
|
||||
$op=new Anc_Operation($this->db);
|
||||
|
|
@ -526,11 +603,11 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$this->id=$p_jrn;
|
||||
|
||||
$internal=$this->compute_internal_code($seq);
|
||||
$this->internal=$internal;
|
||||
$this->jr_internal=$internal;
|
||||
|
||||
$cust=new Fiche($this->db);
|
||||
$cust->get_by_qcode($e_client);
|
||||
$sposte=$cust->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$cust->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts, take only the credit Supplier
|
||||
if ( strpos($sposte,',') != 0 )
|
||||
{
|
||||
|
|
@ -665,7 +742,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$tot_amount=round(bcadd($tot_amount,$acc_amount->amount_perso),2);
|
||||
|
||||
/* get the account and explode if necessary */
|
||||
$sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$fiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts, take only the debit one for customer
|
||||
if ( strpos($sposte,',') != 0 )
|
||||
{
|
||||
|
|
@ -678,11 +755,11 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
}
|
||||
if ($g_parameter->MY_UPDLAB=='Y')
|
||||
{
|
||||
$acc_operation->desc=strip_tags(${"e_march".$i."_label"});
|
||||
$acc_operation->desc=strip_tags(${"e_march".$i."_label"}??"");
|
||||
}
|
||||
else
|
||||
{
|
||||
$acc_operation->desc=null;
|
||||
$acc_operation->desc="";
|
||||
}
|
||||
$acc_operation->poste=$poste_val;
|
||||
$acc_operation->amount=$acc_amount->amount;
|
||||
|
|
@ -962,7 +1039,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$this->pj=$acc_operation->update_receipt();
|
||||
|
||||
// Set Internal code
|
||||
$this->grpt_id=$seq;
|
||||
$this->jr_grpt_id=$seq;
|
||||
$this->update_internal_code($internal);
|
||||
/* update quant_purchase */
|
||||
$this->db->exec_sql('update quant_purchase set qp_internal = $1 where j_id in (select j_id from jrnx where j_grpt=$2)',
|
||||
|
|
@ -975,10 +1052,11 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
}
|
||||
|
||||
/* Save the attachment */
|
||||
if ( isset ($_FILES))
|
||||
if ( isset ($_FILES) && sizeof($_FILES) != 0 && $_FILES["pj"]["name"] != 0 )
|
||||
{
|
||||
if ( sizeof($_FILES) != 0 )
|
||||
$this->db->save_receipt($seq);
|
||||
$acc_document=new \Acc_Document($this->db, $this->jr_id);
|
||||
$acc_document->save_receipt();
|
||||
$this->doc=HtmlInput::show_receipt_document($this->jr_id,h($_FILES['pj']['name']));
|
||||
}
|
||||
$str_file="";
|
||||
/* Generate an document and save it into the database (Note de frais only)
|
||||
|
|
@ -1008,7 +1086,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
if ( $acjrn->get_type()=='FIN') {
|
||||
$acjrn=new Acc_Ledger_Fin($this->db, $mp->get_parameter('ledger_target'));
|
||||
$acfiche=new Fiche($this->db,$acjrn->get_bank());
|
||||
$fqcode=$acfiche->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$fqcode=$acfiche->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
} else {
|
||||
$fqcode = ${'e_mp_qcode_' . $e_mp};
|
||||
$acfiche = new Fiche($this->db);
|
||||
|
|
@ -1019,7 +1097,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$acc_pay->date=$e_date;
|
||||
|
||||
/* get the account and explode if necessary */
|
||||
$sposte=$acfiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte=$acfiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts, take only the debit one for customer
|
||||
if ( strpos($sposte,',') != 0 )
|
||||
{
|
||||
|
|
@ -1090,7 +1168,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
// insert into the table JRN
|
||||
$mp_jr_id=$acc_pay->insert_jrn();
|
||||
$this->payment_operation=$mp_jr_id;
|
||||
$acjrn->grpt_id=$acseq;
|
||||
$acjrn->jr_grpt_id=$acseq;
|
||||
$acjrn->update_internal_code($acinternal);
|
||||
// add an automatic PJ if ODS
|
||||
if ($acjrn->get_type()=="ODS") {
|
||||
|
|
@ -1333,10 +1411,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
{
|
||||
$fClient=new Fiche($this->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).' ';
|
||||
$e_client_label=$fClient->get_attribute(ATTR_DEF_NAME).' '.
|
||||
' Adresse : '.$fClient->get_attribute(ATTR_DEF_ADRESS).' '.
|
||||
$fClient->get_attribute(ATTR_DEF_POSTCODE).' '.
|
||||
$fClient->get_attribute(ATTR_DEF_CITY).' ';
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1402,10 +1480,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
{
|
||||
$fMarch=new Fiche($this->db);
|
||||
$fMarch->get_by_qcode($march);
|
||||
$march_label=$fMarch->strAttribut(ATTR_DEF_NAME);
|
||||
$march_label=$fMarch->get_attribute(ATTR_DEF_NAME);
|
||||
/* vat use */
|
||||
if ( ! isset($march_tva_id) && $g_parameter->MY_TVA_USE=='Y' )
|
||||
$march_tva_id=$fMarch->strAttribut(ATTR_DEF_TVA);
|
||||
$march_tva_id=$fMarch->get_attribute(ATTR_DEF_TVA);
|
||||
}
|
||||
// Show input
|
||||
//--
|
||||
|
|
@ -1414,6 +1492,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$W1->name="e_march".$i;
|
||||
$W1->value=$march;
|
||||
$W1->table=0;
|
||||
$W1->setAfter_clean("compute_all_ledger()");
|
||||
$W1->set_dblclick("fill_ipopcard(this);");
|
||||
$W1->set_attribute('ipopup','ipopcard');
|
||||
|
||||
|
|
@ -1589,9 +1668,9 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$client->get_by_qcode($e_client,true);
|
||||
|
||||
$client_name=h($client->getName().
|
||||
' '.$client->strAttribut(ATTR_DEF_ADRESS).' '.
|
||||
$client->strAttribut(ATTR_DEF_CP).' '.
|
||||
$client->strAttribut(ATTR_DEF_CITY));
|
||||
' '.$client->get_attribute(ATTR_DEF_ADRESS).' '.
|
||||
$client->get_attribute(ATTR_DEF_POSTCODE).' '.
|
||||
$client->get_attribute(ATTR_DEF_CITY));
|
||||
$lPeriode=new Periode($this->db);
|
||||
if ($this->check_periode() == true)
|
||||
{
|
||||
|
|
@ -1606,14 +1685,14 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$r .= '<div id="summary_op1">';
|
||||
$r.='<TABLE>';
|
||||
if ( $p_summary ) {
|
||||
$jr_id=$this->db->get_value('select jr_id from jrn where jr_internal=$1',array($this->internal));
|
||||
$jr_id=$this->db->get_value('select jr_id from jrn where jr_internal=$1',array($this->jr_internal));
|
||||
$r.="<tr>";
|
||||
$r.='<td>';
|
||||
$r.=_('Détail opération ');
|
||||
$r.='</td>';
|
||||
$r.='<td>';
|
||||
$r.=sprintf ('<a class="line" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a>',
|
||||
$jr_id,dossier::id(),$this->internal);
|
||||
$jr_id,dossier::id(),$this->jr_internal);
|
||||
$r.='</td>';
|
||||
$r.="</tr>";
|
||||
}
|
||||
|
|
@ -1713,7 +1792,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
if ( $g_parameter->MY_UPDLAB=='Y')
|
||||
$fiche_name=h(${"e_march".$i."_label"});
|
||||
else
|
||||
$fiche_name=$fiche->strAttribut (ATTR_DEF_NAME);
|
||||
$fiche_name=$fiche->get_attribute (ATTR_DEF_NAME);
|
||||
$amount=bcmul(${"e_march".$i."_price"},${'e_quant'.$i});
|
||||
if ( $g_parameter->MY_TVA_USE=='Y')
|
||||
{
|
||||
|
|
@ -1794,7 +1873,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$r.='</td>';
|
||||
// encode the pa
|
||||
if ( $g_parameter->MY_ANALYTIC!='nu'
|
||||
&& $g_parameter->match_analytic($fiche->strAttribut(ATTR_DEF_ACCOUNT))==TRUE
|
||||
&& $g_parameter->match_analytic($fiche->get_attribute(ATTR_DEF_ACCOUNT))==TRUE
|
||||
) // use of AA
|
||||
{
|
||||
// show form
|
||||
|
|
|
|||
|
|
@ -28,9 +28,87 @@ require_once NOALYSS_INCLUDE.'/lib/user_common.php';
|
|||
require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
|
||||
|
||||
/*!
|
||||
* \brief Handle the ledger of sold,
|
||||
*
|
||||
* @exception throw an exception is something is wrong
|
||||
* @class Acc_Ledger_Sale
|
||||
* @brief : input, confirm and save new operations in edger of sales
|
||||
the $_POST data is an array with these keys
|
||||
@code
|
||||
Array
|
||||
(
|
||||
|
||||
// =====================
|
||||
// ANALYTIC PART
|
||||
// =====================
|
||||
[pa_id] => Array
|
||||
(
|
||||
[0] => 1
|
||||
)
|
||||
|
||||
[op] => Array
|
||||
(
|
||||
[0] => 0
|
||||
)
|
||||
|
||||
[amount_t0] => 10
|
||||
[hplan] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => -1
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[val] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => 10
|
||||
)
|
||||
|
||||
)
|
||||
// =====================
|
||||
// SALES DATA
|
||||
// =====================
|
||||
|
||||
[e_client] => QuickCode customer
|
||||
[nb_item] => number of items (lines of invoice)
|
||||
[p_jrn] => JRN_DEF.JRN_DEF_ID id of the ledger
|
||||
[jrn_note_input] => Note JRN_NOTE.N_TEXT
|
||||
[mt] => 1759130008.8134
|
||||
[p_currency_rate] => Currency Rate
|
||||
[p_currency_code] => Currency Code
|
||||
[e_comm] => Description of invoice
|
||||
[e_date] => date invoice
|
||||
[e_ech] => limit date
|
||||
[e_pj] => Receipt number
|
||||
[e_pj_suggest] => suggested receipt number
|
||||
[e_mp] => payment means (
|
||||
[jrn_type] => Type of ledger (always VEN)
|
||||
//---------------------------------------------
|
||||
// For each invoice line
|
||||
//---------------------------------------------
|
||||
[e_march0] => QuickCode of the item
|
||||
[e_march0_label] => label
|
||||
[e_march0_price] => unit price
|
||||
[e_march0_tva_id] => VAT ID
|
||||
[e_march0_tva_amount] => amount of VAT
|
||||
[e_quant0] => quantity of item
|
||||
//========================
|
||||
// MISC
|
||||
//========================
|
||||
[repo] => 1 (repository)
|
||||
[gen_invoice] => on (it is asked to generate an invoice
|
||||
[gen_doc] => Document template id
|
||||
[bon_comm] => JRN_INFO.
|
||||
[other_info] = JRN_INFO.>
|
||||
[opd_name] => Name of operation template
|
||||
[od_description] => Description of operation template
|
||||
[reverse_date] => if reverse is asked
|
||||
[ext_label] => Label for revese operation
|
||||
[jr_optype] => Type of operation NOR:Normal,, EXT; reverse, ..
|
||||
)
|
||||
@endcode
|
||||
|
||||
*/
|
||||
|
||||
class Acc_Ledger_Sale extends Acc_Ledger {
|
||||
|
|
@ -118,7 +196,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
|
||||
|
||||
/* get the account and explode if necessary */
|
||||
$sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte = $fiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts, take only the debit one for customer
|
||||
if (strpos($sposte, ',') != 0) {
|
||||
$array = explode(',', $sposte);
|
||||
|
|
@ -184,7 +262,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
}
|
||||
// if 2 accounts, take only the credit one
|
||||
/* The account exists */
|
||||
$sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte = $fiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
|
||||
if (strpos($sposte, ',') != 0) {
|
||||
$array = explode(',', $sposte);
|
||||
|
|
@ -275,7 +353,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
$seq = $this->db->get_next_seq('s_grpt');
|
||||
$this->id = $p_jrn;
|
||||
$internal = $this->compute_internal_code($seq);
|
||||
$this->internal = $internal;
|
||||
$this->jr_internal = $internal;
|
||||
|
||||
$oPeriode = new Periode($this->db);
|
||||
$check_periode = $this->check_periode();
|
||||
|
|
@ -287,7 +365,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
|
||||
$cust = new Fiche($this->db);
|
||||
$cust->get_by_qcode($e_client);
|
||||
$sposte = $cust->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte = $cust->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
|
||||
// if 2 accounts, take only the debit one for the customer
|
||||
//
|
||||
|
|
@ -337,7 +415,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
$tot_amount = round($tot_amount, 2);
|
||||
$acc_operation = new Acc_Operation($this->db);
|
||||
$acc_operation->date = $e_date;
|
||||
$sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte = $fiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
|
||||
// if 2 accounts, take only the credit one
|
||||
if (strpos($sposte, ',') != 0) {
|
||||
|
|
@ -698,17 +776,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
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 (noalyss_strlentrim($_FILES['pj']['name']) != 0)
|
||||
$this->db->save_receipt($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=HtmlInput::show_receipt_document($this->jr_id,h($file));
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Save the payer
|
||||
//----------------------------------------
|
||||
|
|
@ -734,7 +802,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
if ( $acjrn->get_type()=='FIN') {
|
||||
$acjrn=new Acc_Ledger_Fin($this->db, $mp->get_parameter('ledger_target'));
|
||||
$acfiche=new Fiche($this->db,$acjrn->get_bank());
|
||||
$fqcode=$acfiche->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$fqcode=$acfiche->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
} else {
|
||||
$fqcode = ${'e_mp_qcode_' . $e_mp};
|
||||
$acfiche = new Fiche($this->db);
|
||||
|
|
@ -745,7 +813,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
$acc_pay = new Acc_Operation($this->db);
|
||||
$acc_pay->date = $pay_date;
|
||||
/* get the account and explode if necessary */
|
||||
$sposte = $acfiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$sposte = $acfiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
// if 2 accounts, take only the debit one for customer
|
||||
if (strpos($sposte, ',') != 0) {
|
||||
$array = explode(',', $sposte);
|
||||
|
|
@ -805,7 +873,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
|
||||
/* insert into jrn */
|
||||
$acc_pay->mt = $mt;
|
||||
$acjrn->grpt_id = $acseq;
|
||||
$acjrn->jr_grpt_id = $acseq;
|
||||
$acc_pay->desc = (!isset($e_comm_paiement) || noalyss_strlentrim($e_comm_paiement) == 0) ? $e_comm : $e_comm_paiement;
|
||||
$mp_jr_id = $acc_pay->insert_jrn();
|
||||
$acjrn->update_internal_code($acinternal);
|
||||
|
|
@ -892,9 +960,9 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
$client->get_by_qcode($e_client, true);
|
||||
|
||||
$client_name = $client->getName() .
|
||||
' ' . $client->strAttribut(ATTR_DEF_ADRESS) . ' ' .
|
||||
$client->strAttribut(ATTR_DEF_CP) . ' ' .
|
||||
$client->strAttribut(ATTR_DEF_CITY);
|
||||
' ' . $client->get_attribute(ATTR_DEF_ADRESS) . ' ' .
|
||||
$client->get_attribute(ATTR_DEF_POSTCODE) . ' ' .
|
||||
$client->get_attribute(ATTR_DEF_CITY);
|
||||
$lPeriode = new Periode($this->db);
|
||||
if ($this->check_periode() == true) {
|
||||
$lPeriode->p_id = $period;
|
||||
|
|
@ -906,14 +974,14 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
$r .= '<div id="summary_op1" >';
|
||||
$r.='<TABLE>';
|
||||
if ( $p_summary ) {
|
||||
$jr_id=$this->db->get_value('select jr_id from jrn where jr_internal=$1',array($this->internal));
|
||||
$jr_id=$this->db->get_value('select jr_id from jrn where jr_internal=$1',array($this->jr_internal));
|
||||
$r.="<tr>";
|
||||
$r.='<td>';
|
||||
$r.=_('Détail opération ');
|
||||
$r.='</td>';
|
||||
$r.='<td>';
|
||||
$r.=sprintf ('<a class="line" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a>',
|
||||
$jr_id,dossier::id(),$this->internal);
|
||||
$jr_id,dossier::id(),$this->jr_internal);
|
||||
$r.='</td>';
|
||||
$r.="</tr>";
|
||||
}
|
||||
|
|
@ -932,6 +1000,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
$r.='<td>' . _('Numéro Pièce') .$span.'</td><td>'. hb($this->pj) . '</td>';
|
||||
}
|
||||
}
|
||||
$e_comm=($e_comm == "")?_('Facture')." $e_pj":$e_comm;
|
||||
$r.='</tr>';
|
||||
$r.='<tr>';
|
||||
$r.='<td> ' . _('Date') . '</td><td> ' . hb($e_date) . '</td>';
|
||||
|
|
@ -954,10 +1023,10 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
$r.='</tr>';
|
||||
|
||||
$r.='<tr>';
|
||||
$r.='<td> ' . _('Client') . '</td><td> ' . hb($e_client . ':' . $client_name) . '</td>';
|
||||
$r.='<td> ' . _('Client') . '</td><td> ' . HtmlInput::card_detail($e_client).":".hb( $client_name) . '</td>';
|
||||
$r.='</tr>';
|
||||
$r.='</table>';
|
||||
$r.='<pre>'._('Note').' '.h($p_array['jrn_note_input']).'</pre>';
|
||||
$r.='<div>'._('Note').'<div id="jrn_note_td">'.$p_array['jrn_note_input'].'</div></div>';
|
||||
$r.='</div>';
|
||||
$r.='<div style="float:none;clear:both">';
|
||||
$r.='</div>';
|
||||
|
|
@ -1004,7 +1073,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
if ($g_parameter->MY_UPDLAB == 'Y')
|
||||
$fiche_name = h(${"e_march" . $i . "_label"});
|
||||
else
|
||||
$fiche_name = $fiche->strAttribut(ATTR_DEF_NAME);
|
||||
$fiche_name = $fiche->get_attribute(ATTR_DEF_NAME);
|
||||
if ($g_parameter->MY_TVA_USE == 'Y') {
|
||||
$idx_tva = ${"e_march" . $i . "_tva_id"};
|
||||
$oTva = Acc_Tva::build($this->db,$idx_tva);
|
||||
|
|
@ -1069,7 +1138,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
}
|
||||
// encode the pa
|
||||
if ($g_parameter->MY_ANALYTIC != 'nu'
|
||||
&& $g_parameter->match_analytic($fiche->strAttribut(ATTR_DEF_ACCOUNT))==TRUE) { // use of AA
|
||||
&& $g_parameter->match_analytic($fiche->get_attribute(ATTR_DEF_ACCOUNT))==TRUE) { // use of AA
|
||||
// show form
|
||||
$anc_op = new Anc_Operation($this->db);
|
||||
$null = ($g_parameter->MY_ANALYTIC == 'op') ? 1 : 0;
|
||||
|
|
@ -1296,7 +1365,8 @@ EOF;
|
|||
return $r;
|
||||
}
|
||||
|
||||
/*!\brief the function extra info allows to
|
||||
/*!
|
||||
* \brief the function extra info allows to
|
||||
* - add a attachment
|
||||
* - generate an invoice
|
||||
* - insert extra info
|
||||
|
|
@ -1304,31 +1374,35 @@ EOF;
|
|||
*/
|
||||
|
||||
public function extra_info() {
|
||||
$r = '<div id="facturation_div_id" style="height:185px;height:10rem">';
|
||||
$r = '<div id="facturation_div_id" style="display:flex;height:185px;height:10rem">';
|
||||
// check for upload piece
|
||||
$file = new IFile();
|
||||
$file->table = 0;
|
||||
$file->setAlertOnSize(true);
|
||||
$r.='<p class="decale">';
|
||||
|
||||
// add a receipt
|
||||
$r.=_("Ajoutez une pièce justificative ");
|
||||
$r.=$file->input("pj", "");
|
||||
|
||||
if ($this->db->count_sql("select md_id,md_name from document_modele where md_affect='VEN' ") > 0) {
|
||||
|
||||
|
||||
$r.=_('ou générer une facture') . ' <input type="checkbox" name="gen_invoice" CHECKED>';
|
||||
// We propose to generate the invoice and some template
|
||||
$doc_gen = new ISelect();
|
||||
$doc_gen->name = "gen_doc";
|
||||
$doc_gen->value = $this->db->make_array(
|
||||
"select md_id,md_name " .
|
||||
" from document_modele where md_affect='VEN' order by 2");
|
||||
$r.=$doc_gen->input() . '<br>';
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
// Propose to generate an invoice
|
||||
//------------------------------------------------
|
||||
$r.=_('ou générer une facture') . ' <input type="checkbox" name="gen_invoice" CHECKED>';
|
||||
// We propose to generate the invoice and some template
|
||||
$doc_gen = new ISelect();
|
||||
$doc_gen->name = "gen_doc";
|
||||
$doc_gen->value = $this->db->make_array(
|
||||
"select md_id,md_name " .
|
||||
" from document_modele where md_affect='VEN' ".
|
||||
" union select -2,'"._("0 - Facture PDF Standard")."' ".
|
||||
" order by 2");
|
||||
$r.=$doc_gen->input() . '<br>';
|
||||
|
||||
$r.='<br>';
|
||||
$obj = new IText();
|
||||
$r.=_('Numero de bon de commande : ') . $obj->input('bon_comm') . '<br>';
|
||||
$r.=_('Communication ou autre information : ') . $obj->input('other_info') . '<br>';
|
||||
$r.=_('Numero de bon de commande') . $obj->input('bon_comm') . '<br>';
|
||||
$r.=_('Communication') . $obj->input('other_info') . '<br>';
|
||||
$r.='</p>';
|
||||
$r.='</div>';
|
||||
return $r;
|
||||
|
|
@ -1478,10 +1552,10 @@ EOF;
|
|||
if (noalyss_strlentrim($e_client) != 0) {
|
||||
$fClient = new Fiche($this->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) . ' ';
|
||||
$e_client_label = $fClient->get_attribute(ATTR_DEF_NAME) . ' ' .
|
||||
' Adresse : ' . $fClient->get_attribute(ATTR_DEF_ADRESS) . ' ' .
|
||||
$fClient->get_attribute(ATTR_DEF_POSTCODE) . ' ' .
|
||||
$fClient->get_attribute(ATTR_DEF_CITY) . ' ';
|
||||
}
|
||||
|
||||
$W1 = new ICard();
|
||||
|
|
@ -1536,10 +1610,10 @@ EOF;
|
|||
if (noalyss_strlentrim($march) != 0 && noalyss_strlentrim($march_label) == 0) {
|
||||
$fMarch = new Fiche($this->db);
|
||||
$fMarch->get_by_qcode($march);
|
||||
$march_label = $fMarch->strAttribut(ATTR_DEF_NAME);
|
||||
$march_label = $fMarch->get_attribute(ATTR_DEF_NAME);
|
||||
if ($flag_tva == 'Y') {
|
||||
if (!(isset(${"e_march$i" . "_tva_id"})))
|
||||
$march_tva_id = $fMarch->strAttribut(ATTR_DEF_TVA);
|
||||
$march_tva_id = $fMarch->get_attribute(ATTR_DEF_TVA);
|
||||
}
|
||||
}
|
||||
// Show input
|
||||
|
|
@ -1549,6 +1623,7 @@ EOF;
|
|||
$W1->name = "e_march" . $i;
|
||||
$W1->value = $march;
|
||||
$W1->table = 0;
|
||||
$W1->setAfter_clean("compute_all_ledger()");
|
||||
$W1->set_attribute('typecard', 'cred');
|
||||
$W1->set_dblclick("fill_ipopcard(this);");
|
||||
$W1->set_attribute('ipopup', 'ipopcard');
|
||||
|
|
@ -1778,7 +1853,59 @@ EOF;
|
|||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief convert an Acc_Sold to an array usable by
|
||||
* Acc_Document::create_document
|
||||
* @parameters $sold (Acc_Sold) convert to convert
|
||||
*/
|
||||
static function convert_to_array(Acc_Sold $sold)
|
||||
{
|
||||
//print $sold;
|
||||
$item=count($sold->det->array);
|
||||
if ( $item ==0)
|
||||
{
|
||||
throw new \Exception('No Data in Quant_sold');
|
||||
}
|
||||
$array=array();
|
||||
|
||||
$array['e_ech']=format_date($sold->det->jr_ech);
|
||||
$array['e_comm']=$sold->det->jr_comment;
|
||||
$array['p_jrn']=$sold->det->jr_def_id;
|
||||
$array['nb_item']=$item;
|
||||
$array['ledger_type']=$sold->signature;
|
||||
$array['e_date']= format_date($sold->det->jr_date);
|
||||
$array['e_pj']= $sold->det->jr_pj_number;
|
||||
$array['jr_date_paid']=$sold->det->jr_date_paid;
|
||||
|
||||
//$this->pj=$array['e_pj'];
|
||||
$array['internal']=$sold->det->jr_internal;
|
||||
|
||||
$client=new \Fiche($sold->db,$sold->det->array[0]['qs_client']);
|
||||
$array['e_client']=$client->get_quick_code();
|
||||
bcscale(2);
|
||||
for ($i=0;$i < $item ; $i++)
|
||||
{
|
||||
$idx='e_march';
|
||||
$serv=new \Fiche($sold->db,$sold->det->array[$i]['qs_fiche']);
|
||||
$array[$idx.$i]=$serv->get_quick_code();
|
||||
$array[$idx.$i.'_label']=$sold->det->array[$i]['j_text'];
|
||||
$array[$idx.$i.'_price']=bcdiv($sold->det->array[$i]['qs_price'],$sold->det->array[$i]['qs_quantite']);
|
||||
$array[$idx.$i.'_tva_id']=$sold->det->array[$i]['qs_vat_code'];
|
||||
$array[$idx.$i.'_tva_amount']=bcsub($sold->det->array[$i]['qs_vat'],$sold->det->array[$i]['qs_vat_sided']);
|
||||
$array['e_quant'.$i]=$sold->det->array[$i]['qs_quantite'];
|
||||
}
|
||||
// Get OTHER_INFO and BON_COMM
|
||||
$cn=\Dossier::connect();
|
||||
$array['bon_comm']=$cn->get_value("select ji_value from jrn_info where jr_id=$1 and id_type = 'BON_COMMANDE' ",[$sold->det->jr_id]);
|
||||
$array['other_info']=$cn->get_value("select ji_value from jrn_info where jr_id=$1 and id_type = 'OTHER' ",[$sold->det->jr_id]);
|
||||
$array['jrn_note_input']=$cn->get_value("select n_text from
|
||||
jrn_note where jr_id=$1 ",[$sold->det->jr_id]);
|
||||
$array['p_currency_code']=$sold->det->currency_id;
|
||||
$array['p_currency_rate']=$sold->det->currency_rate;
|
||||
return $array;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ class Acc_Ledger_Search
|
|||
|
||||
protected $cn; //!< Database Connection
|
||||
private $type; //!< type of ledger : FIN,ODS,VEN,ACH
|
||||
private $all; //!< Flag to indicate if all ledgers must searched (1 for yes)
|
||||
private $div; //! prefix for id of DOM id
|
||||
//! id of the ledger
|
||||
var $id ;
|
||||
private $all; //!< Flag to indicate if all ledgers must be searched (1 for yes)
|
||||
private $div; //!< prefix for id of DOM id
|
||||
var $id ; //!< id of the ledger
|
||||
|
||||
/**
|
||||
* @brief return a HTML string with the form for the search
|
||||
* @param $p_type if the type of ledger possible values=ALL,VEN,ACH,ODS,FIN: uppercase !
|
||||
|
|
@ -47,9 +47,9 @@ class Acc_Ledger_Search
|
|||
* - 1 means all the ledger of this type
|
||||
* - 0 No have the "Tous les journaux" availables
|
||||
* @param $div is the div (for reconciliation)
|
||||
* @param type $p_type
|
||||
* @param type $p_all
|
||||
* @param type $p_div
|
||||
* @param string $p_type ACH, VEN , ODS or FIN
|
||||
* @param int $p_all 1 means all the ledger
|
||||
* @param string $p_div prefix of the DOM ID
|
||||
*
|
||||
* @todo the parameter $all_type_ledger is useless : ALL means all the ledgers, VEN all the ledger of sales...
|
||||
*/
|
||||
|
|
@ -196,7 +196,7 @@ class Acc_Ledger_Search
|
|||
$f_qcode->javascript=sprintf(' onchange="fill_data_onchange(%s);" ',
|
||||
$f_qcode->name);
|
||||
$f_qcode->value=$http->request($this->div.'qcode',"string","");
|
||||
|
||||
$f_qcode->setAfter_clean("");
|
||||
/* $f_txt_qcode=new IText('qcode');
|
||||
$f_txt_qcode->value=(isset($_REQUEST['qcode']))?$_REQUEST['qcode']:'';
|
||||
*/
|
||||
|
|
@ -258,7 +258,7 @@ class Acc_Ledger_Search
|
|||
}
|
||||
|
||||
/**
|
||||
* Build the button for managing the filter for search
|
||||
* @brief Build the button for managing the filter for search
|
||||
* @param type $p_div id prefix of the div, button, table ..
|
||||
* @param $this->type if the type of ledger possible values=ALL,VEN,ACH,ODS,FIN
|
||||
* @param $all_type_ledger
|
||||
|
|
@ -343,6 +343,7 @@ class Acc_Ledger_Search
|
|||
p_closed,
|
||||
jr_pj_number,
|
||||
n_text,
|
||||
n_html,
|
||||
(select string_agg(a,' ')
|
||||
from (select '<span style=\"font-size:80%\" class=\"tagcell tagcell-color'||t.t_color::text||'\">'||t_tag||'</span>' a
|
||||
from operation_tag ot join tags t on(ot.tag_id=t.t_id)
|
||||
|
|
@ -943,7 +944,14 @@ class Acc_Ledger_Search
|
|||
if ( $row['analytic_op'] != "")
|
||||
$r.=sprintf('<span style="float:right;background:black;color:white;">∋</span>');
|
||||
$r.="</TD>";
|
||||
$r.=td(h($row['n_text']), ' style="font-size:0.87em%"');
|
||||
// Note
|
||||
$r.='<td>';
|
||||
$r.='<span id="als_note'.$row['jr_id'].'" class="font-small">';
|
||||
$r.= substr($row['n_text']??"",0,120);
|
||||
$r.='<span>';
|
||||
$r.='</span>';
|
||||
$r.='</td>';
|
||||
|
||||
// Amount
|
||||
// If the ledger is financial :
|
||||
// the credit must be negative and written in red
|
||||
|
|
@ -1241,22 +1249,21 @@ class Acc_Ledger_Search
|
|||
return array($count, $r);
|
||||
}
|
||||
/**
|
||||
* return the html code to create an hidden div and a button
|
||||
* @brief return the html code to create an hidden div and a button
|
||||
* to show this DIV. This contains all the available ledgers
|
||||
* for the user in READ or RW
|
||||
*@param $p_selected is an array of checkbox
|
||||
*@param $p_div div suffix for the list of ledgers
|
||||
*@param $p_div div suffix for the list of ledgers, base for building the DOMID of elements from the DIV
|
||||
*@note the choosen ledger are stored in the array r_jrn (_GET)
|
||||
*/
|
||||
function select_ledger($p_selected,$p_div)
|
||||
{
|
||||
global $g_user;
|
||||
$r = '';
|
||||
/* security : filter ledger on user */
|
||||
$p_array = $g_user->get_ledger($this->type, 3,FALSE);
|
||||
|
||||
$r = '';
|
||||
/* security : filter ledger on user */
|
||||
$p_array = $g_user->get_ledger($this->type, 3,false);
|
||||
ob_start();
|
||||
|
||||
|
||||
|
||||
/* create a hidden div for the ledger */
|
||||
echo '<div id="div_jrn'.$p_div.'" >';
|
||||
|
|
@ -1291,7 +1298,7 @@ class Acc_Ledger_Search
|
|||
for ($e=0;$e<$nb_array;$e++)
|
||||
{
|
||||
$row=$p_array[$e];
|
||||
// if ( $row['jrn_enable']==0) continue;
|
||||
|
||||
$r=new ICheckBox($p_div.'r_jrn'.$e,$row['jrn_def_id']);
|
||||
$r->set_attribute("ledger_type", $row['jrn_def_type']);
|
||||
$idx=$row['jrn_def_id'];
|
||||
|
|
|
|||
|
|
@ -64,14 +64,14 @@ class Acc_Operation
|
|||
* \brief constructor set automatically the attributes user and periode
|
||||
* \param $p_cn the databse connection
|
||||
*/
|
||||
function __construct($p_cn)
|
||||
function __construct($p_cn,$p_jrid=0)
|
||||
{
|
||||
global $g_user;
|
||||
$this->db=$p_cn;
|
||||
$this->qcode="";
|
||||
$this->user=$_SESSION[SESSION_KEY.'g_user'];
|
||||
$this->periode=$g_user->get_periode();
|
||||
$this->jr_id=0;
|
||||
$this->jr_id=$p_jrid;
|
||||
$this->jr_optype="NOR";
|
||||
$this->amount=0;
|
||||
$this->currency_rate=1;
|
||||
|
|
@ -84,16 +84,16 @@ class Acc_Operation
|
|||
$r=<<<EOF
|
||||
Acc_Operation Object
|
||||
[
|
||||
db {$this->db}
|
||||
|
||||
qcode {$this->qcode}
|
||||
user {$this->user}
|
||||
periode {$this->periode}
|
||||
jr_id {$this->jr_id}
|
||||
jr_optype {$this->jr_optype}
|
||||
amount {$this->amount}
|
||||
currency_rate {$this->amount}
|
||||
currency_rate_ref {$this->amount}
|
||||
currency_id {$this->amount}
|
||||
currency_rate {$this->currency_rate}
|
||||
currency_rate_ref {$this->currency_rate_ref}
|
||||
currency_id {$this->currency_id}
|
||||
]
|
||||
EOF;
|
||||
return $r;
|
||||
|
|
@ -394,7 +394,7 @@ EOF;
|
|||
{
|
||||
if ( ! isset($this->jr_id) )
|
||||
throw new Exception('jr_id is not set',1);
|
||||
$Res=$this->db->exec_sql("select jr_internal from jrn where jr_id=".$this->jr_id);
|
||||
$Res=$this->db->exec_sql("select jr_internal from jrn where jr_id=$1",[$this->jr_id]);
|
||||
if ( Database::num_row($Res) == 0 ) return null;
|
||||
$l_line=Database::fetch_array($Res);
|
||||
$this->jr_internal= $l_line['jr_internal'];
|
||||
|
|
@ -436,19 +436,25 @@ EOF;
|
|||
$all=Database::fetch_all($res);
|
||||
return $all;
|
||||
}
|
||||
/*!\brief add a comment to the line (jrnx.j_text) */
|
||||
/*!
|
||||
* \brief add a comment to the line (jrnx.j_text)
|
||||
*/
|
||||
function update_comment($p_text)
|
||||
{
|
||||
$sql="update jrnx set j_text=$1 where j_id=$2";
|
||||
$this->db->exec_sql($sql,array($p_text,$this->jrnx_id));
|
||||
}
|
||||
/*!\brief add a comment to the operation (jrn.jr_text) */
|
||||
/*!
|
||||
* \brief add a comment to the operation (jrn.jr_text)
|
||||
*/
|
||||
function operation_update_comment($p_text)
|
||||
{
|
||||
$sql="update jrn set jr_comment=$1 where jr_id=$2";
|
||||
$this->db->exec_sql($sql,array($p_text,$this->jr_id));
|
||||
}
|
||||
/*!\brief add a limit of payment to the operation (jrn.jr_ech) */
|
||||
/*!
|
||||
* \brief add a limit of payment to the operation (jrn.jr_ech)
|
||||
*/
|
||||
function operation_update_date_limit($p_text)
|
||||
{
|
||||
if ( isDate($p_text) == null )
|
||||
|
|
@ -458,7 +464,9 @@ EOF;
|
|||
$sql="update jrn set jr_ech=to_date($1,'DD.MM.YYYY') where jr_id=$2";
|
||||
$this->db->exec_sql($sql,array($p_text,$this->jr_id));
|
||||
}
|
||||
/*!\brief return the jrn_def_id from jrn */
|
||||
/*!
|
||||
* \brief return the jrn_def_id from jrn
|
||||
*/
|
||||
function get_ledger()
|
||||
{
|
||||
$sql="select jr_def_id from jrn where jr_id=$1";
|
||||
|
|
@ -1023,11 +1031,43 @@ EOF;
|
|||
/**
|
||||
* @class Acc_Detail
|
||||
* @brief Contains the detail of an operation Acc_Operation
|
||||
* propery :
|
||||
* - $det
|
||||
- jr_id PKfrom table JRN
|
||||
- jr_def_id id of the ledger (FK to - _DEF- _DEF_ID)from table JRN
|
||||
- jr_montant AMOUNT of the operationfrom table JRN
|
||||
- jr_comment COMMENT from table JRN
|
||||
- jr_date DATEfrom table JRN
|
||||
- jr_grpt_id CODE to group - X rowsfrom table JRN
|
||||
- jr_internal INTERNAL CODEfrom table JRN
|
||||
- jr_tech_date DATE OF CHANGEfrom table JRN
|
||||
- jr_tech_per FK TO PARAM_PERIODEP_IDfrom table JRN
|
||||
- jrn_ech from table JRN
|
||||
- jr_ech DATE LIMIT OF PAYMENTfrom table JRN
|
||||
- jr_rapt from table JRN
|
||||
- jr_echfrom table JRN
|
||||
- jr_validfrom table JRN
|
||||
- jr_opid from table JRN
|
||||
- jr_c_opidfrom table JRN
|
||||
- jr_pj OID OF THE DOCUMENTfrom table JRN
|
||||
- jr_pj_name NAME OF THE DOCUMENTfrom table JRN
|
||||
- jr_pj_typefrom table JRN
|
||||
- jr_pj_number RECEIPT NBfrom table JRN
|
||||
- jr_mt INTERNAL CODEfrom table JRN
|
||||
- jr_raptfrom table JRN
|
||||
- jr_date_paid DATE OF PAYMENTfrom table JRN
|
||||
- jr_optype TYPE OF OPERATION NOR = NORMAL OPE=OPENING EXT=EXTOURNEfrom table JRN
|
||||
- currency_id FK TO CURRENCYIDfrom table JRN
|
||||
- currency_rate amountfrom table JRN
|
||||
- currency_rate_ref amount in CURRENT_HISTORYCH_VALUEfrom table JRN
|
||||
* - note from table JRN_NOTE
|
||||
- $jr_id JRN.JR_ID
|
||||
- $info
|
||||
*/
|
||||
class Acc_Detail extends Acc_Operation
|
||||
{
|
||||
public $det;
|
||||
public $jr_id;
|
||||
public $det;//!< Object with columns from JRN
|
||||
public $jr_id;//! $jr_id (int) JRN.JR_ID
|
||||
public $info;
|
||||
|
||||
function __construct($p_cn,$p_jrid=0)
|
||||
|
|
@ -1042,10 +1082,34 @@ class Acc_Detail extends Acc_Operation
|
|||
*/
|
||||
function get()
|
||||
{
|
||||
$sql="SELECT jr_id, jr_def_id, jr_montant, jr_comment, jr_date, jr_grpt_id,
|
||||
jr_internal, jr_tech_date, jr_tech_per, jrn_ech, jr_ech, jr_rapt,jr_ech,
|
||||
jr_valid, jr_opid, jr_c_opid, jr_pj, jr_pj_name, jr_pj_type,
|
||||
jr_pj_number, jr_mt,jr_rapt,jr_date_paid,jr_optype,currency_id,currency_rate,currency_rate_ref
|
||||
$sql="SELECT jr_id
|
||||
, jr_def_id
|
||||
, jr_montant
|
||||
, jr_comment
|
||||
, jr_date
|
||||
, jr_grpt_id
|
||||
, jr_internal
|
||||
, jr_tech_date
|
||||
, jr_tech_per
|
||||
, jrn_ech
|
||||
, jr_ech
|
||||
, jr_rapt
|
||||
,jr_ech
|
||||
, jr_valid
|
||||
, jr_opid
|
||||
, jr_c_opid
|
||||
, jr_pj
|
||||
, jr_pj_name
|
||||
, jr_pj_type,
|
||||
jr_pj_number
|
||||
, jr_mt
|
||||
,jr_rapt
|
||||
,jr_date_paid
|
||||
,jr_optype
|
||||
,currency_id
|
||||
,currency_rate
|
||||
,currency_rate_ref
|
||||
,jr_document_xml
|
||||
FROM jrn where jr_id=$1";
|
||||
$array=$this->db->get_array($sql,array($this->jr_id));
|
||||
if ( count($array) == 0 ) throw new Exception('Aucune ligne trouvée');
|
||||
|
|
@ -1053,9 +1117,15 @@ class Acc_Detail extends Acc_Operation
|
|||
{
|
||||
$this->det->$key=$val;
|
||||
}
|
||||
$sql="select n_text from jrn_note where jr_id=$1";
|
||||
$this->det->note=$this->db->get_value($sql,array($this->jr_id));
|
||||
$this->det->note=strip_tags($this->det->note);
|
||||
$sql="select n_text,n_html from jrn_note where jr_id=$1";
|
||||
$a=$this->db->get_row($sql,array($this->jr_id));
|
||||
if ( empty($a)) {
|
||||
$this->det->note="";
|
||||
$this->det->note_html=null;
|
||||
} else {
|
||||
$this->det->note=strip_tags($a['n_text']??"");
|
||||
$this->det->note_html=($a['n_html'] == "")?$a['n_text']:$a['n_html'];
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
|
@ -1069,6 +1139,15 @@ class Acc_Detail extends Acc_Operation
|
|||
$array['p_jrn']=$this->det->jr_def_id;
|
||||
return $array;
|
||||
|
||||
}
|
||||
function __toString(): string
|
||||
{
|
||||
$r= __CLASS__;
|
||||
$r.="this->signature ".$this->signature."\n";
|
||||
$r.="this->det ".print_r($this->det,true);
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -1140,6 +1219,15 @@ SELECT jx1.j_id
|
|||
|
||||
return $array;
|
||||
|
||||
}
|
||||
function __toString(): string
|
||||
{
|
||||
$r= __CLASS__;
|
||||
$r.="this->signature ".$this->signature."\n";
|
||||
$r.="this->det ".print_r($this->det,true);
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -1155,33 +1243,33 @@ class Acc_Sold extends Acc_Detail
|
|||
{
|
||||
parent::__construct($p_cn,$p_jrid);
|
||||
$this->signature='VEN';
|
||||
$this->det=new stdClass();
|
||||
$this->det->array=new stdClass();
|
||||
}
|
||||
function get()
|
||||
{
|
||||
parent::get();
|
||||
$sql="
|
||||
select qs_id, qs_internal
|
||||
, jx1.j_id
|
||||
, qs1.qs_fiche
|
||||
, qs1.qs_quantite
|
||||
, qs1.qs_price
|
||||
, qs1.qs_vat
|
||||
, qs1.qs_vat_code
|
||||
, qs1.qs_client
|
||||
, qs1.qs_valid
|
||||
, jx1.j_text
|
||||
, qs_vat_sided
|
||||
, qs_unit
|
||||
, jx1.j_debit
|
||||
,oc1.oc_amount
|
||||
,oc1.oc_vat_amount
|
||||
,oc1.oc_price_unit
|
||||
from quant_sold qs1
|
||||
join jrnx jx1 using(j_id)
|
||||
left join operation_currency oc1 using(j_id)
|
||||
where jx1.j_grpt = $1
|
||||
order by jx1.j_id;
|
||||
, jx1.j_id
|
||||
, qs1.qs_fiche
|
||||
, qs1.qs_quantite
|
||||
, qs1.qs_price
|
||||
, qs1.qs_vat
|
||||
, qs1.qs_vat_code
|
||||
, qs1.qs_client
|
||||
, qs1.qs_valid
|
||||
, jx1.j_text
|
||||
, qs_vat_sided
|
||||
, qs_unit
|
||||
, jx1.j_debit
|
||||
,oc1.oc_amount
|
||||
,oc1.oc_vat_amount
|
||||
,oc1.oc_price_unit
|
||||
from quant_sold qs1
|
||||
join jrnx jx1 using(j_id)
|
||||
left join operation_currency oc1 using(j_id)
|
||||
where jx1.j_grpt = $1
|
||||
order by jx1.j_id;
|
||||
";
|
||||
$this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
|
||||
}
|
||||
|
|
@ -1214,7 +1302,15 @@ order by jx1.j_id;
|
|||
return $array;
|
||||
|
||||
}
|
||||
|
||||
function __toString(): string
|
||||
{
|
||||
$r="";
|
||||
$r.="this->signature ".$this->signature."\n";
|
||||
$r.="this->det ".print_r($this->det,true);
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
|
|
@ -1297,7 +1393,15 @@ order by jx1.j_id
|
|||
return $array;
|
||||
|
||||
}
|
||||
|
||||
function __toString(): string
|
||||
{
|
||||
$r= __CLASS__;
|
||||
$r.="this->signature ".$this->signature."\n";
|
||||
$r.="this->det ".print_r($this->det,true);
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -1354,5 +1458,14 @@ class Acc_Fin extends Acc_Detail
|
|||
$array['correct']=1;
|
||||
return $array;
|
||||
|
||||
}
|
||||
function __toString(): string
|
||||
{
|
||||
$r= __CLASS__;
|
||||
$r.="this->signature ".$this->signature."\n";
|
||||
$r.="this->det ".print_r($this->det,true);
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Acc_Operation_Note
|
|||
private $id;
|
||||
private $operation_id; //!< jrn.jr_id
|
||||
private $jrn_note_sql;
|
||||
|
||||
|
||||
function __construct(Jrn_Note_SQL $p_Jrn_Note_SQL)
|
||||
{
|
||||
$this->jrn_note_sql = $p_Jrn_Note_SQL;
|
||||
|
|
@ -79,12 +79,18 @@ class Acc_Operation_Note
|
|||
{
|
||||
$cn=Dossier::connect();
|
||||
$this->jrn_note_sql->setp("jr_id",$this->operation_id);
|
||||
$this->jrn_note_sql->setp("n_text",$this->note);
|
||||
$this->jrn_note_sql->setp("n_text", strip_tags($this->note));
|
||||
|
||||
if ( empty($this->jrn_note_sql->n_text) && $this->id > -1 ) {
|
||||
$this->jrn_note_sql->delete();
|
||||
return $this;
|
||||
}
|
||||
// forbid the tag script, iframe and A
|
||||
$n=str_ireplace('<script','<.script',$this->note);
|
||||
$n=str_ireplace('<iframe','<.iframe',$n);
|
||||
$n=str_ireplace('<a ','<.a',$n);
|
||||
|
||||
$this->jrn_note_sql->setp("n_html", $n);
|
||||
$this->jrn_note_sql->save();
|
||||
$this->id=$this->jrn_note_sql->n_id;
|
||||
return $this;
|
||||
|
|
@ -121,6 +127,19 @@ class Acc_Operation_Note
|
|||
}
|
||||
function print()
|
||||
{
|
||||
echo '<pre id="print_note">'.h($this->note).'</pre>';
|
||||
echo '<div id="print_note">'.h($this->note).'</div>';
|
||||
}
|
||||
/**
|
||||
* @brief create a TEXTAREA to show HTML Note
|
||||
* @param type $div_id
|
||||
* @returns ITextarea
|
||||
*/
|
||||
static function build_textarea($div_id)
|
||||
{
|
||||
$inote = new ITextarea('jrn_note');
|
||||
$inote->id="{$div_id}_jrn_note";
|
||||
$inote->set_enrichText("no-toolbar");
|
||||
$inote->heigh=500;
|
||||
return $inote;
|
||||
}
|
||||
}
|
||||
|
|
@ -275,7 +275,7 @@ class Acc_Payment
|
|||
$fiche->get_by_qcode($row->mp_qcode);
|
||||
$f=HtmlInput::hidden('e_mp_qcode_'.$row->mp_id,$row->mp_qcode);
|
||||
|
||||
// $f.=$fiche->strAttribut(ATTR_DEF_NAME);
|
||||
// $f.=$fiche->get_attribute(ATTR_DEF_NAME);
|
||||
}
|
||||
$check=( $p_select == $row->mp_id)?" checked " : "unchecked";
|
||||
$r.='<li><input type="radio" name="e_mp" value="'.$row->mp_id.'" '.$check.'>';
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@
|
|||
"label"=>"tva_label",
|
||||
"rate"=>"tva_rate",
|
||||
"comment"=>"tva_comment",
|
||||
"account"=>"tva_poste");
|
||||
"account"=>"tva_poste"
|
||||
tva_peppol_code
|
||||
'vx_code'
|
||||
* );
|
||||
|
||||
*/
|
||||
class Acc_Tva
|
||||
|
|
@ -42,7 +45,11 @@ class Acc_Tva
|
|||
"account"=>"tva_poste",
|
||||
"both_side"=>'tva_both_side',
|
||||
'tva_reverse_account'=>'tva_reverse_account',
|
||||
'tva_code'=>'tva_code');
|
||||
'tva_code'=>'tva_code',
|
||||
"tva_peppol_code"=>"tva_peppol_code",
|
||||
'vx_code'=>'vx_code'
|
||||
|
||||
);
|
||||
public $tva_id,
|
||||
$tva_label,
|
||||
$tva_rate,
|
||||
|
|
@ -50,16 +57,19 @@ class Acc_Tva
|
|||
$tva_poste,
|
||||
$tva_both_side,
|
||||
$tva_code,
|
||||
$tva_reverse_account;
|
||||
$tva_reverse_account,
|
||||
$tva_peppol_code,
|
||||
$vx_code
|
||||
;
|
||||
|
||||
private $cn; //!< Database connection
|
||||
|
||||
private Tva_Rate_SQL $tva_rate_sql;
|
||||
|
||||
function __construct ($p_init,$p_tva_id=-1)
|
||||
function __construct (Database $cn,$p_tva_id=-1)
|
||||
{
|
||||
$this->cn=$p_init;
|
||||
$this->tva_rate_sql=new Tva_Rate_SQL($p_init,$p_tva_id);
|
||||
$this->cn=$cn;
|
||||
$this->tva_rate_sql=new Tva_Rate_SQL($cn,$p_tva_id);
|
||||
$this->tva_id=$p_tva_id;
|
||||
$this->tva_label=&$this->tva_rate_sql->tva_label;
|
||||
$this->tva_rate=&$this->tva_rate_sql->tva_rate;
|
||||
|
|
@ -68,6 +78,8 @@ class Acc_Tva
|
|||
$this->tva_both_side=&$this->tva_rate_sql->tva_both_side;
|
||||
$this->tva_code=&$this->tva_rate_sql->tva_code;
|
||||
$this->tva_reverse_account=&$this->tva_rate_sql->tva_reverse_account;
|
||||
$this->tva_peppol_code=&$this->tva_rate_sql->tva_peppol_code;
|
||||
$this->vx_code=&$this->tva_rate_sql->vx_code;
|
||||
|
||||
}
|
||||
/**
|
||||
|
|
@ -103,7 +115,7 @@ class Acc_Tva
|
|||
{
|
||||
$idx=self::$variable[$p_string];
|
||||
$this->$idx=$p_value;
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new Exception("ACC108"."Attribut inexistant $p_string",EXC_INVALID);
|
||||
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ class Action_Document_Type_MTable extends Manage_Table_SQL
|
|||
$cn->rollback();
|
||||
|
||||
echo $exc->getMessage();
|
||||
error_log($exc->getTraceAsString());
|
||||
record_log($exc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
class Anc_Acc_List extends Anc_Acc_Link
|
||||
{
|
||||
var $arow; //!< $arow array of row from
|
||||
var $card_poste;
|
||||
/**
|
||||
*@brief display form to get the parameter
|
||||
* - card_poste 1 by card, 2 by account
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ class Anc_Balance_Double extends Anc_Print
|
|||
*
|
||||
* \return string
|
||||
*/
|
||||
|
||||
public $from_poste2;
|
||||
public $to_poste2;
|
||||
public $pa_id2;
|
||||
function display_html ()
|
||||
{
|
||||
if ($this->pa_id == $this->pa_id2) throw new Exception(_("Pas de croisement avec un seul plan"),1000);
|
||||
|
|
|
|||
|
|
@ -30,10 +30,11 @@ require_once NOALYSS_INCLUDE.'/constant.php';
|
|||
*/
|
||||
class Anc_Group extends Anc_Print
|
||||
{
|
||||
var $db;
|
||||
var $ga_id;
|
||||
var $ga_description;
|
||||
var $pa_id;
|
||||
var $db; /*!< $db (Database) Database connexion */
|
||||
var $ga_id; /*!< $ga_id (int) PK GROUPE_ANALYTIQUE.GA_ID */
|
||||
var $ga_description; /*!< $ga_description (string) name of the group */
|
||||
var $pa_id; /*!< $pa_id (int) id PLAN_ANALYTIC.PA_ID */
|
||||
var $pa_name; /*!< $pa_name (string) name of the Analytic Axis */
|
||||
|
||||
function __construct ( $p_cn )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class Anc_Group_Operation
|
|||
var $a_operation; /*!< array of operations */
|
||||
var $date; /*!< date of the operations */
|
||||
var $pa_id; /*!< the concerned pa_id */
|
||||
|
||||
var $nMaxRow; /*!< $nMaxRow (int) max row to display */
|
||||
/*!\brief constructor */
|
||||
function __construct($p_cn,$p_id=0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,6 +39,13 @@ class Anc_Key
|
|||
{
|
||||
|
||||
private $key; /*! the distribution key */
|
||||
protected $a_ledger ; /*!< array of ledger (JRN_DEF.JRN_DEF_ID) for
|
||||
* which the key is available*/
|
||||
protected $a_activity; /*!< array of activity for
|
||||
* which the key is available*/
|
||||
protected $a_row; /*!< array of row from key_distribution_detail
|
||||
* , detail of the key*/
|
||||
|
||||
/**
|
||||
*@brief Return the number of keys available.
|
||||
* Return the number of keys available for the ledger given in parameter
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@
|
|||
|
||||
class Anc_Table extends Anc_Acc_Link
|
||||
{
|
||||
public $card_poste;
|
||||
private $aheader;
|
||||
private $sql;
|
||||
private $arow;
|
||||
function __construct($p_cn)
|
||||
{
|
||||
parent::__construct($p_cn);
|
||||
|
|
|
|||
|
|
@ -290,7 +290,17 @@ EOF;
|
|||
$this->cn->commit();
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief load all the existing forecast
|
||||
*@param $p_cn is an Database object
|
||||
*@return array of f_id and f_name
|
||||
*/
|
||||
public static function load_all($p_cn)
|
||||
{
|
||||
$sql="select f_id, f_name,f_start_date,f_end_date from forecast order by 2 desc";
|
||||
$ret=$p_cn->get_array($sql);
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ class Balance_Age
|
|||
$fiche=new Fiche($this->cn, $p_extra);
|
||||
$this->afiche[0]['f_id']=$fiche->id;
|
||||
$this->afiche[0]['quick_code']=$fiche->get_quick_code();
|
||||
$this->afiche[0]['name']=$fiche->strAttribut(ATTR_DEF_NAME, 0);
|
||||
$this->afiche[0]['first_name']=$fiche->strAttribut(ATTR_DEF_FIRST_NAME, 0);
|
||||
$this->afiche[0]['name']=$fiche->get_attribute(ATTR_DEF_NAME, 0);
|
||||
$this->afiche[0]['first_name']=$fiche->get_attribute(ATTR_DEF_FIRST_NAME, 0);
|
||||
break;
|
||||
case 'F':
|
||||
$this->afiche=$this->cn->get_array("
|
||||
|
|
|
|||
|
|
@ -33,12 +33,10 @@ require_once NOALYSS_INCLUDE.'/lib/user_common.php';
|
|||
class Bank extends Fiche
|
||||
{
|
||||
|
||||
var $name; /*!< $name name of the company */
|
||||
var $street; /*!< $street Street */
|
||||
var $country; /*!< $country Country */
|
||||
var $cp; /*!< $cp Zip code */
|
||||
var $vat_number; /*!< $vat_number vat number */
|
||||
|
||||
|
||||
use Trait_Card;
|
||||
|
||||
/*! \brief Constructor only a db connection is needed */
|
||||
function __construct($p_cn,$p_id=0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class Card_PDF extends \PDF
|
|||
$this->card=new \Fiche ($cn,$p_card_id);
|
||||
$this->card->load();
|
||||
parent::__construct($cn, "P");
|
||||
$this->setDossierInfo($this->card->strAttribut(ATTR_DEF_QUICKCODE));
|
||||
$this->setDossierInfo($this->card->get_attribute(ATTR_DEF_QUICKCODE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -46,8 +46,8 @@ class Card_PDF extends \PDF
|
|||
if ($nb_attribut == 0) {
|
||||
throw new \Exception(_("card_pdf.044 , card_inexistante"));
|
||||
}
|
||||
$this->setTitle($this->card->get_quick_code()." ".strtoupper($this->card->strAttribut(1))
|
||||
." ".$this->card->strAttribut(32,0), true);
|
||||
$this->setTitle($this->card->get_quick_code()." ".strtoupper($this->card->get_attribute(1))
|
||||
." ".$this->card->get_attribute(32,0), true);
|
||||
$this->SetAuthor('NOALYSS');
|
||||
$this->AliasNbPages();
|
||||
$this->AddPage();
|
||||
|
|
@ -63,7 +63,7 @@ class Card_PDF extends \PDF
|
|||
}
|
||||
|
||||
|
||||
$filename=$this->card->strAttribut(1)."-".$this->card->strAttribut(23).".pdf";
|
||||
$filename=$this->card->get_attribute(1)."-".$this->card->get_attribute(23).".pdf";
|
||||
$filename=sanitize_filename($filename);
|
||||
$this->Output($filename,"D");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,84 +196,119 @@ class Card_Property
|
|||
return $result;
|
||||
|
||||
}
|
||||
elseif ($this->ad_id == ATTR_DEF_NUMTVA) {
|
||||
if($this->ad_id == ATTR_DEF_BQ_NO)
|
||||
{
|
||||
$result['input']=new IBan_Number("av_text{$this->ad_id}",$this->av_text);
|
||||
$result['label']=$this->ad_text;
|
||||
return $result;
|
||||
}
|
||||
if ($this->ad_id == ATTR_DEF_NUMTVA) {
|
||||
/// Propose a button to check VAT
|
||||
$result['input']=new IVATNumber( "av_text" . $this->ad_id,$this->av_text);
|
||||
$result['label']=$this->ad_text;
|
||||
return $result;
|
||||
}
|
||||
elseif ($this->ad_id == ATTR_DEF_TVA) {
|
||||
$result['input'] = new ITva_Popup('popup_tva');
|
||||
if ( $this->ad_id == ATTR_DEF_QUANTITY_TYPE){
|
||||
$result['input']=new IText( "av_text" . $this->ad_id,$this->av_text);
|
||||
$array=$this->cn->get_array("select qc_code,format('%s %s',qc_code,qc_label) label from quantity_code_ref order by qc_label",p_mode: PGSQL_NUM);
|
||||
$result['input']->set_datalist($array);
|
||||
$result['label']=$this->ad_text;
|
||||
return $result;
|
||||
}
|
||||
if ( $this->ad_id == ATTR_DEF_PEPPOLID)
|
||||
{
|
||||
/// Propose a button to check VAT
|
||||
$result['input']=new IPEPPOL_ID( "av_text" . $this->ad_id,$this->av_text);
|
||||
$result['label']=$this->ad_text;
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($this->ad_id == ATTR_DEF_TVA) {
|
||||
$result['input'] = new ITva_Popup( "av_text" . $this->ad_id);
|
||||
$result['input']->table = 0;
|
||||
$result['input']->value = $this->av_text;
|
||||
$result['label']=$this->ad_text;
|
||||
} else {
|
||||
switch ($this->ad_type) {
|
||||
case 'text':
|
||||
$result['input'] = new IText();
|
||||
$result['input']->css_size = "100%";
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
case 'numeric':
|
||||
$result['input'] = new INum();
|
||||
$result['input']->prec = ($this->ad_extra == "") ? 2 : $this->ad_extra;
|
||||
$result['input']->size = $this->ad_size;
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
case 'date':
|
||||
$result['input'] = new IDate();
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
case 'zone':
|
||||
$result['input'] = new ITextArea();
|
||||
$result['input']->style = ' class="itextarea" style="margin:0px;width:100%"';
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
case 'poste':
|
||||
$result['input'] = new IPoste("av_text" . $this->ad_id);
|
||||
$result['input']->set_attribute('ipopup', 'ipop_account');
|
||||
$result['input']->set_attribute('account', "av_text" . $this->ad_id);
|
||||
$result['input']->table = 1;
|
||||
$bulle = Icon_Action::infobulle(14);
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
case 'check':
|
||||
$result['input'] = new InputSwitch("av_text" . $this->ad_id);
|
||||
$result['input']->value = (empty($this->av_text) ) ? 0 : 1;
|
||||
break;
|
||||
case 'select':
|
||||
$result['input'] = new ISelect("av_text" . $this->ad_id);
|
||||
$result['input']->value = $this->cn->make_array($this->ad_extra);
|
||||
$result['input']->style = 'style="width:100%"';
|
||||
$result['input']->selected = $this->av_text;
|
||||
break;
|
||||
case 'card':
|
||||
$result['input'] = new ICard("av_text" . $this->ad_id);
|
||||
// filter on frd_id
|
||||
$result['input']->extra = $this->ad_extra;
|
||||
$result['input']->extra2 = 0;
|
||||
$result['input']->id = uniqid();
|
||||
$result['label'] = new ISpan();
|
||||
$filter = $this->ad_extra;
|
||||
$result['input']->width = $this->ad_size;
|
||||
$result['input']->extra = $filter;
|
||||
$result['input']->extra2 = 0;
|
||||
$result['input']->limit = 6;
|
||||
$result['label']->name = "av_text" . $this->ad_id . $result['input']->id . "_label";
|
||||
$result['input']->set_attribute('ipopup', 'ipopcard');
|
||||
$result['input']->set_attribute('typecard', $this->ad_extra);
|
||||
$result['input']->set_attribute('inp', $result['input']->id);
|
||||
$result['input']->set_attribute('label', "av_text" . $this->ad_id . $result['input']->id . "_label");
|
||||
$result['input']->autocomplete = 1;
|
||||
$result['input']->dblclick = "fill_ipopcard(this);";
|
||||
$result['msg'] = $result['input']->search();
|
||||
$result['msg'] .= $result['label']->input();
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
}
|
||||
$result['input']->table = 0;
|
||||
return $result;
|
||||
}
|
||||
// Warning length quickcode
|
||||
if ($this->ad_id == ATTR_DEF_QUICKCODE) {
|
||||
$result['input'] = new IText();
|
||||
$result['input']->css_size = "100%";
|
||||
$result['input']->label = $this->ad_text;
|
||||
$result['input']->name = "av_text" . $this->ad_id;
|
||||
$result['input']->value = $this->av_text;
|
||||
$result['input']->placeholder= "999NOM";
|
||||
$result['bulle'] = Icon_Action::warnbulle(76);
|
||||
$result['label']=$this->ad_text;
|
||||
return $result;
|
||||
}
|
||||
|
||||
switch ($this->ad_type) {
|
||||
case 'text':
|
||||
$result['input'] = new IText();
|
||||
$result['input']->css_size = "100%";
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
case 'numeric':
|
||||
$result['input'] = new INum();
|
||||
$result['input']->prec = ($this->ad_extra == "") ? 2 : $this->ad_extra;
|
||||
$result['input']->size = $this->ad_size;
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
case 'date':
|
||||
$result['input'] = new IDate();
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
case 'zone':
|
||||
$result['input'] = new ITextArea();
|
||||
$result['input']->style = ' class="itextarea" style="margin:0px;width:100%"';
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
case 'poste':
|
||||
$result['input'] = new IPoste("av_text" . $this->ad_id);
|
||||
$result['input']->set_attribute('ipopup', 'ipop_account');
|
||||
$result['input']->set_attribute('account', "av_text" . $this->ad_id);
|
||||
$result['input']->table = 1;
|
||||
$bulle = Icon_Action::infobulle(14);
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
case 'check':
|
||||
$result['input'] = new InputSwitch("av_text" . $this->ad_id);
|
||||
$result['input']->value = (empty($this->av_text) ) ? 0 : 1;
|
||||
break;
|
||||
case 'select':
|
||||
$result['input'] = new ISelect("av_text" . $this->ad_id);
|
||||
$result['input']->value = $this->cn->make_array($this->ad_extra);
|
||||
$result['input']->style = 'style="width:100%"';
|
||||
$result['input']->selected = $this->av_text;
|
||||
break;
|
||||
case 'card':
|
||||
$result['input'] = new ICard("av_text" . $this->ad_id);
|
||||
// filter on frd_id
|
||||
$result['input']->extra = $this->ad_extra;
|
||||
$result['input']->extra2 = 0;
|
||||
$result['input']->id = uniqid();
|
||||
$result['label'] = new ISpan();
|
||||
$filter = $this->ad_extra;
|
||||
$result['input']->width = $this->ad_size;
|
||||
$result['input']->extra = $filter;
|
||||
$result['input']->extra2 = 0;
|
||||
$result['input']->limit = 6;
|
||||
$result['label']->name = "av_text" . $this->ad_id . $result['input']->id . "_label";
|
||||
$result['input']->set_attribute('ipopup', 'ipopcard');
|
||||
$result['input']->set_attribute('typecard', $this->ad_extra);
|
||||
$result['input']->set_attribute('inp', $result['input']->id);
|
||||
$result['input']->set_attribute('label', "av_text" . $this->ad_id . $result['input']->id . "_label");
|
||||
$result['input']->autocomplete = 1;
|
||||
$result['input']->dblclick = "fill_ipopcard(this);";
|
||||
$result['msg'] = $result['input']->search();
|
||||
$result['msg'] .= $result['label']->input();
|
||||
$result['input']->value = $this->av_text;
|
||||
break;
|
||||
}
|
||||
$result['input']->table = 0;
|
||||
$result['label']=$this->ad_text;
|
||||
|
||||
|
||||
$result['input']->label = $this->ad_text;
|
||||
$result['input']->name = "av_text" . $this->ad_id;
|
||||
|
|
@ -281,10 +316,7 @@ class Card_Property
|
|||
$result['bulle'] = Icon_Action::infobulle(21);
|
||||
}
|
||||
|
||||
// Warning length quickcode
|
||||
if ($this->ad_id == ATTR_DEF_QUICKCODE) {
|
||||
$result['bulle'] = Icon_Action::warnbulle(76);
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
@ -304,7 +336,7 @@ class Card_Property
|
|||
if ($fiche->id==0 && $fiche->fiche_def !=0 )
|
||||
{
|
||||
$fiche_def=new Fiche_Def($fiche->cn,$fiche->fiche_def);
|
||||
$aProperty=$fiche_def->getAttribut();
|
||||
$aProperty=$fiche_def->load_attribute();
|
||||
$fiche->attribut=$aProperty;
|
||||
return;
|
||||
} elseif ($fiche->id==0 && $fiche->fiche_def ==0 )
|
||||
|
|
@ -339,7 +371,7 @@ class Card_Property
|
|||
$fiche->attribut[$i]=$t;
|
||||
}
|
||||
$e=new Fiche_Def($fiche->cn, $fiche->fiche_def);
|
||||
$e->GetAttribut();
|
||||
$e->load_attribute();
|
||||
|
||||
if (sizeof($fiche->attribut)!=sizeof($e->attribut))
|
||||
{
|
||||
|
|
@ -475,7 +507,7 @@ class Card_Property
|
|||
$p_fiche->cn->exec_sql("update fiche set f_enable=$1 where f_id=$2",
|
||||
array($p_fiche->get_f_enable(), $p_fiche->id));
|
||||
|
||||
$name = $p_fiche->strAttribut(ATTR_DEF_NAME);
|
||||
$name = $p_fiche->get_attribute(ATTR_DEF_NAME);
|
||||
|
||||
// parse the attribute
|
||||
foreach ($p_fiche->attribut as $value)
|
||||
|
|
@ -693,4 +725,18 @@ class Card_Property
|
|||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @brief returns the property value of a card without creating a card
|
||||
* @param \Database $conx
|
||||
* @param $card_id (int) FICHE.F_ID
|
||||
* @param $property_id (int) ad_value
|
||||
* @return string or false if nothing was found
|
||||
*/
|
||||
static function get_attribute(\Database $conx, $card_id,$property_id)
|
||||
{
|
||||
$r=$conx->get_value("select ad_value from fiche_detail where
|
||||
ad_id = $1 and f_id=$2",[$property_id,$card_id]);
|
||||
if ( $conx->count() == 0) { return false;}
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Customer extends Fiche
|
|||
var $country; /*!< $country Country */
|
||||
var $cp; /*!< $cp Zip code */
|
||||
var $vat_number; /*!< $vat_number vat number */
|
||||
|
||||
use Trait_Card;
|
||||
/*! \brief Constructor
|
||||
* only a db connection is needed
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -69,37 +69,18 @@ class Database extends DatabaseCore
|
|||
$this->exec_sql('set search_path to public,comptaproc,pg_catalog;');
|
||||
}
|
||||
$this->exec_sql('set DateStyle to ISO, MDY;');
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
* \brief Save a "piece justificative" , the name must be pj
|
||||
*
|
||||
* \param $seq jr_grpt_id
|
||||
* \return $oid of the lob file if success
|
||||
* null if a error occurs
|
||||
*
|
||||
*/
|
||||
function save_receipt($seq)
|
||||
{
|
||||
$oid = $this->upload('pj');
|
||||
if ($oid == false) {
|
||||
return false;
|
||||
}
|
||||
// Remove old document
|
||||
$ret = $this->exec_sql("select jr_pj from jrn where jr_grpt_id=$seq");
|
||||
if (pg_num_rows($ret) != 0) {
|
||||
$r = pg_fetch_array($ret, 0);
|
||||
$old_oid = $r['jr_pj'];
|
||||
if (strlen($old_oid??"") != 0)
|
||||
$this->lo_unlink( $old_oid);
|
||||
}
|
||||
// Load new document
|
||||
$this->exec_sql("update jrn set jr_pj=$1 , jr_pj_name=$2,
|
||||
jr_pj_type=$3 where jr_grpt_id=$4",
|
||||
array($oid, $_FILES['pj']['name'], $_FILES['pj']['type'], $seq));
|
||||
return $oid;
|
||||
$this->ret=true;
|
||||
$this->is_open=true;
|
||||
}
|
||||
function __toString(): string {
|
||||
return "DatabaseCore[db=" . var_export($this->db,true)
|
||||
. ", ret=" .var_export( $this->ret,true)
|
||||
. ", is_open=" . $this->is_open
|
||||
. ", sql=" . $this->sql
|
||||
. ", array=" . var_export($this->array,true)
|
||||
. ",dbname = ".$this->get_dbname()
|
||||
. "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get version of a database, the content of the
|
||||
|
|
|
|||
|
|
@ -58,6 +58,24 @@ class Document
|
|||
// counter for MARCH_NEXT
|
||||
$this->counter=0;
|
||||
}
|
||||
|
||||
function __toString(): string
|
||||
{
|
||||
return "Document[db=" . $this->db
|
||||
. ", d_id=" . $this->d_id
|
||||
. ", ag_id=" . $this->ag_id
|
||||
. ", d_mimetype=" . $this->d_mimetype
|
||||
. ", d_filename=" . $this->d_filename
|
||||
. ", d_lob=" . $this->d_lob
|
||||
. ", d_description=" . $this->d_description
|
||||
. ", d_number=" . $this->d_number
|
||||
. ", md_id=" . $this->md_id
|
||||
. ", f_id=" . $this->f_id
|
||||
. ", counter=" . $this->counter
|
||||
. ", d_name=" . $this->d_name
|
||||
. ", md_type=" . $this->md_type
|
||||
. "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert a minimal document and set the d_id
|
||||
|
|
@ -109,16 +127,20 @@ class Document
|
|||
/*!
|
||||
* \brief Generate the document, Call $this-\>replace to replace
|
||||
* tag by value
|
||||
* @param p_array contains the data normally it is the $_POST
|
||||
* @param $p_filename contains the new filename
|
||||
* @param p_array contains the data normally it is the $_POST (see Acc_Ledger_Sale or
|
||||
* Acc_Ledger_Purchase)
|
||||
* @see Acc_Ledger_Sale
|
||||
* @see Acc_Ledger_Purchase
|
||||
* @param $p_filename contains the new filename, if not given the filename will be generated
|
||||
* \return an string : the url where the generated doc can be found, the name
|
||||
* of the file and his mimetype
|
||||
*/
|
||||
|
||||
function generate($p_array, $p_filename="")
|
||||
{
|
||||
|
||||
try {
|
||||
// create a temp directory in /tmp to unpack file and to parse it
|
||||
///@var $dirname (string) temp directory in /tmp to unpack file and to parse it
|
||||
$dirname=tempnam($_ENV['TMP'], 'doc_');
|
||||
if ($dirname == false) {
|
||||
throw new Exception ('DC117 cannot create tmp file',5000);
|
||||
|
|
@ -128,6 +150,31 @@ class Document
|
|||
if ( mkdir($dirname) == false ) {
|
||||
throw new Exception ("DC121 cannot create $dirname directory",5000);
|
||||
}
|
||||
/**
|
||||
* md_id == -2 : INVOICE_STD is the standard PDF invoice, you don't parse or compute
|
||||
* it
|
||||
*/
|
||||
if ( $this->md_id == INVOICE_STD)
|
||||
{
|
||||
$file_to_parse=str_replace(
|
||||
array('/', '*', '<', '>', ';', ',', '\\', '.', ':', '(', ')', ' ', '[', ']')
|
||||
, "-"
|
||||
, "inv-std-".$p_array['e_pj']).".pdf";
|
||||
|
||||
$this->d_number=$this->db->get_next_seq("seq_doc_type_stdinv");
|
||||
$this->d_filename=$file_to_parse;
|
||||
$this->d_mimetype="application/pdf";
|
||||
$this->d_name=$file_to_parse;
|
||||
$standard_invoice=new \Noalyss\Invoice_PDF($this->db,$dirname,$file_to_parse);
|
||||
$standard_invoice->set_data($p_array);
|
||||
$standard_invoice->export();
|
||||
$this->saveGenerated($dirname.DIRECTORY_SEPARATOR.$file_to_parse);
|
||||
// Invoice
|
||||
$href=http_build_query(array('gDossier'=>Dossier::id(), "d_id"=>$this->d_id, 'act'=>'RAW:document'));
|
||||
$ret='<A class="mtitle" HREF="export.php?'.$href.'">'._('Document').'</A>';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// Retrieve the lob and save it into $dirname
|
||||
$this->db->start();
|
||||
$dm_info="select md_name,md_type,md_lob,md_filename,md_mimetype
|
||||
|
|
@ -149,7 +196,8 @@ class Document
|
|||
record_log(sprintf('DOCUMENT.GENERATE.D1 , export failed %s %s',$dirname, $filename));
|
||||
throw new Exception(sprintf(_("Export a échoué pour %s"), $filename));
|
||||
}
|
||||
|
||||
// $type (letter) type of document : OOo for openoffice otherwise n , with OOo the file
|
||||
// is a ZIP XML
|
||||
$type="n";
|
||||
// if the doc is a OOo, we need to unzip it first
|
||||
// and the name of the file to change is always content.xml
|
||||
|
|
@ -214,8 +262,7 @@ class Document
|
|||
|
||||
return $ret;
|
||||
} catch (Exception $e) {
|
||||
record_log($e->getMessage());
|
||||
record_log($e->getTraceAsString());
|
||||
record_log($e);
|
||||
return span(_("Génération du document a échoué"),'class="notice"');
|
||||
}
|
||||
}
|
||||
|
|
@ -252,7 +299,7 @@ class Document
|
|||
{
|
||||
if (mkdir($temp_dir)==false)
|
||||
{
|
||||
$msg=sprintf("D221."._("Ne peut pas créer le répertoire %s", $temp_dir));
|
||||
$msg=sprintf("D221."._("Ne peut pas créer le répertoire %s"), $temp_dir);
|
||||
record_log("D221".$msg);
|
||||
throw new Exception($msg);
|
||||
}
|
||||
|
|
@ -337,14 +384,12 @@ class Document
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Save the generated Document
|
||||
* \brief insert the generated Document into the database, update the $this->d_id
|
||||
* that is the PK of document. and load the PDF into the database.
|
||||
* \param $p_file is the generated file
|
||||
*
|
||||
*
|
||||
* \return 0 if no error otherwise 1
|
||||
*/
|
||||
|
||||
function saveGenerated($p_file)
|
||||
protected function saveGenerated($p_file)
|
||||
{
|
||||
// We save the generated file
|
||||
$doc=new Document($this->db);
|
||||
|
|
@ -676,8 +721,8 @@ class Document
|
|||
* - [DATE_LIMIT_CALC]
|
||||
* - [NUMBER]
|
||||
* - [MY_NAME]
|
||||
* - [MY_CP]
|
||||
* - [MY_COMMUNE]
|
||||
* - [MY_POSTCODE]
|
||||
* - [MY_CITY]
|
||||
* - [MY_TVA]
|
||||
* - [MY_STREET]
|
||||
* - [MY_NUMBER]
|
||||
|
|
@ -721,22 +766,22 @@ class Document
|
|||
$p_tag=noalyss_str_replace('=', '', $p_tag);
|
||||
$r="Tag inconnu";
|
||||
static $aComment=NULL;
|
||||
static $counter_comment=1; /* <! counter for the comment , skip the first one which is the descrition */
|
||||
static $counter_comment=1; /*<! counter for the comment , skip the first one which is the descrition */
|
||||
|
||||
static $aRelatedAction=NULL;
|
||||
static $counter_related_action=0; /* <! counter for the related action */
|
||||
static $counter_related_action=0; /*<! counter for the related action */
|
||||
|
||||
static $aRelatedOperation=NULL;
|
||||
static $counter_related_operation=0; /* <! counter for the related operation */
|
||||
static $counter_related_operation=0; /*<! counter for the related operation */
|
||||
|
||||
static $aFileAttached=NULL;
|
||||
static $counter_file=0; /* <! counter for the file */
|
||||
static $counter_file=0; /*<! counter for the file */
|
||||
|
||||
static $aOtherCard=NULL;
|
||||
static $counter_other_card=0; /* <! counter for the other card */
|
||||
static $counter_other_card=0; /*<! counter for the other card */
|
||||
|
||||
static $aTag=NULL;
|
||||
static $counter_tag=0; /* <! counter for the tags */
|
||||
static $counter_tag=0; /*<! counter for the tags */
|
||||
|
||||
static $aParameterExtra=NULL; // Extra parameter for the company
|
||||
switch ($p_tag)
|
||||
|
|
@ -766,11 +811,13 @@ class Document
|
|||
case 'MY_NAME':
|
||||
$r=$g_parameter->MY_NAME;
|
||||
break;
|
||||
case 'MY_POSTCODE':
|
||||
case 'MY_CP':
|
||||
$r=$g_parameter->MY_CP;
|
||||
$r=$g_parameter->MY_POSTCODE;
|
||||
break;
|
||||
case 'MY_CITY':
|
||||
case 'MY_COMMUNE':
|
||||
$r=$g_parameter->MY_COMMUNE;
|
||||
$r=$g_parameter->MY_CITY;
|
||||
break;
|
||||
case 'MY_TVA':
|
||||
$r=$g_parameter->MY_TVA;
|
||||
|
|
@ -781,14 +828,16 @@ class Document
|
|||
case 'MY_NUMBER':
|
||||
$r=$g_parameter->MY_NUMBER;
|
||||
break;
|
||||
case 'MY_PHONE':
|
||||
case 'MY_TEL':
|
||||
$r=$g_parameter->MY_TEL;
|
||||
$r=$g_parameter->MY_PHONE;
|
||||
break;
|
||||
case 'MY_FAX':
|
||||
$r=$g_parameter->MY_FAX;
|
||||
break;
|
||||
case 'MY_COUNTRY':
|
||||
case 'MY_PAYS':
|
||||
$r=$g_parameter->MY_PAYS;
|
||||
$r=$g_parameter->MY_COUNTRY;
|
||||
break;
|
||||
|
||||
|
||||
|
|
@ -802,7 +851,7 @@ class Document
|
|||
$tiers=new Fiche($this->db);
|
||||
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$p=$tiers->strAttribut(ATTR_DEF_ACCOUNT,0);
|
||||
$p=$tiers->get_attribute(ATTR_DEF_ACCOUNT,0);
|
||||
// if exercice is open with a report, 1 day is 1st exercice's day
|
||||
if ( $g_parameter->MY_REPORT == 'Y') {
|
||||
// var $user_exercice (int) current user exercice (from his preference)
|
||||
|
|
@ -828,13 +877,13 @@ class Document
|
|||
$tiers=new Fiche($this->db);
|
||||
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_NAME,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_NAME,0);
|
||||
break;
|
||||
case 'CUST_ADDR_1':
|
||||
$tiers=new Fiche($this->db);
|
||||
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_ADRESS,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_ADRESS,0);
|
||||
|
||||
break;
|
||||
case 'CUST_CP':
|
||||
|
|
@ -842,7 +891,7 @@ class Document
|
|||
|
||||
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_CP,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_POSTCODE,0);
|
||||
|
||||
break;
|
||||
case 'CUST_CITY':
|
||||
|
|
@ -850,7 +899,7 @@ class Document
|
|||
|
||||
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_CITY,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_CITY,0);
|
||||
|
||||
break;
|
||||
|
||||
|
|
@ -859,7 +908,7 @@ class Document
|
|||
|
||||
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_PAYS,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_COUNTRY,0);
|
||||
|
||||
break;
|
||||
// Marchandise in $p_array['e_march*']
|
||||
|
|
@ -869,25 +918,25 @@ class Document
|
|||
|
||||
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_NUMTVA,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_NUMTVA,0);
|
||||
break;
|
||||
case 'CUST_NUM':
|
||||
$tiers=new Fiche($this->db);
|
||||
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_NUMBER_CUSTOMER,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_NUMBER_CUSTOMER,0);
|
||||
break;
|
||||
case 'CUST_BANQUE_NO':
|
||||
$tiers=new Fiche($this->db);
|
||||
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_BQ_NO,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_BQ_NO,0);
|
||||
break;
|
||||
case 'CUST_BANQUE_NAME':
|
||||
$tiers=new Fiche($this->db);
|
||||
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_BQ_NAME,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_BQ_NAME,0);
|
||||
break;
|
||||
/* -------------------------------------------------------------------------------- */
|
||||
/* BENEFIT (fee notes */
|
||||
|
|
@ -900,7 +949,7 @@ class Document
|
|||
break;
|
||||
}
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_NAME,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_NAME,0);
|
||||
break;
|
||||
case 'BENEF_ADDR_1':
|
||||
$tiers=new Fiche($this->db);
|
||||
|
|
@ -911,7 +960,7 @@ class Document
|
|||
break;
|
||||
}
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_ADRESS,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_ADRESS,0);
|
||||
|
||||
break;
|
||||
case 'BENEF_CP':
|
||||
|
|
@ -924,7 +973,7 @@ class Document
|
|||
break;
|
||||
}
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_CP,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_POSTCODE,0);
|
||||
|
||||
break;
|
||||
case 'BENEF_CITY':
|
||||
|
|
@ -937,7 +986,7 @@ class Document
|
|||
break;
|
||||
}
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_CITY,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_CITY,0);
|
||||
|
||||
break;
|
||||
|
||||
|
|
@ -951,7 +1000,7 @@ class Document
|
|||
break;
|
||||
}
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_PAYS,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_COUNTRY,0);
|
||||
|
||||
break;
|
||||
// Marchandise in $p_array['e_march*']
|
||||
|
|
@ -966,7 +1015,7 @@ class Document
|
|||
break;
|
||||
}
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_NUMTVA,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_NUMTVA,0);
|
||||
break;
|
||||
case 'BENEF_NUM':
|
||||
$tiers=new Fiche($this->db);
|
||||
|
|
@ -977,7 +1026,7 @@ class Document
|
|||
break;
|
||||
}
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_NUMBER_CUSTOMER,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_NUMBER_CUSTOMER,0);
|
||||
break;
|
||||
case 'BENEF_BANQUE_NO':
|
||||
$tiers=new Fiche($this->db);
|
||||
|
|
@ -988,7 +1037,7 @@ class Document
|
|||
break;
|
||||
}
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_BQ_NO,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_BQ_NO,0);
|
||||
break;
|
||||
case 'BENEF_BANQUE_NAME':
|
||||
$tiers=new Fiche($this->db);
|
||||
|
|
@ -999,7 +1048,7 @@ class Document
|
|||
break;
|
||||
}
|
||||
$tiers->get_by_qcode($qcode, false);
|
||||
$r=$tiers->strAttribut(ATTR_DEF_BQ_NAME,0);
|
||||
$r=$tiers->get_attribute(ATTR_DEF_BQ_NAME,0);
|
||||
break;
|
||||
|
||||
// Marchandise in $p_array['e_march*']
|
||||
|
|
@ -1072,7 +1121,7 @@ class Document
|
|||
{
|
||||
$f=new Fiche($this->db);
|
||||
$f->get_by_qcode($p_array["e_march".$this->counter], false);
|
||||
$r=$f->strAttribut(ATTR_DEF_NAME,0);
|
||||
$r=$f->get_attribute(ATTR_DEF_NAME,0);
|
||||
}
|
||||
else
|
||||
$r="";
|
||||
|
|
@ -1094,7 +1143,7 @@ class Document
|
|||
{
|
||||
$f=new Fiche($this->db);
|
||||
$f->get_by_qcode($p_array[$id], false);
|
||||
$r=$f->strAttribut(ATTR_DEF_NAME,0);
|
||||
$r=$f->get_attribute(ATTR_DEF_NAME,0);
|
||||
}
|
||||
else
|
||||
$r="";
|
||||
|
|
@ -1115,7 +1164,7 @@ class Document
|
|||
{
|
||||
$f=new Fiche($this->db);
|
||||
$f->get_by_qcode($p_array[$id], false);
|
||||
$r=$f->strAttribut(ATTR_DEF_STOCK,0);
|
||||
$r=$f->get_attribute(ATTR_DEF_STOCK,0);
|
||||
$r=($r==NOTFOUND)?'':$r;
|
||||
}
|
||||
}
|
||||
|
|
@ -1769,24 +1818,6 @@ class Document
|
|||
$this->db->lo_unlink($d_lob);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Move a document from the table document into the concerned row
|
||||
* the document is not copied : it is only a link
|
||||
*
|
||||
* \param $p_internal internal code
|
||||
*
|
||||
*/
|
||||
|
||||
function moveDocumentPj($p_internal)
|
||||
{
|
||||
$sql="update jrn set jr_pj=$1,jr_pj_name=$2,jr_pj_type=$3 where jr_internal=$4";
|
||||
|
||||
$this->db->exec_sql($sql, array($this->d_lob, $this->d_filename, $this->d_mimetype, $p_internal));
|
||||
// clean the table document
|
||||
$sql='delete from document where d_id='.$this->d_id;
|
||||
$this->db->exec_sql($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief replace a special tag *TAGxxxx with the value from fiche_detail, the xxxx
|
||||
* is the ad_value
|
||||
|
|
@ -1837,7 +1868,7 @@ class Document
|
|||
}
|
||||
|
||||
/**
|
||||
* replace a pattern with a value in the buffer , handle the change for OOo type file and amount
|
||||
* @brief replace a pattern with a value in the buffer , handle the change for OOo type file and amount
|
||||
*
|
||||
* @param string $p_buffer
|
||||
* @param string $_pattern
|
||||
|
|
@ -1891,14 +1922,14 @@ class Document
|
|||
function export_file($p_destination_file)
|
||||
{
|
||||
if ($this->d_id==0) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
$this->db->start();
|
||||
$ret=$this->db->exec_sql(
|
||||
"select d_id,d_lob,d_filename,d_mimetype from document where d_id=$1", [$this->d_id]);
|
||||
if (Database::num_row($ret)==0)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
$row=Database::fetch_array($ret, 0);
|
||||
//the document is saved into file $tmp
|
||||
|
|
@ -1917,15 +1948,14 @@ class Document
|
|||
}
|
||||
/**
|
||||
* @brief transform the current Document to a PDF, returns the full path of the PDF from the TMP folder
|
||||
* if the file IS a pdf , then export it and return the path to the file.
|
||||
*
|
||||
* @todo replace use of unoconv with a PHP lib to convert into PDF
|
||||
* @return string full path to the PDF file
|
||||
*/
|
||||
function transform2pdf()
|
||||
{
|
||||
if (GENERATE_PDF == 'NO' ) {
|
||||
\record_log(__FILE__."D1857 PDF not available");
|
||||
throw new \Exception("Cannot not transform to PDF",5000);
|
||||
}
|
||||
// Extract from public.document
|
||||
// Extract from public.document
|
||||
$dirname=tempnam($_ENV['TMP'],"document");
|
||||
|
||||
if ( $dirname == false ) {
|
||||
|
|
@ -1936,6 +1966,16 @@ class Document
|
|||
if ( mkdir($dirname) == false ) {
|
||||
throw new Exception("D1868.cannot create tmp directory",5000);
|
||||
}
|
||||
if ( $this->d_mimetype == "application/pdf") {
|
||||
$destination_file=$dirname."/".$this->d_filename;
|
||||
$this->export_file($destination_file);
|
||||
return $dirname."/".$destination_file;
|
||||
return;
|
||||
}
|
||||
if (GENERATE_PDF == 'NO' ) {
|
||||
\record_log(__FILE__."D1857 PDF not available");
|
||||
throw new \Exception("Cannot not transform to PDF",5000);
|
||||
}
|
||||
|
||||
$destination_file=$dirname."/".$this->d_filename;
|
||||
$this->export_file($destination_file);
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class Document_Export
|
|||
$zip=new Zip_Extended();
|
||||
$res=$zip->open("{$this->store_pdf}/result.zip",ZipArchive::CREATE);
|
||||
if ($res !== true) {
|
||||
error_log("ERR-DE89 cannot create zip file");
|
||||
record_log("ERR-DE89 cannot create zip file");
|
||||
record_log($this);
|
||||
throw new Exception ("ERR-DE89 cannot recreate zip");
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ class Document_Export
|
|||
// addGmpn
|
||||
$res=$zip->add_file_pattern($this->store_pdf,"/.*pdf/");
|
||||
if ($res == 0) {
|
||||
error_log("ERR-DE96 aucun fichier trouvé");
|
||||
record_log("ERR-DE96 aucun fichier trouvé");
|
||||
record_log($this);
|
||||
throw new Exception ( "ERR-DE96 cannot recreate zip");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,25 +27,24 @@
|
|||
/**
|
||||
* @class Document_Type
|
||||
*@brief class for the table document_type , a document_type is a kind of action in the follow up
|
||||
*
|
||||
* < dt_id pk document_type
|
||||
* < dt_value value
|
||||
*/
|
||||
class Document_Type
|
||||
{
|
||||
var $db; //!< Database conx
|
||||
var $dt_id; //!< $dt_id (int) primary key of DOCUMENT_TYPE
|
||||
var $dt_value; //!< $dt_value (text) description of document type
|
||||
var $dt_prefix; //!< $dt_prefix (text) prefix to use for this
|
||||
/** document_type
|
||||
* \brief constructor
|
||||
* \param $p_cn database connx
|
||||
*/
|
||||
|
||||
function __construct(Database $p_cn, $p_id = -1)
|
||||
var $db; //!< Database Connection
|
||||
var $dt_id; //!< primary key see SQL DOCUMENT_TYPE.DT_ID
|
||||
var $dt_value; //!< description of the document see SQL DOCUMENT_TYPE.DT_VALUE
|
||||
var $dt_prefix; //!< prefix for numbering see SQL DOCUMENT_TYPE.DT_PREFIX
|
||||
|
||||
/**
|
||||
* \brief constructor document_type
|
||||
* \param $p_cn database connx
|
||||
* \param $dt_id primary key see SQL DOCUMENT_TYPE.DT_ID
|
||||
*/
|
||||
function __construct(\Database $p_cn, int $dt_id = -1)
|
||||
{
|
||||
$this->db = $p_cn;
|
||||
$this->dt_id = $p_id;
|
||||
$this->dt_id = $dt_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -55,9 +54,9 @@ class Document_Type
|
|||
function get()
|
||||
{
|
||||
$sql = "select * from document_type where dt_id=$1";
|
||||
$R = $this->db->exec_sql($sql, array($this->dt_id));
|
||||
if ($this->db->count($R) == 0) return 1;
|
||||
$r = Database::fetch_array($R, 0);
|
||||
$r = $this->db->get_row($sql, array($this->dt_id));
|
||||
if ( $r == null ) return 1;
|
||||
|
||||
$this->dt_id = $r['dt_id'];
|
||||
$this->dt_value = $r['dt_value'];
|
||||
$this->dt_prefix = $r['dt_prefix'];
|
||||
|
|
@ -76,6 +75,7 @@ class Document_Type
|
|||
$array = array();
|
||||
for ($i = 0; $i < count($r); $i++)
|
||||
{
|
||||
$tmp=array();
|
||||
$tmp['dt_value'] = $r[$i]['dt_value'];
|
||||
$tmp['dt_prefix'] = $r[$i]['dt_prefix'];
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ class Document_Type
|
|||
* Restart the increment of the document
|
||||
* @param type $p_int
|
||||
*/
|
||||
function set_number($p_int)
|
||||
function set_number(int $p_int)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -111,8 +111,74 @@ class Document_Type
|
|||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
record_log($e);
|
||||
alert("Erreur " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
function __toString(): string
|
||||
{
|
||||
return sprintf("dt_id : [%d] \n dt_value [%s] \n dt_prefix [%s]\n",$this->dt_id,$this->dt_value,$this->dt_prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief unit test for Document_Type
|
||||
* @return void
|
||||
*/
|
||||
static function test_me()
|
||||
{
|
||||
// if (! defined('TEST_UNIT')) return;
|
||||
$cn=Dossier::connect();
|
||||
function prv_echo_error($msg,int $lineno) {
|
||||
print '<p class="p-2 alert-danger">';
|
||||
print "ERROR : $lineno";
|
||||
print $msg;
|
||||
print '</p>';
|
||||
}
|
||||
// prepare test
|
||||
$old_value=[];
|
||||
try {
|
||||
$cn->start();
|
||||
$old_value[0]=$cn->get_row('select * from document_type where dt_id=$1',[8]);
|
||||
$old_value[1]=$cn->get_row('select * from document_type where dt_id=$1',[6]);
|
||||
|
||||
$cn->exec_sql("update document_type set dt_value='Email' where dt_id=$1",[6]);
|
||||
$cn->exec_sql("update document_type set dt_prefix='PML' where dt_id=$1",[8]);
|
||||
$document_type=new Document_Type($cn,8);
|
||||
echo $document_type;
|
||||
|
||||
if ( $document_type->get() == 1 ) {
|
||||
}
|
||||
|
||||
if ( $document_type->dt_prefix!='PML') {
|
||||
prv_echo_error("PREFIX :". $document_type,__LINE__);
|
||||
}
|
||||
|
||||
$document_type->set_number(6);
|
||||
$document_type->get();
|
||||
|
||||
if ( $document_type->dt_value!='Email') {
|
||||
prv_echo_error("VALUE :". $document_type,__LINE__);
|
||||
}
|
||||
$list=Document_Type::get_list($cn);
|
||||
|
||||
// list array > 1 and key =5
|
||||
if (count ($list) == 0) {
|
||||
prv_echo_error("GET_LIST :EMPTY",__LINE__);
|
||||
} else {
|
||||
foreach (['js_mod','dt_id','dt_value','dt_prefix','js_remove'] as $key) {
|
||||
if ( ! isset ($list[0][$key])) {
|
||||
prv_echo_error ('NOT SET '.$key,__LINE__);
|
||||
} else {
|
||||
echo '<pre>';
|
||||
var_dump( $list[0][$key]);
|
||||
echo '</pre>';
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
prv_echo_error("EXCEPTION :". $document_type,__LINE__);
|
||||
print_r($e->getTraceAsString());
|
||||
}
|
||||
$cn->rollback();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class Fiche
|
|||
var $tot_deb;
|
||||
var $ledger_name; ///!< this variable is a mistake, it shouldn't exist, need code rewrite
|
||||
var $ledger_description; ///!< this variable is a mistake, it shouldn't exist, need code rewrite
|
||||
|
||||
|
||||
function __construct($p_cn,$p_id=0)
|
||||
{
|
||||
$this->cn=$p_cn;
|
||||
|
|
@ -136,7 +136,7 @@ class Fiche
|
|||
*/
|
||||
static function cmp_name(Fiche $o1,Fiche $o2)
|
||||
{
|
||||
return strcmp($o1->strAttribut(ATTR_DEF_NAME),$o2->strAttribut(ATTR_DEF_NAME));
|
||||
return strcmp($o1->get_attribute(ATTR_DEF_NAME),$o2->get_attribute(ATTR_DEF_NAME));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -159,7 +159,7 @@ class Fiche
|
|||
$t=new Fiche($this->cn,$avail[$i]['jrn_def_bank']);
|
||||
$t->ledger_name=$avail[$i]['jrn_def_name'];
|
||||
$t->ledger_description=$avail[$i]['jrn_def_description'];
|
||||
$t->getAttribut();
|
||||
$t->load_attribute();
|
||||
$all[$i]=$t;
|
||||
|
||||
}
|
||||
|
|
@ -192,20 +192,27 @@ class Fiche
|
|||
|
||||
|
||||
if ( $p_all )
|
||||
$this->getAttribut();
|
||||
$this->load_attribute();
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* @brief replace by set_attribute
|
||||
* @deprecated since version 9.3.0.12
|
||||
*/
|
||||
function setAttribut($p_ad_id,$p_value) {
|
||||
$this->set_attribute($p_ad_id, $p_value);
|
||||
}
|
||||
/**
|
||||
*@brief set an attribute by a value, if the attribut array is empty
|
||||
* a call to getAttribut is performed
|
||||
* a call to load_attribute is performed
|
||||
*@param int AD_ID attr_def.ad_id
|
||||
*@param int value value of this attribute
|
||||
*@see constant.php table: attr_def
|
||||
*/
|
||||
function setAttribut($p_ad_id,$p_value)
|
||||
function set_attribute($p_ad_id,$p_value)
|
||||
{
|
||||
if ( $this->fiche_def == 0) throw new Exception ("FICHE.179 Invalid category",EXC_INVALID);
|
||||
if ( sizeof($this->attribut)==0 ) $this->getAttribut();
|
||||
if ( sizeof($this->attribut)==0 ) $this->load_attribute();
|
||||
|
||||
for ($e=0;$e <sizeof($this->attribut);$e++)
|
||||
{
|
||||
|
|
@ -216,11 +223,19 @@ class Fiche
|
|||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief replace by load_attribute
|
||||
* @deprecated since version 9.3.0.12
|
||||
* @return type
|
||||
*/
|
||||
function getAttribut() {
|
||||
return Card_Property::load($this);
|
||||
}
|
||||
/**
|
||||
*\brief get all the attribute of a card, add missing ones
|
||||
* and sort the array ($this-\>attribut) by ad_id
|
||||
*/
|
||||
function getAttribut()
|
||||
function load_attribute()
|
||||
{
|
||||
Card_Property::load($this);
|
||||
}
|
||||
|
|
@ -298,22 +313,32 @@ class Fiche
|
|||
"<TR> <TD>".
|
||||
$this->attribut_def."</TD></TR>";
|
||||
}
|
||||
/**
|
||||
* @brief use get_attribute instead
|
||||
* @deprecated since version 9.3.12
|
||||
* @param int $p_ad_id AD_ID from attr_def.ad_id
|
||||
* @param int $p_return 1 return NOTFOUND otherwise an empty string
|
||||
*/
|
||||
function strAttribut($p_ad_id,$p_return=1)
|
||||
{
|
||||
return $this->get_attribute($p_ad_id,$p_return);
|
||||
}
|
||||
/***
|
||||
* @brief return the string of the given attribute
|
||||
* (attr_def.ad_id)
|
||||
* @param int $p_ad_id AD_ID from attr_def.ad_id
|
||||
* @param int $p_return 1 return NOTFOUND otherwise an empty string
|
||||
* @see constant.php
|
||||
* @return string
|
||||
* @return string
|
||||
* @note reread data from database and so it reset previous unsaved change
|
||||
*/
|
||||
function strAttribut($p_ad_id,$p_return=1)
|
||||
function get_attribute($p_ad_id,$p_return=1)
|
||||
{
|
||||
$return=($p_return==1)?NOTFOUND:"";
|
||||
if ( empty ($this->attribut) )
|
||||
{
|
||||
|
||||
$this->getAttribut();
|
||||
$this->load_attribute();
|
||||
}
|
||||
|
||||
foreach ($this->attribut as $e)
|
||||
|
|
@ -332,7 +357,7 @@ class Fiche
|
|||
{
|
||||
$a_return=[];
|
||||
if ( empty ($this->attribut)) {
|
||||
$this->getAttribut();
|
||||
$this->load_attribute();
|
||||
}
|
||||
foreach ($this->attribut as $attr)
|
||||
{
|
||||
|
|
@ -354,7 +379,7 @@ class Fiche
|
|||
// array = array of attribute object sorted on ad_id
|
||||
$fiche_def=new Fiche_Def($this->cn,$p_fiche_def);
|
||||
$fiche_def->get();
|
||||
$array=$fiche_def->getAttribut();
|
||||
$array=$fiche_def->load_attribute();
|
||||
$r="";
|
||||
$r.='<table style="width:98%;margin:1%">';
|
||||
foreach ($array as $attr)
|
||||
|
|
@ -396,7 +421,7 @@ class Fiche
|
|||
*/
|
||||
function Display($p_readonly,$p_in="")
|
||||
{
|
||||
$this->GetAttribut();
|
||||
$this->load_attribute();
|
||||
$attr=$this->attribut;
|
||||
$ret="";
|
||||
$ret.='<span style="margin-right:5px;float:right;font-size:80%">'.
|
||||
|
|
@ -499,13 +524,23 @@ class Fiche
|
|||
{
|
||||
$p_array["av_text".ATTR_DEF_QUICKCODE]="";
|
||||
}
|
||||
// by default the quick_code is the base account of the class + first letters of the name
|
||||
if ( $p_array["av_text".ATTR_DEF_QUICKCODE] =="")
|
||||
{
|
||||
$base_acc=$this->cn->get_value("select fd_class_base from fiche_def where fd_id = $1",
|
||||
[$p_fiche_def]);
|
||||
$p_array["av_text".ATTR_DEF_QUICKCODE]=sprintf("%s%s"
|
||||
, substr($base_acc,0, 3)
|
||||
, substr($p_array["av_text".ATTR_DEF_NAME], 0, 4)
|
||||
);
|
||||
}
|
||||
$sql=sprintf("select insert_quick_code(%d,'%s')", $fiche_id,
|
||||
sql_string($p_array['av_text'.ATTR_DEF_QUICKCODE]));
|
||||
$this->cn->exec_sql($sql);
|
||||
// get the card properties for this card category
|
||||
$fiche_def=new Fiche_Def($this->cn, $p_fiche_def);
|
||||
|
||||
$this->attribut=$fiche_def->getAttribut();
|
||||
$this->attribut=$fiche_def->load_attribute();
|
||||
|
||||
if (empty($this->attribut))
|
||||
{
|
||||
|
|
@ -517,20 +552,20 @@ class Fiche
|
|||
$key='av_text'.$property->ad_id;
|
||||
if (isset($p_array[$key]))
|
||||
{
|
||||
$this->setAttribut($property->ad_id, $p_array[$key]);
|
||||
$this->set_attribute($property->ad_id, $p_array[$key]);
|
||||
}
|
||||
}
|
||||
// For accounting
|
||||
|
||||
Card_Property::update($this);
|
||||
// reread from database
|
||||
$this->getAttribut();
|
||||
$this->load_attribute();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
record_log("FIC603".$e->getMessage()." ".$e->getTraceAsString());
|
||||
record_log($e);
|
||||
$this->cn->rollback();
|
||||
throw ($e);
|
||||
throw (new \Exception ("F561 ". __CLASS__.".".__FUNCTION__,561,$e));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
|
@ -565,7 +600,7 @@ class Fiche
|
|||
|
||||
|
||||
// get the card properties for this card category
|
||||
$this->getAttribut();
|
||||
$this->load_attribute();
|
||||
|
||||
if ( empty ($this->attribut) ) {
|
||||
throw new Exception("FICHE.UPDATE02"._("Aucun attribut ")."($this->fiche_def)",EXC_INVALID);
|
||||
|
|
@ -574,7 +609,7 @@ class Fiche
|
|||
foreach($this->attribut as $property) {
|
||||
$key='av_text'.$property->ad_id;
|
||||
if ( isset($p_array[$key])) {
|
||||
$this->setAttribut($property->ad_id, $p_array[$key]);
|
||||
$this->set_attribute($property->ad_id, $p_array[$key]);
|
||||
}
|
||||
}
|
||||
if ( isset($p_array['f_enable'])) {
|
||||
|
|
@ -584,7 +619,7 @@ class Fiche
|
|||
}
|
||||
// save all
|
||||
Card_Property::update($this);
|
||||
$this->quick_code=$this->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$this->quick_code=$this->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
}
|
||||
|
||||
/*!\brief remove a card, check if not used first, must be synchro with is_used
|
||||
|
|
@ -634,17 +669,17 @@ class Fiche
|
|||
return $r[0]['ad_value'];
|
||||
}
|
||||
|
||||
/*!\brief Synonum of fiche::getAttribut
|
||||
/*!\brief Synonum of fiche::load_attribute
|
||||
*/
|
||||
function Get()
|
||||
{
|
||||
$this->getAttribut();
|
||||
$this->load_attribute();
|
||||
}
|
||||
/*!\brief Synonum of fiche::getAttribut
|
||||
/*!\brief Synonum of fiche::load_attribute
|
||||
*/
|
||||
function load() :void
|
||||
{
|
||||
$this->getAttribut();
|
||||
$this->load_attribute();
|
||||
}
|
||||
/*!
|
||||
* \brief get all the card thanks the fiche_def_ref
|
||||
|
|
@ -692,7 +727,7 @@ class Fiche
|
|||
{
|
||||
$row=Database::fetch_array($Ret,$i);
|
||||
$t=new Fiche($this->cn,$row['f_id']);
|
||||
$t->getAttribut();
|
||||
$t->load_attribute();
|
||||
$all[$i]=clone $t;
|
||||
|
||||
}
|
||||
|
|
@ -772,7 +807,7 @@ class Fiche
|
|||
break;
|
||||
}
|
||||
|
||||
$qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$qcode=$this->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
$this->row=$this->cn->get_array("
|
||||
with sqlletter as
|
||||
(select j_id,jl_id from letter_cred union all select j_id , jl_id from letter_deb )
|
||||
|
|
@ -851,7 +886,7 @@ class Fiche
|
|||
echo_error("class_fiche",__LINE__,"id is 0");
|
||||
return;
|
||||
}
|
||||
$qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$qcode=$this->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
$periode=sql_filter_per($this->cn,$p_from,$p_to,'p_id','jr_tech_per');
|
||||
|
||||
$this->row=$this->cn->get_array("select j_date,
|
||||
|
|
@ -909,7 +944,7 @@ class Fiche
|
|||
|
||||
if ( count($this->row ) == 0 )
|
||||
return;
|
||||
$qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$qcode=$this->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
|
||||
$rep="";
|
||||
$already_seen=array();
|
||||
|
|
@ -998,14 +1033,14 @@ class Fiche
|
|||
"<TH style=\"text-align:left\">"._('Poste')." </TH>".
|
||||
"<TH style=\"text-align:left\">"._('Interne')." </TH>".
|
||||
"<TH style=\"text-align:left\">"._('Tiers')." </TH>".
|
||||
"<TH style=\"text-align:left\">"._('Description')." </TH>".
|
||||
"<TH style=\"text-align:left\">"._('Type')."</TH>".
|
||||
"<TH style=\"text-align:left\">"._('ISO')."</TH>".
|
||||
"<TH style=\"text-align:right\">"._('Dev.')."</TH>".
|
||||
"<TH class=\"visible_gt800\" style=\"text-align:left\">"._('Description')." </TH>".
|
||||
"<TH class=\"visible_gt800\" style=\"text-align:left\">"._('Type')."</TH>".
|
||||
"<TH class=\"visible_gt800\" style=\"text-align:left\">"._('ISO')."</TH>".
|
||||
"<TH class=\"visible_gt800\" style=\"text-align:right\">"._('Dev.')."</TH>".
|
||||
"<TH style=\"text-align:right\">"._('Débit')." </TH>".
|
||||
"<TH style=\"text-align:right\">"._('Crédit')." </TH>".
|
||||
th('Prog.','style="text-align:right"').
|
||||
th('Let.','style="text-align:right"');
|
||||
th('Let.','class="visible_gt800" style="text-align:right"');
|
||||
"</TR>"
|
||||
;
|
||||
$old_exercice="";$sum_deb=0;$sum_cred=0;
|
||||
|
|
@ -1035,19 +1070,20 @@ class Fiche
|
|||
$progress=bcsub($sum_deb,$sum_cred);
|
||||
$side=" ".$this->get_amount_side($progress);
|
||||
echo "<TR class=\"highlight\">".
|
||||
"<TD>$old_exercice</TD>".
|
||||
td('').
|
||||
td('').
|
||||
"<TD></TD>".td().
|
||||
"<TD>Totaux</TD>".
|
||||
td($op['p_exercice']).
|
||||
td("",' class="visible_gt800" ').
|
||||
td("",' class="visible_gt800" ').
|
||||
td("",' class="visible_gt800" ').
|
||||
td().
|
||||
td().
|
||||
td().
|
||||
"<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
|
||||
"<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
|
||||
td(nbm(abs($progress)).$side,'style="text-align:right"').
|
||||
td('').
|
||||
"</TR>";
|
||||
td(_('Totaux')).
|
||||
td("",' class="visible_gt800" ').
|
||||
td("",' class="" ').
|
||||
"<TD></TD>".
|
||||
"<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
|
||||
"<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
|
||||
td(nbm(abs($progress)).$side,'style="text-align:right"').
|
||||
td("",' class="visible_gt800" ').
|
||||
"</TR>";
|
||||
$sum_cred=0;
|
||||
$sum_deb=0;
|
||||
$progress=0;
|
||||
|
|
@ -1067,23 +1103,23 @@ class Fiche
|
|||
td(h($op['jr_pj_number'])).
|
||||
td($op['j_poste']).
|
||||
"<TD>".$vw_operation."</TD>".
|
||||
td($tiers).
|
||||
"<TD>".h($op['description']).$op_analytic."</TD>".
|
||||
td($tiers, ' class="visible_gt800" ').
|
||||
"<TD class=\"visible_gt800\" >".h($op['description']).$op_analytic."</TD>".
|
||||
td($op['jr_optype']);
|
||||
|
||||
/// If the currency is not the default one , then show the amount
|
||||
if ( $op['currency_id'] > 0 && $op['oc_amount'] != 0)
|
||||
{
|
||||
echo td($op['cr_code_iso']).
|
||||
td(nbm($op['oc_amount'],4),'style="text-align:right;padding-left:10px;"');
|
||||
echo td($op['cr_code_iso'], ' class="visible_gt800" ').
|
||||
td(nbm($op['oc_amount'],4),' class="visible_gt800" style="text-align:right;padding-left:10px;"');
|
||||
} else {
|
||||
echo td().td();
|
||||
echo td("",' class="visible_gt800" ').td("",' class="visible_gt800" ');
|
||||
}
|
||||
|
||||
echo "<TD style=\"text-align:right\">".nbm($op['deb_montant'])."</TD>".
|
||||
"<TD style=\"text-align:right\">".nbm($op['cred_montant'])."</TD>".
|
||||
td(nbm(abs($progress)).$side,'style="text-align:right"').
|
||||
td($html_let, ' style="text-align:right"') .
|
||||
td($html_let, ' style="text-align:right" class="visible_gt800" ') .
|
||||
"</TR>";
|
||||
$old_exercice=$op['p_exercice'];
|
||||
|
||||
|
|
@ -1094,18 +1130,18 @@ class Fiche
|
|||
echo '<tfoot>';
|
||||
echo "<TR class=\"highlight\">".
|
||||
td($op['p_exercice']).
|
||||
td().
|
||||
td().
|
||||
td().
|
||||
td("",' class="visible_gt800" ').
|
||||
td("",' class="visible_gt800" ').
|
||||
td("",' class="visible_gt800" ').
|
||||
td().
|
||||
td(_('Totaux')).
|
||||
td().
|
||||
td().
|
||||
td("",' class="visible_gt800" ').
|
||||
td("",' class="" ').
|
||||
"<TD></TD>".
|
||||
"<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
|
||||
"<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
|
||||
"<TD style=\"text-align:right\">".nbm($diff)."</TD>".
|
||||
td($solde_side).
|
||||
"<TD style=\"text-align:right\">".nbm($diff).$solde_side."</TD>".
|
||||
td("",' class="visible_gt800" ').
|
||||
"</TR>";
|
||||
echo "<TR style=\"font-weight:bold\">".
|
||||
"<TD>$solde_type</TD>".
|
||||
|
|
@ -1203,7 +1239,7 @@ class Fiche
|
|||
function get_solde_detail($p_cond="")
|
||||
{
|
||||
if ( $this->id == 0 ) return array('credit'=>0,'debit'=>0,'solde'=>0);
|
||||
$qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$qcode=$this->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
|
||||
if ( $p_cond != "") $p_cond=" and ".$p_cond;
|
||||
$Res=$this->cn->exec_sql("select coalesce(sum(deb),0) as sum_deb,
|
||||
|
|
@ -1255,7 +1291,7 @@ class Fiche
|
|||
function get_bk_balance($p_cond="")
|
||||
{
|
||||
if ( $this->id == 0 ) throw new Exception('fiche->id est nul');
|
||||
$qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$qcode=$this->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
|
||||
if ( $p_cond != "") $p_cond=" and ".$p_cond;
|
||||
$sql="select sum(deb) as sum_deb, sum(cred) as sum_cred from
|
||||
|
|
@ -1319,16 +1355,17 @@ class Fiche
|
|||
bcscale(4);
|
||||
$gDossier=dossier::id();
|
||||
$p_search=sql_string($p_search);
|
||||
$script=$_SERVER['PHP_SELF'];
|
||||
$script=$_SERVER['PHP_SELF']??"";
|
||||
// Creation of the nav bar
|
||||
// Get the max numberRow
|
||||
$filter_amount='';
|
||||
global $g_user;
|
||||
|
||||
$filter_year=" j_tech_per in (select p_id from parm_periode ".
|
||||
"where p_exercice='".$g_user->get_exercice()."')";
|
||||
|
||||
if ( $p_amount) $filter_amount=' and f_id in (select f_id from jrnx where '.$filter_year.')';
|
||||
if ($p_amount) {
|
||||
$filter_amount = ' and f_id in (select f_id from jrnx where ' . $filter_year . ')';
|
||||
}
|
||||
|
||||
$all_tiers=$this->count_by_modele($this->fiche_def_ref,"",$p_sql.$filter_amount);
|
||||
// Get offset and page variable
|
||||
|
|
@ -1357,10 +1394,11 @@ class Fiche
|
|||
<TR >
|
||||
<TH>'._('Quick Code').Icon_Action::infobulle(17).'</TH>'.
|
||||
'<th>'._('Poste comptable').'</th>'.
|
||||
'<th class="sorttable_sorted">'._('Nom').'</span>'.'</th>
|
||||
<th>'._('Adresse').'</th>
|
||||
<th>'._('site web').'</th>
|
||||
<th style="text-align:right">'._('Total débit').'</th>
|
||||
'<th class="sorttable_sorted">'._('Nom').'</span>'.'</th>'.
|
||||
'<th>'._('Compte en banque').'</th>'.
|
||||
'<th>'._('Adresse').'</th>'.
|
||||
'<th>'._('site web').'</th>'.
|
||||
'<th style="text-align:right">'._('Total débit').'</th>
|
||||
<th style="text-align:right">'._('Total crédit').'</th>
|
||||
<th style="text-align:right">'._('Solde').'</th>';
|
||||
$r.='</TR>';
|
||||
|
|
@ -1387,7 +1425,7 @@ class Fiche
|
|||
|
||||
$odd="";
|
||||
$odd = ($i % 2 == 0 ) ? ' odd ': ' even ';
|
||||
$accounting=$tiers->strAttribut(ATTR_DEF_ACCOUNT,0);
|
||||
$accounting=$tiers->get_attribute(ATTR_DEF_ACCOUNT,0);
|
||||
if ( ! empty($accounting) && $p_action == 'bank'
|
||||
&& $amount['debit'] < $amount['credit']
|
||||
&&
|
||||
|
|
@ -1409,14 +1447,15 @@ class Fiche
|
|||
$e=sprintf('<A HREF="%s" title="Détail" class="line"> ',
|
||||
$url_detail);
|
||||
|
||||
$r.="<TD> $e".$tiers->strAttribut(ATTR_DEF_QUICKCODE)."</A></TD>";
|
||||
$r.="<TD> $e".$tiers->get_attribute(ATTR_DEF_QUICKCODE)."</A></TD>";
|
||||
$r.="<TD sorttable_customkey=\"text{$accounting}\"> $e".$accounting."</TD>";
|
||||
$r.="<TD>".h($tiers->strAttribut(ATTR_DEF_NAME))."</TD>";
|
||||
$r.="<TD>".h($tiers->strAttribut(ATTR_DEF_ADRESS,0).
|
||||
" ".$tiers->strAttribut(ATTR_DEF_CP,0).
|
||||
" ".$tiers->strAttribut(ATTR_DEF_PAYS,0)).
|
||||
$r.="<TD>".h($tiers->get_attribute(ATTR_DEF_NAME))."</TD>";
|
||||
$r.=td($tiers->get_attribute(ATTR_DEF_BQ_NO,0));
|
||||
$r.="<TD>".h($tiers->get_attribute(ATTR_DEF_ADRESS,0).
|
||||
" ".$tiers->get_attribute(ATTR_DEF_POSTCODE,0).
|
||||
" ".$tiers->get_attribute(ATTR_DEF_COUNTRY,0)).
|
||||
"</TD>";
|
||||
$r.='<td>'.linkTo($tiers->strAttribut(ATTR_DEF_WEBSITE,0)).'</td>';
|
||||
$r.='<td>'.linkTo($tiers->get_attribute(ATTR_DEF_WEBSITE,0)).'</td>';
|
||||
$str_deb=(($amount['debit']==0)?0:nbm($amount['debit']));
|
||||
$str_cred=(($amount['credit']==0)?0:nbm($amount['credit']));
|
||||
$str_solde=nbm($amount['solde']);
|
||||
|
|
@ -1461,27 +1500,29 @@ class Fiche
|
|||
$sql='select fd_id from fiche where f_id=$1';
|
||||
$R=$this->cn->get_value($sql, array($this->id));
|
||||
if ( $R == "" )
|
||||
$this->fd_id=0;
|
||||
$this->fiche_def=0;
|
||||
else
|
||||
$this->fd_id=$R;
|
||||
return $this->fd_id;
|
||||
$this->fiche_def=$R;
|
||||
return $this->fiche_def;
|
||||
}
|
||||
/*!
|
||||
***************************************************
|
||||
* \brief Check if a fiche is used by a jrn
|
||||
* \brief Check if a card can be used and then belong tp a specific ledger, it the card
|
||||
*
|
||||
* return 1 if the fiche is in the range otherwise 0, the quick_code
|
||||
* or the id must be set
|
||||
*
|
||||
*
|
||||
* \param $p_jrn journal_id
|
||||
* \param $p_type : deb or cred default empty
|
||||
* \param $jrn_def_id journal_id (JRN.JRN_DEF_ID)
|
||||
* \param $side : deb or cred , default empty = both
|
||||
*
|
||||
* \return 1 if the fiche is in the range otherwise < 1
|
||||
* -1 the card doesn't exist
|
||||
* -2 the ledger has no card to check
|
||||
* \return 1 if the card belongs to the ledger,
|
||||
* 0 the card doesn't belong,
|
||||
* -1 the card doesn't exist,
|
||||
* -2 the ledger has no card to check,
|
||||
* -3 there is no category of card for this ledger
|
||||
*
|
||||
*/
|
||||
function belong_ledger($p_jrn,$p_type="")
|
||||
function belong_ledger($jrn_def_id,$side="")
|
||||
{
|
||||
// check if we have a quick_code or a f_id
|
||||
if (($this->quick_code==null || $this->quick_code == "" )
|
||||
|
|
@ -1491,41 +1532,38 @@ class Fiche
|
|||
}
|
||||
|
||||
//retrieve the quick_code
|
||||
if ( $this->quick_code=="")
|
||||
$this->quick_code=$this->get_quick_code();
|
||||
|
||||
|
||||
if ( $this->quick_code==null)
|
||||
return -1;
|
||||
|
||||
if ( $this->id == 0 )
|
||||
if ( $this->get_by_qcode(null,false) == 1)
|
||||
return -1;
|
||||
|
||||
$get="";
|
||||
if ( $p_type == 'deb' )
|
||||
{
|
||||
$get='jrn_def_fiche_deb';
|
||||
}elseif ( $p_type == 'cred' )
|
||||
{
|
||||
$get='jrn_def_fiche_cred';
|
||||
if ($this->quick_code == "") {
|
||||
$this->quick_code = $this->get_quick_code();
|
||||
}
|
||||
if ( $get != "" )
|
||||
|
||||
|
||||
if ($this->quick_code == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($this->id == 0 && $this->get_by_qcode(null, false) == 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( $side == 'deb' )
|
||||
{
|
||||
$Res=$this->cn->exec_sql("select $get as fiche from jrn_def where jrn_def_id=$p_jrn");
|
||||
$Res=$this->cn->exec_sql("select jrn_def_fiche_deb as fiche from jrn_def where jrn_def_id=$1",[$jrn_def_id]);
|
||||
}elseif ( $side == 'cred' )
|
||||
{
|
||||
$Res=$this->cn->exec_sql("select jrn_def_fiche_cred as fiche from jrn_def where jrn_def_id=$1",[$jrn_def_id]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get all the fiche type (deb and cred)
|
||||
$Res=$this->cn->exec_sql(" select jrn_def_fiche_cred as fiche
|
||||
from jrn_def where jrn_def_id=$p_jrn
|
||||
from jrn_def where jrn_def_id=$1
|
||||
union
|
||||
select jrn_def_fiche_deb
|
||||
from jrn_def where jrn_def_id=$p_jrn"
|
||||
from jrn_def where jrn_def_id=$1",
|
||||
[$jrn_def_id]
|
||||
);
|
||||
}
|
||||
$Max=Database::num_row($Res);
|
||||
if ( $Max==0)
|
||||
if ( Database::num_row($Res)==0)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -1554,32 +1592,46 @@ class Fiche
|
|||
fd_id in (".$str_list.") and f_id= ".$this->id;
|
||||
|
||||
$Res=$this->cn->exec_sql($sql);
|
||||
$Max=Database::num_row($Res);
|
||||
if ($Max==0 )
|
||||
if (Database::num_row($Res) == 0) {
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
/*!\brief get all the card from a categorie
|
||||
/*!
|
||||
* \brief get all the card from a categorie
|
||||
*\param $p_cn database connx
|
||||
*\param $pFd_id is the category id
|
||||
*\param $card_category_id is the category id
|
||||
*\param $p_order for the sort, possible values is name_asc,name_desc or nothing
|
||||
* \param $inactive int possible values : 1 = inactive included, 0 = only active ones (default 1)
|
||||
*\return an array of card, but only the fiche->id is set
|
||||
*/
|
||||
static function get_fiche_def($p_cn,$pFd_id,$p_order='')
|
||||
static function get_fiche_def($p_cn,$card_category_id,$p_order='',$inactive=1)
|
||||
{
|
||||
// var $cond_active string SQL cond for filtering active or not
|
||||
$cond_active=($inactive == 1)?"":" and f_enable='1' ";
|
||||
|
||||
switch ($p_order)
|
||||
{
|
||||
case 'name_asc':
|
||||
$sql='select f_id,ad_value from fiche join fiche_detail using (f_id) where ad_id=1 and fd_id=$1 order by 2 asc';
|
||||
$sql="select f_id,ad_value from fiche join fiche_detail using (f_id)
|
||||
where
|
||||
ad_id=1
|
||||
and fd_id=$1
|
||||
$cond_active
|
||||
order by 2 asc";
|
||||
break;
|
||||
case 'name_desc':
|
||||
$sql='select f_id,ad_value from fiche join fiche_detail using (f_id) where ad_id=1 and fd_id=$1 order by 2 desc';
|
||||
$sql="select f_id,ad_value from fiche join fiche_detail using (f_id)
|
||||
where ad_id=1
|
||||
and fd_id=$1
|
||||
$cond_active
|
||||
order by 2 desc";
|
||||
break;
|
||||
default:
|
||||
$sql='select f_id from fiche where fd_id=$1 ';
|
||||
$sql="select f_id from fiche where fd_id=$1 $cond_active ";
|
||||
}
|
||||
$array=$p_cn->get_array($sql,array($pFd_id));
|
||||
$array=$p_cn->get_array($sql,array($card_category_id));
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
|
@ -1589,7 +1641,7 @@ class Fiche
|
|||
function is_used()
|
||||
{
|
||||
/* retrieve first the quickcode */
|
||||
$qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$qcode=$this->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
$sql='select count(*) as c from jrnx where j_qcode=$1';
|
||||
$count=$this->cn->get_value($sql,array($qcode));
|
||||
if ( $count > 0 ) return TRUE;
|
||||
|
|
@ -1789,15 +1841,15 @@ class Fiche
|
|||
|
||||
$fiche->set_fiche_def($fiche_def->id);
|
||||
|
||||
$fiche->setAttribut(ATTR_DEF_NAME,$name);
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT,$fiche_def->class_base.$name);
|
||||
$fiche->set_attribute(ATTR_DEF_NAME,$name);
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT,$fiche_def->class_base.$name);
|
||||
|
||||
echo p(print_r($fiche->to_array(),false));
|
||||
$fiche->insert(1,$fiche->to_array());
|
||||
assert($name == $fiche->strAttribut(ATTR_DEF_NAME));
|
||||
assert($name == $fiche->get_attribute(ATTR_DEF_NAME));
|
||||
|
||||
echo p("fiche ATTR_DEF_ACCOUNT after insert ",$fiche->strAttribut(ATTR_DEF_ACCOUNT));
|
||||
$accounting=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
echo p("fiche ATTR_DEF_ACCOUNT after insert ",$fiche->get_attribute(ATTR_DEF_ACCOUNT));
|
||||
$accounting=$fiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
$acc_accounting=new Acc_Account($cn,$accounting);
|
||||
|
||||
echo p("accounting id",$acc_accounting->get_parameter("id"));
|
||||
|
|
@ -1807,7 +1859,7 @@ class Fiche
|
|||
|
||||
function get_gestion_title()
|
||||
{
|
||||
$r = "<h2 id=\"gestion_title\">" . h($this->getName()) . " " . h($this->strAttribut(ATTR_DEF_FIRST_NAME,0)) . '[' . $this->get_quick_code() . ']</h2>';
|
||||
$r = "<h2 id=\"gestion_title\">" . h($this->getName()) . " " . h($this->get_attribute(ATTR_DEF_FIRST_NAME,0)) . '[' . $this->get_quick_code() . ']</h2>';
|
||||
return $r;
|
||||
}
|
||||
function get_all_account()
|
||||
|
|
@ -1893,7 +1945,7 @@ class Fiche
|
|||
*/
|
||||
function display_row()
|
||||
{
|
||||
$this->getAttribut();
|
||||
$this->load_attribute();
|
||||
foreach($this->attribut as $attr) {
|
||||
$sort="";
|
||||
|
||||
|
|
@ -1926,12 +1978,12 @@ class Fiche
|
|||
}
|
||||
/**
|
||||
* @brief create a card from a qcode and returns a card
|
||||
* @param string $p_qcode qcode of the card
|
||||
* @param $cn Database cnx
|
||||
* @param $p_qcode (string) qcode of the card
|
||||
*/
|
||||
static function from_qcode($p_qcode)
|
||||
static function from_qcode(Database $cn,string $p_qcode)
|
||||
{
|
||||
$cn=Dossier::connect();
|
||||
$card=new Card($cn);
|
||||
$card=new Fiche($cn);
|
||||
$card->get_by_qcode($p_qcode);
|
||||
return $card;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ class Fiche_Def
|
|||
var $attribut; //!< get from attr_xxx tables
|
||||
var $fd_description; //!< Description of the Card Category
|
||||
|
||||
function __construct($p_cn,$p_id = 0)
|
||||
function __construct($cn,$id = 0)
|
||||
{
|
||||
$this->cn=$p_cn;
|
||||
$this->id=$p_id;
|
||||
$this->cn=$cn;
|
||||
$this->id=$id;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -59,13 +59,20 @@ class Fiche_Def
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief replace by load_attribute
|
||||
* @deprecated since version 9.3.12
|
||||
* @return type
|
||||
*/
|
||||
function getAttribut() {
|
||||
return $this->load_attribute();
|
||||
}
|
||||
/*!
|
||||
* \brief Get attribut of a fiche_def
|
||||
* \brief Get attribute of a fiche_def
|
||||
*
|
||||
* \return array of Card_Property
|
||||
*/
|
||||
function getAttribut()
|
||||
function load_attribute()
|
||||
{
|
||||
$sql="select * from jnt_fic_attr ".
|
||||
" natural join attr_def where fd_id= $1".
|
||||
|
|
@ -337,16 +344,18 @@ $order
|
|||
* \brief Get all the card where the fiche_def.fd_id is given in parameter
|
||||
* \param $step = 0 we don't use the offset, page_size,...
|
||||
* $step = 1 we use the jnr_bar_nav
|
||||
*
|
||||
* \param $inactive int possible values : 1 = inactive included, 0 = only active ones (default 1)
|
||||
* \return array ('f_id'=>..,'ad_value'=>..)
|
||||
*\see fiche
|
||||
*/
|
||||
function get_by_type($step=0)
|
||||
function get_by_type($step=0,$inactive=1)
|
||||
{
|
||||
// var $cond_active string SQL cond for filtering active or not
|
||||
$cond_active=($inactive == 1)?"":" and f_enable='1' ";
|
||||
$sql="select f_id,ad_value
|
||||
from
|
||||
fiche join fiche_detail using(f_id)
|
||||
where ad_id=1 and fd_id=$1 order by 2";
|
||||
where ad_id=1 and fd_id=$1 $cond_active order by 2";
|
||||
|
||||
// we use navigation_bar
|
||||
if ($step == 1 && $_SESSION[SESSION_KEY.'g_pagesize'] != -1 )
|
||||
|
|
@ -361,18 +370,24 @@ $order
|
|||
return $Ret;
|
||||
}
|
||||
/*!
|
||||
* \brief Get all the card where the fiche_def.frd_id is given in parameter
|
||||
* \return array of fiche or null is nothing is found
|
||||
* \brief Get all the card where the fiche_def.frd_id is given in parameter, it is the template for category
|
||||
*\param $inactive int possible values : 1 = inactive included, 0 = only active ones (default 1)
|
||||
* \param $template_category int FICHE_DEF_REF.FRD_ID
|
||||
* \return array of Fiche or null is nothing is found
|
||||
*
|
||||
*/
|
||||
function get_by_category($p_cat)
|
||||
function get_by_category($template_category,$inactive=1)
|
||||
{
|
||||
// var $cond_active string SQL cond for filtering active or not
|
||||
$cond_active=($inactive == 1)?"":" and f_enable='1' ";
|
||||
$sql="select f_id,ad_value
|
||||
from
|
||||
fiche join fiche_def using(fd_id)
|
||||
join fiche_detail using(f_id)
|
||||
where ad_id=1 and frd_id=$1 order by 2 ";
|
||||
where ad_id=1 and frd_id=$1 $cond_active
|
||||
order by 2 ";
|
||||
|
||||
$Ret=$this->cn->exec_sql($sql,array($p_cat));
|
||||
$Ret=$this->cn->exec_sql($sql,array($template_category));
|
||||
if ( ($Max=Database::num_row($Ret)) == 0 )
|
||||
return null;
|
||||
$all[0]=new Fiche($this->cn);
|
||||
|
|
@ -381,7 +396,7 @@ $order
|
|||
{
|
||||
$row=Database::fetch_array($Ret,$i);
|
||||
$t=new Fiche($this->cn,$row['f_id']);
|
||||
$t->getAttribut();
|
||||
$t->load_attribute();
|
||||
$all[$i]=$t;
|
||||
|
||||
}
|
||||
|
|
@ -613,7 +628,7 @@ $order
|
|||
{
|
||||
if ( $this->id == 0 ) return;
|
||||
/* ORDER */
|
||||
$this->GetAttribut();
|
||||
$this->load_attribute();
|
||||
$order=$p_order;
|
||||
if ( $p_order == -1 ) {
|
||||
$order = $this->cn->get_value("select ad_default_order from attr_def where ad_id=$1",[$p_ad_id]);
|
||||
|
|
@ -659,7 +674,7 @@ $order
|
|||
function save_order($p_array)
|
||||
{
|
||||
extract($p_array, EXTR_SKIP);
|
||||
$this->GetAttribut();
|
||||
$this->load_attribute();
|
||||
foreach ($this->attribut as $row)
|
||||
{
|
||||
if ( $row->ad_id == 1 ) continue;
|
||||
|
|
@ -770,7 +785,7 @@ $order
|
|||
// Save the label
|
||||
|
||||
$this->get();
|
||||
$this->GetAttribut();
|
||||
$this->load_attribute();
|
||||
$r.= '<H2 class="info">' . $this->id . " " . h($this->label) . '</H2>';
|
||||
$r.='<fieldset><legend>'._('Données générales').'</legend>';
|
||||
|
||||
|
|
@ -801,7 +816,7 @@ $order
|
|||
$r.=HtmlInput::submit('remove_cat', _('Effacer'));
|
||||
$r.='</form>';
|
||||
|
||||
require NOALYSS_TEMPLATE.'/fiche_def-input_detail.php';
|
||||
|
||||
|
||||
$r.='</fieldset>';
|
||||
$r.='<hr>';
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ class Follow_Up
|
|||
|
||||
// Description
|
||||
$desc=new ITextArea();
|
||||
$desc->set_enrichText("enrich");
|
||||
$desc->set_enrichText("full");
|
||||
$desc->style=' class="itextarea" style="width:80%;margin-left:5%;"';
|
||||
$desc->name="ag_comment";
|
||||
$desc->readOnly=$readonly;
|
||||
|
|
@ -339,8 +339,8 @@ class Follow_Up
|
|||
{
|
||||
$tiers=new Fiche($this->db);
|
||||
$tiers->get_by_qcode($this->qcode_dest);
|
||||
$qcode_dest_label=strtoupper($tiers->strAttribut(1));
|
||||
$qcode_dest_label.=" ".$tiers->strAttribut(ATTR_DEF_FIRST_NAME,0);
|
||||
$qcode_dest_label=strtoupper($tiers->get_attribute(1));
|
||||
$qcode_dest_label.=" ".$tiers->get_attribute(ATTR_DEF_FIRST_NAME,0);
|
||||
$this->f_id_dest=$tiers->id;
|
||||
}
|
||||
else
|
||||
|
|
@ -411,8 +411,8 @@ class Follow_Up
|
|||
|
||||
if ($fiche_contact->id!=0)
|
||||
{
|
||||
$spcontact->value=strtoupper($fiche_contact->strAttribut(ATTR_DEF_NAME)??"");
|
||||
$spcontact->value.=" ".$fiche_contact->strAttribut(ATTR_DEF_FIRST_NAME,0);
|
||||
$spcontact->value=strtoupper($fiche_contact->get_attribute(ATTR_DEF_NAME)??"");
|
||||
$spcontact->value.=" ".$fiche_contact->get_attribute(ATTR_DEF_FIRST_NAME,0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -535,7 +535,7 @@ class Follow_Up
|
|||
}
|
||||
$this->dt_id=$this->ag_type;
|
||||
$aexp=new Fiche($this->db, $this->f_id_dest);
|
||||
$this->qcode_dest=$aexp->strAttribut(ATTR_DEF_QUICKCODE);
|
||||
$this->qcode_dest=$aexp->get_attribute(ATTR_DEF_QUICKCODE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,171 +0,0 @@
|
|||
<?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 manage the table forecast
|
||||
*/
|
||||
/*!
|
||||
* \brief manage the table forecast
|
||||
*/
|
||||
class Forecast
|
||||
{
|
||||
private static $variable=array ("id"=>"f_id",
|
||||
"name"=>"f_name","start_date"=>"f_start_date","end_date"=>"f_end_date"
|
||||
);
|
||||
private $cn;
|
||||
/**
|
||||
* @brief constructor
|
||||
* @param $p_init Database object
|
||||
*/
|
||||
function __construct ($p_init,$p_id=0)
|
||||
{
|
||||
$this->cn=$p_init;
|
||||
$this->f_id=$p_id;
|
||||
}
|
||||
public function get_parameter($p_string)
|
||||
{
|
||||
if ( array_key_exists($p_string,self::$variable) )
|
||||
{
|
||||
$idx=self::$variable[$p_string];
|
||||
return $this->$idx;
|
||||
}
|
||||
else
|
||||
throw new Exception("Attribut inexistant $p_string");
|
||||
}
|
||||
public function set_parameter($p_string,$p_value)
|
||||
{
|
||||
if ( array_key_exists($p_string,self::$variable) )
|
||||
{
|
||||
$idx=self::$variable[$p_string];
|
||||
$this->$idx=$p_value;
|
||||
}
|
||||
else
|
||||
throw new Exception("Attribut inexistant $p_string");
|
||||
}
|
||||
public function get_info()
|
||||
{
|
||||
return var_export(self::$variable,true);
|
||||
}
|
||||
|
||||
public function verify()
|
||||
{
|
||||
// Verify that the elt we want to add is correct
|
||||
// the f_name must be unique (case insensitive)
|
||||
if ( noalyss_strlentrim($this->f_name)==0) throw new Exception(_('Le nom ne peut pas être vide'));
|
||||
|
||||
return 0;
|
||||
}
|
||||
public function save()
|
||||
{
|
||||
/* please adapt */
|
||||
if ( $this->get_parameter("id") == 0 )
|
||||
$this->insert();
|
||||
else
|
||||
$this->update();
|
||||
}
|
||||
|
||||
public function insert()
|
||||
{
|
||||
if ( $this->verify() != 0 ) return;
|
||||
$sql="insert into forecast (f_name,f_start_date,f_end_date) ".
|
||||
" values ($1,$2,$3) returning f_id";
|
||||
$res=$this->cn->exec_sql(
|
||||
$sql,
|
||||
array($this->f_name,$this->f_start_date,$this->f_end_date)
|
||||
);
|
||||
$this->f_id=Database::fetch_result($res,0,0);
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief update the forecast table
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
if ( $this->verify() != 0 ) return;
|
||||
|
||||
$sql="update forecast set f_name=$1,f_start_date=$2,f_end_date=$3 ".
|
||||
" where f_id = $4";
|
||||
$res=$this->cn->exec_sql(
|
||||
$sql,
|
||||
array($this->f_name,$this->f_start_date,$this->f_end_date, $this->f_id)
|
||||
);
|
||||
|
||||
}
|
||||
/**
|
||||
*@brief load all the existing forecast
|
||||
*@param $p_cn is an Database object
|
||||
*@return array of f_id and f_name
|
||||
*/
|
||||
public static function load_all($p_cn)
|
||||
{
|
||||
$sql="select f_id, f_name,f_start_date,f_end_date from forecast order by 2 desc";
|
||||
$ret=$p_cn->get_array($sql);
|
||||
return $ret;
|
||||
}
|
||||
/**
|
||||
* @brief load from db
|
||||
* @return boolean true if found else false
|
||||
*/
|
||||
public function load():bool
|
||||
{
|
||||
$sql="select f_id, f_name,f_start_date ,f_end_date from forecast where f_id=$1";
|
||||
$res=$this->cn->exec_sql(
|
||||
$sql,
|
||||
array($this->f_id)
|
||||
);
|
||||
if ( Database::num_row($res) == 0 ) return false;
|
||||
$row=Database::fetch_array($res,0);
|
||||
$a_index=array_values(self::$variable);
|
||||
foreach ( $a_index as $idx)
|
||||
{
|
||||
$this->$idx=$row[$idx];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function delete()
|
||||
{
|
||||
$sql="delete from forecast where f_id=$1";
|
||||
$res=$this->cn->exec_sql($sql,array($this->f_id));
|
||||
}
|
||||
public function object_clone()
|
||||
{
|
||||
$this->load();
|
||||
/* save into the table forecast */
|
||||
$sql="insert into forecast(f_name,f_start_date,f_end_date) select 'clone '||f_name,f_start_date,f_end_date from forecast where f_id=$1 returning f_id";
|
||||
$new=$this->cn->get_value($sql,array($this->f_id));
|
||||
|
||||
/* save into forecast_cat */
|
||||
$sql="insert into forecast_cat(fc_desc,f_id,fc_order) select fc_desc,$1,fc_order from forecast_cat where f_id=$2 returning fc_id" ;
|
||||
$array=$this->cn->get_array($sql,array($new,$this->f_id));
|
||||
|
||||
$old=$this->cn->get_array("select fc_id from forecast_cat where f_id=$1",array($this->f_id));
|
||||
/* save into forecast_item */
|
||||
for ($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$this->cn->exec_sql("insert into forecast_item (fi_text,fi_account,fi_order,fc_id,fi_amount,fi_pid) ".
|
||||
" select fi_text,fi_account,fi_order,$1,fi_amount,fi_pid ".
|
||||
" from forecast_item where fc_id=$2",array($array[$i]['fc_id'],$old[$i]['fc_id']));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
333
include/class/invoice_pdf.class.php
Normal file
333
include/class/invoice_pdf.class.php
Normal file
|
|
@ -0,0 +1,333 @@
|
|||
<?php
|
||||
|
||||
namespace Noalyss;
|
||||
|
||||
/*
|
||||
* 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 22/10/23
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief create a standard invoice
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Invoice PDF
|
||||
* @brief create a standard invoice
|
||||
*/
|
||||
class Invoice_PDF extends \PDF
|
||||
{
|
||||
|
||||
private $data; //!< $data (array) see Acc_Ledger_Purchases
|
||||
|
||||
function __construct(
|
||||
\Database $cn
|
||||
, private $dirname //!< folder where to save file
|
||||
, private $filename //!< filename to use
|
||||
)
|
||||
{
|
||||
parent::__construct($cn);
|
||||
}
|
||||
|
||||
public function get_dirname()
|
||||
{
|
||||
return $this->dirname;
|
||||
}
|
||||
|
||||
public function get_filename()
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
public function set_dirname($dirname)
|
||||
{
|
||||
$this->dirname = $dirname;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_filename($filename)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function set_data($array)
|
||||
{
|
||||
$this->data = $array;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function get_data()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
function footer()
|
||||
{
|
||||
//Position at 1 cm from bottom
|
||||
$this->SetY(-10);
|
||||
//Arial italic 8
|
||||
$this->SetFont('Arial', '', 8);
|
||||
//Page number
|
||||
parent::Cell(0, 8, " Page " . $this->PageNo() . '/{nb}', 0, 0, 'C');
|
||||
parent::Ln(3);
|
||||
}
|
||||
|
||||
function header()
|
||||
{
|
||||
global $g_parameter;
|
||||
$this->setY(15);
|
||||
$this->SetFont('DejaVu', '', 6);
|
||||
$colsize = 90;
|
||||
$this->write_multi($colsize, 3, $g_parameter->MY_NAME);
|
||||
$this->write_multi($colsize, 3, $this->data['e_date'], border: '', align: 'R');
|
||||
$this->line_new();
|
||||
$this->write_multi($colsize, 3,
|
||||
sprintf("%s %s "
|
||||
, $g_parameter->MY_STREET
|
||||
, $g_parameter->MY_NUMBER));
|
||||
$this->line_new();
|
||||
$this->write_multi($colsize, 3, $g_parameter->MY_POSTCODE
|
||||
. " " . $g_parameter->MY_CITY
|
||||
. " " . $g_parameter->MY_COUNTRY
|
||||
);
|
||||
$this->line_new();
|
||||
$this->write_multi($colsize, 3, $g_parameter->MY_TVA);
|
||||
$this->line_new();
|
||||
|
||||
$email_company = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
|
||||
['INVOICE_EMAIL_COMPANY']);
|
||||
$site = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
|
||||
['WEB_COMPANY']);
|
||||
// for FRANCE , the SIREN and SIRET must be given
|
||||
$siren = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
|
||||
['SIREN']);
|
||||
$siret = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
|
||||
['SIRET']);
|
||||
$iban = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
|
||||
['COMPANY_BANK_IBAN']);
|
||||
$bic = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
|
||||
['COMPANY_BANK_BIC']);
|
||||
|
||||
if ($siret != "")
|
||||
{
|
||||
$this->write_multi($colsize, 3, "SIRET $siret");
|
||||
$this->line_new();
|
||||
}
|
||||
if ($siren != "")
|
||||
{
|
||||
$this->write_multi($colsize, 3, "SIREN $siren");
|
||||
$this->line_new();
|
||||
}
|
||||
if ($iban != "")
|
||||
{
|
||||
$this->write_multi($colsize, 3, "IBAN $iban BIC $bic");
|
||||
$this->line_new();
|
||||
}
|
||||
if ($g_parameter->MY_PHONE != "")
|
||||
{
|
||||
$this->write_multi($colsize, 3, sprintf(_("Tel %s "),
|
||||
$g_parameter->MY_PHONE
|
||||
));
|
||||
$this->line_new();
|
||||
}
|
||||
if ($email_company != "")
|
||||
{
|
||||
$this->write_multi($colsize, 3, sprintf(_("email %s "),
|
||||
$email_company));
|
||||
$this->line_new();
|
||||
}
|
||||
if ($site != "")
|
||||
{
|
||||
$this->write_multi($colsize, 3, sprintf(_("site %s"),
|
||||
$site
|
||||
));
|
||||
$this->line_new();
|
||||
}
|
||||
$this->setFont("DejaVu", 'B', 14);
|
||||
$this->write_multi(40, 10, "");
|
||||
$this->write_multi(100, 10, _("Facture") . " " . $this->data['e_pj'], border: 1, align: 'C');
|
||||
$this->write_multi(40, 10, "");
|
||||
$this->line_new(10);
|
||||
$this->ln(5);
|
||||
}
|
||||
|
||||
//!
|
||||
//@brief make the invoice
|
||||
function export()
|
||||
{
|
||||
$this->SetAuthor('NOALYSS');
|
||||
$this->AliasNbPages();
|
||||
$this->AddPage();
|
||||
$this->SetAutoPageBreak(true, $this->bMargin*1);
|
||||
$this->setTitle($this->filename, true);
|
||||
// $customer (Fiche) retrieve card of the customer
|
||||
$customer = new \Fiche($this->cn);
|
||||
$customer->get_by_qcode(trim($this->data['e_client']));
|
||||
|
||||
$this->setFont("DejaVu", '', 7);
|
||||
$this->write_cell(50, 4, "");
|
||||
$this->write_cell(60, 4, sprintf(_("Echéance %s"), $this->data['e_ech']));
|
||||
$this->line_new();
|
||||
$this->write_cell(50, 4, "");
|
||||
$this->write_cell(100, 4, _("Client"), 'B', 'R');
|
||||
$this->line_new();
|
||||
$this->write_cell(50, 4, "");
|
||||
$this->write_cell(110, 4, $customer->get_attribute(ATTR_DEF_NAME)
|
||||
. " " . $customer->get_attribute(ATTR_DEF_FIRST_NAME, 0));
|
||||
$this->line_new();
|
||||
$this->write_cell(50, 4, "");
|
||||
$this->write_cell(110, 4, $customer->get_attribute(ATTR_DEF_ADRESS, 0));
|
||||
$this->line_new();
|
||||
$this->write_cell(50, 4, "");
|
||||
$this->write_cell(110, 4, $customer->get_attribute(ATTR_DEF_POSTCODE, 0)
|
||||
. " " . $customer->get_attribute(ATTR_DEF_CITY, 0)
|
||||
);
|
||||
$this->line_new();
|
||||
$this->write_cell(50, 4, "");
|
||||
$this->write_cell(110, 4, $customer->get_attribute(ATTR_DEF_COUNTRY, 0));
|
||||
$this->line_new();
|
||||
$this->write_cell(50, 4, "");
|
||||
$this->write_cell(110, 4, $customer->get_attribute(ATTR_DEF_NUMTVA, 0));
|
||||
$this->line_new();
|
||||
$a_tva_amount = [];
|
||||
$a_tva_code = [];
|
||||
$col = array(
|
||||
"quick_code" => 30,
|
||||
"label" => 80,
|
||||
"quantity" => 25,
|
||||
"price" => 25,
|
||||
"vat_code" => 20
|
||||
);
|
||||
$this->SetFont("DejaVu", "B", 12);
|
||||
$this->write_multi(50, 20, "");
|
||||
$this->write_multi(50, 20, _("Détails"));
|
||||
$this->line_new();
|
||||
$this->SetFont("DejaVu", "B", 7);
|
||||
$currency = new \Acc_Currency($this->cn, $this->data['p_currency_code']);
|
||||
$this->write_multi(100, 4, sprintf(_("Les montants sont en %s taux %s")
|
||||
, $currency->get_code()
|
||||
, $this->data['p_currency_rate']));
|
||||
$this->line_new(4);
|
||||
$this->SetFont("DejaVuCond", "", 7);
|
||||
if ($this->data["bon_comm"] != "")
|
||||
{
|
||||
$this->write_multi(120, 4, sprintf(_("Bon de commande / référence %s")
|
||||
, $this->data["bon_comm"]));
|
||||
$this->line_new(4);
|
||||
}
|
||||
$this->line_new(4);
|
||||
$this->SetFont("DejaVu", "", 7);
|
||||
$this->write_multi($col['quick_code'], 4, _("Article"), 1);
|
||||
$this->write_multi($col['label'], 4, _("Description"), 1);
|
||||
$this->write_multi($col['quantity'], 4, _("Quantité"), 1, align: 'C');
|
||||
$this->write_multi($col['price'], 4, _("Prix"), 1, align: 'C');
|
||||
$this->write_multi($col['vat_code'], 4, _("TVA"), 1, align: 'C');
|
||||
$this->line_new();
|
||||
///@var $tot_amount (float) total amount without VAT
|
||||
///@var $tot_vat (float) total VAT
|
||||
///@var $line (int) line printed
|
||||
$tot_amount = $tot_vat = $line =0;
|
||||
for ($i = 0; $i < $this->data['nb_item']; $i++)
|
||||
{
|
||||
$item = new \Fiche($this->cn);
|
||||
if (!isset($this->data['e_march' . $i]) || $this->data['e_march' . $i] == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$line++;
|
||||
$item->get_by_qcode(trim($this->data['e_march' . $i]));
|
||||
$fill = $this->is_fill($line);
|
||||
$this->write_multi($col['quick_code'], 4, $item->get_attribute(ATTR_DEF_QUICKCODE),'','',$fill);
|
||||
$this->write_multi($col['label'], 4, $this->data['e_march' . $i . '_label'],fill:$fill);
|
||||
$this->write_multi($col['quantity'], 4, nbm($this->data['e_quant' . $i]), '', 'R',fill:$fill);
|
||||
$this->write_multi($col['price'], 4, nbm($this->data['e_march' . $i . '_price']), '', 'R',fill:$fill);
|
||||
$this->write_multi($col['vat_code'], 4, $this->data['e_march' . $i . '_tva_id'], '', 'C',fill:$fill);
|
||||
$x = $this->data['e_march' . $i . '_tva_id'];
|
||||
if (!isset($a_tva_amount[$x]))
|
||||
{
|
||||
$a_tva_amount[$x] = 0;
|
||||
}
|
||||
$a_tva_amount[$x] = bcadd($a_tva_amount[$x], $this->data["e_march" . $i . "_tva_amount"], 2);
|
||||
$tot_amount = bcadd($tot_amount
|
||||
, bcmul($this->data['e_march' . $i . '_price']
|
||||
, $this->data['e_quant' . $i]
|
||||
, 2
|
||||
)
|
||||
, 2);
|
||||
$tot_vat = bcadd($tot_vat
|
||||
, $this->data['e_march' . $i . '_tva_amount']
|
||||
, 2);
|
||||
$this->line_new(4);
|
||||
if ($this->GetY()>250) {
|
||||
$this->AddPage();
|
||||
}
|
||||
}
|
||||
$this->line_new(10);
|
||||
$this->SetFont("DejaVu", "B", 9);
|
||||
$this->write_multi(30, 4, _("TVA"));
|
||||
$this->line_new(5);
|
||||
$this->SetFont("DejaVu", "", 7);
|
||||
foreach ($a_tva_amount as $tva_id => $tva_amount)
|
||||
{
|
||||
$tva = \Acc_Tva::build($this->cn, $tva_id);
|
||||
$this->write_multi(20, 4, "");
|
||||
$this->write_multi(80, 4, $tva->tva_id
|
||||
. " / " . $tva->tva_code
|
||||
. " / " . $tva->tva_label
|
||||
. " / " . $tva->tva_rate * 100
|
||||
);
|
||||
|
||||
$this->write_multi(50, 4, $tva_amount,align:'R');
|
||||
$this->line_new();
|
||||
}
|
||||
$this->ln(20);
|
||||
$this->SetFont("DejaVu", "B", 9);
|
||||
$this->write_multi(30, 4, _("TOTAUX"));
|
||||
$this->line_new();
|
||||
$this->SetFont("DejaVu", "", 7);
|
||||
$this->write_multi(60, 4, _("Total Hors TVA "));
|
||||
$this->write_multi(60, 4, nbm($tot_amount), '', 'R');
|
||||
$this->line_new();
|
||||
$this->write_multi(60, 4, _("Total TVA "));
|
||||
$this->write_multi(60, 4, nbm($tot_vat), '', 'R');
|
||||
$this->line_new();
|
||||
$this->write_multi(60, 4, _("Total "));
|
||||
$this->write_multi(60, 4, nbm(bcadd($tot_amount, $tot_vat, 2),2), '', 'R');
|
||||
$this->line_new();
|
||||
$iban = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
|
||||
['COMPANY_BANK_IBAN']);
|
||||
if ($this->data['e_ech'] != "" && $iban != "")
|
||||
{
|
||||
$info = ($this->data["other_info"] == "") ? $this->data["e_pj"] : $this->data["other_info"];
|
||||
$bic = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
|
||||
['COMPANY_BANK_IBAN']);
|
||||
$this->write_multi(150, 4,
|
||||
sprintf(_("Paiement avant le %s sur le compte %s (BIC %s) avec comme message %s"),
|
||||
$this->data['e_ech']
|
||||
, $iban
|
||||
, $bic
|
||||
, $this->data["other_info"]
|
||||
)
|
||||
);
|
||||
$this->line_new();
|
||||
}
|
||||
$this->Output($this->dirname . DIRECTORY_SEPARATOR . $this->filename, "F");
|
||||
}
|
||||
}
|
||||
|
|
@ -20,11 +20,13 @@
|
|||
|
||||
// Copyright Author Dany De Bontridder danydb@aevalys.eu
|
||||
|
||||
/* !\file
|
||||
/*!
|
||||
*\file
|
||||
* \brief letter the accounting entry (row level)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @brief mother class for the lettering by account and by card
|
||||
* use the tables jnt_letter, letter_deb and letter_cred
|
||||
* - "account"=>"account", => the accounting of the j_id (use by Lettering_Account)
|
||||
|
|
@ -32,11 +34,18 @@
|
|||
* - "start"=>"start", => date of the first day
|
||||
* - "end"=>"end", => date of the last day
|
||||
* - "sql_ledger"=>"sql_ledger" => the sql clause to filter on the available ledgers
|
||||
*
|
||||
* @see unit-test/include/class/acc_letterTest.php
|
||||
* @see test scenario scenario/XML/ajax_display_letter.php
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class Lettering
|
||||
{
|
||||
///@todo Lettering must be rewritten and use __set and __get
|
||||
/// instead of an array + data_member
|
||||
///@todo Lettering must be rewritten and use __set and __get
|
||||
/// instead of an array + data_member
|
||||
protected $variable=array("account"=>"account", /* the accounting of the j_id (use by Lettering_Account) */
|
||||
"quick_code"=>"quick_code", /* the quick_code of the j_id (used by Lettering_Card) */
|
||||
"start"=>"start", /* date of the first day */
|
||||
|
|
@ -54,7 +63,7 @@ class Lettering
|
|||
var $fil_amount_min;
|
||||
var $fil_deb;
|
||||
var $linked;
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param $p_init resource to database
|
||||
|
|
@ -299,7 +308,7 @@ class Lettering
|
|||
catch (Exception $exc)
|
||||
{
|
||||
echo $exc->getMessage();
|
||||
error_log($exc->getTraceAsString());
|
||||
record_log($exc);
|
||||
$this->db->rollback();
|
||||
return;
|
||||
}
|
||||
|
|
@ -356,7 +365,7 @@ class Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* show only the lettered records from jrnx
|
||||
* @brief show only the lettered records from jrnx
|
||||
* it fills the array $this->content
|
||||
*/
|
||||
protected function show_lettered()
|
||||
|
|
@ -371,7 +380,7 @@ class Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* show only the lettered records from jrnx
|
||||
* @brief show only the lettered records from jrnx
|
||||
* it fills the array $this->content
|
||||
*/
|
||||
protected function show_lettered_diff()
|
||||
|
|
@ -386,7 +395,7 @@ class Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* show only the not lettered records from jrnx
|
||||
* @brief show only the not lettered records from jrnx
|
||||
* it fills the array $this->content
|
||||
*/
|
||||
protected function show_not_lettered()
|
||||
|
|
@ -484,8 +493,12 @@ class Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* only for operation retrieved thanks a account (jrnx.j_poste)
|
||||
*@class
|
||||
* @brief only for operation retrieved thanks a account (jrnx.j_poste)
|
||||
* manage the accounting entries for a given account
|
||||
*
|
||||
* @see unit-test/include/class/acc_letterTest.php
|
||||
*
|
||||
*/
|
||||
class Lettering_Account extends Lettering
|
||||
{
|
||||
|
|
@ -498,7 +511,7 @@ class Lettering_Account extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* fills the this->content, datas are filtered thanks
|
||||
* @brief fills the this->content, datas are filtered thanks
|
||||
* - fil_deb poss values t (debit), f(credit), ' ' (everything)
|
||||
* - fil_amount_max max amount
|
||||
* - fil_amount_min min amount
|
||||
|
|
@ -553,7 +566,7 @@ class Lettering_Account extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* fills this->content with all the operation for the this->account(jrnx.j_poste)
|
||||
* @brief fills this->content with all the operation for the this->account(jrnx.j_poste)
|
||||
*/
|
||||
public function get_all()
|
||||
{
|
||||
|
|
@ -582,7 +595,7 @@ class Lettering_Account extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* same as get_all but only for lettered operation
|
||||
* @brief same as get_all but only for lettered operation
|
||||
*/
|
||||
public function get_letter()
|
||||
{
|
||||
|
|
@ -611,7 +624,7 @@ class Lettering_Account extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* same as get_all but only for lettered operation
|
||||
*@brief same as get_all but only for lettered operation
|
||||
*/
|
||||
public function get_letter_diff()
|
||||
{
|
||||
|
|
@ -642,7 +655,7 @@ class Lettering_Account extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* same as get_all but only for unlettered operation
|
||||
*@brief same as get_all but only for unlettered operation
|
||||
*/
|
||||
public function get_unletter()
|
||||
{
|
||||
|
|
@ -668,7 +681,8 @@ class Lettering_Account extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* only for operation retrieved thanks a quick_code
|
||||
* @class
|
||||
* @brief only for operation retrieved thanks a quick_code
|
||||
* manage the accounting entries for a given card
|
||||
*/
|
||||
class Lettering_Card extends Lettering
|
||||
|
|
@ -688,7 +702,7 @@ class Lettering_Card extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* fills the this->content, datas are filtered thanks
|
||||
*@brief fills the this->content, datas are filtered thanks
|
||||
* - fil_deb poss values t (debit), f(credit), ' ' (everything)
|
||||
* - fil_amount_max max amount
|
||||
* - fil_amount_min min amount
|
||||
|
|
@ -748,7 +762,7 @@ class Lettering_Card extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* fills this->content with all the operation for the this->quick_code(j_qcode)
|
||||
* @brief fills this->content with all the operation for the this->quick_code(j_qcode)
|
||||
*/
|
||||
public function get_all()
|
||||
{
|
||||
|
|
@ -778,7 +792,7 @@ class Lettering_Card extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* same as get_all but only for lettered operation
|
||||
* @brief same as get_all but only for lettered operation
|
||||
*/
|
||||
public function get_letter()
|
||||
{
|
||||
|
|
@ -806,6 +820,10 @@ class Lettering_Card extends Lettering
|
|||
$this->content=$this->db->get_array($sql, array($this->quick_code, $this->start, $this->end));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief lettered operation with a different amount
|
||||
* @return void
|
||||
*/
|
||||
public function get_letter_diff()
|
||||
{
|
||||
$sql="
|
||||
|
|
@ -834,7 +852,7 @@ class Lettering_Card extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* same as get_all but only for unlettered operation
|
||||
* @brief same as get_all but only for unlettered operation
|
||||
*/
|
||||
public function get_unletter()
|
||||
{
|
||||
|
|
@ -857,7 +875,7 @@ class Lettering_Card extends Lettering
|
|||
}
|
||||
|
||||
/**
|
||||
* fill $this->content with the rows from this query
|
||||
* @brief fill $this->content with the rows from this query
|
||||
* Columns are
|
||||
* - j_id, id of jrnx
|
||||
* - j_date, date opeation (yyyy.mm.dd)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class Manager extends Fiche
|
|||
var $country; /*!< $country Country */
|
||||
var $cp; /*!< $cp Zip code */
|
||||
var $vat_number; /*!< $vat_number vat number */
|
||||
|
||||
use Trait_Card;
|
||||
/*! \brief Constructor
|
||||
* only a db connection is needed */
|
||||
function __construct($p_cn,$p_id=0)
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ class Noalyss_Appearance
|
|||
{
|
||||
static private $aCSSColor = ['H2' => '#9fbcd6',
|
||||
'MENU1' => '#000074',
|
||||
'BODY' => '#ffffff',
|
||||
'BODY' => '#fafafa',
|
||||
'MENU2' => '#3d3d87',
|
||||
'MENU1-SELECTED' => '#7191ea',
|
||||
'MENU1-SELECTED' => '#506cb8',
|
||||
'TR-ODD'=>'#DCE7F5',
|
||||
'TR-EVEN'=>'#ffffff',
|
||||
'INNER-BOX'=>'#DCE1EF',
|
||||
|
|
@ -44,7 +44,7 @@ class Noalyss_Appearance
|
|||
'FONT-MENU2' => '#ffffff',
|
||||
'FONT-TABLE' => '#222bd0',
|
||||
'FONT-DEFAULT' => '#000074',
|
||||
'FOLDER' => '#ffffff',
|
||||
'FOLDER' => '#fafafa',
|
||||
'FONT-TABLE-HEADER' =>'#0C106D',
|
||||
'FONT-FOLDER' => '#000074'];
|
||||
static private $aCSSColorName = array();
|
||||
|
|
@ -170,9 +170,7 @@ class Noalyss_Appearance
|
|||
.nav-pills .nav-link {
|
||||
color: {$menu1_font} !important;
|
||||
}
|
||||
.nav-link:hover {
|
||||
background-color:{$menu1_selected};
|
||||
}
|
||||
|
||||
table.sortable, table.table_large, table.result ,table.resultfooter {
|
||||
color:{$font_table} !important;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ class Noalyss_Parameter_Folder
|
|||
var $MY_TVA;
|
||||
var $MY_STREET;
|
||||
var $MY_NUMBER;
|
||||
var $MY_CP;
|
||||
var $MY_TEL;
|
||||
var $MY_PAYS;
|
||||
var $MY_COMMUNE;
|
||||
var $MY_POSTCODE;
|
||||
var $MY_PHONE;
|
||||
var $MY_COUNTRY;
|
||||
var $MY_CITY;
|
||||
var $MY_FAX;
|
||||
var $MY_ANALYTIC;
|
||||
var $MY_STRICT;
|
||||
|
|
@ -49,10 +49,12 @@ class Noalyss_Parameter_Folder
|
|||
var $MY_DEFAULT_ROUND_ERROR_CRED;
|
||||
var $MY_ANC_FILTER;
|
||||
var $MY_CURRENCY;
|
||||
var $MY_COUNTRY;
|
||||
var $MY_COUNTRY_CODE;
|
||||
var $MY_REPORT; //!< In Belgium , we need a report on the beginning of the exercice , not in France,
|
||||
|
||||
var $MY_INVOICE_FORMAT; //!< Default invoice format : BASIC, UBL21BEL, FACTURXFR
|
||||
|
||||
|
||||
const VALID_INVOICE_FORMAT=['BASIC','UBL21BEL','FACTURXFR'];
|
||||
// constructor
|
||||
function __construct($p_cn)
|
||||
{
|
||||
|
|
@ -75,10 +77,11 @@ class Noalyss_Parameter_Folder
|
|||
MY_TVA = [ {$this->MY_TVA }]
|
||||
MY_STREET = [ {$this->MY_STREET }]
|
||||
MY_NUMBER= [ {$this->MY_NUMBER }]
|
||||
MY_CP= [ {$this->MY_CP }]
|
||||
MY_TEL= [ {$this->MY_TEL }]
|
||||
MY_PAYS= [ {$this->MY_PAYS }]
|
||||
MY_COMMUNE= [ {$this->MY_COMMUNE }]
|
||||
MY_POSTCODE= [ {$this->MY_POSTCODE }]
|
||||
MY_PHONE= [ {$this->MY_PHONE }]
|
||||
MY_COUNTRY= [ {$this->MY_COUNTRY }]
|
||||
MY_COUNTRY_CODE= [ {$this->MY_COUNTRY_CODE }]
|
||||
MY_CITY= [ {$this->MY_CITY }]
|
||||
MY_FAX= [ {$this->MY_FAX }]
|
||||
MY_ANALYTIC= [ {$this->MY_ANALYTIC }]
|
||||
MY_STRICT= [ {$this->MY_STRICT }]
|
||||
|
|
@ -93,11 +96,16 @@ MY_DEFAULT_ROUND_ERROR_DEB= [ {$this->MY_DEFAULT_ROUND_ERROR_DEB }]
|
|||
MY_DEFAULT_ROUND_ERROR_CRED= [ {$this->MY_DEFAULT_ROUND_ERROR_CRED }]
|
||||
MY_ANC_FILTER= [ {$this->MY_ANC_FILTER }]
|
||||
MY_REPORT = [ {$this->MY_REPORT } ]
|
||||
|
||||
MY_INVOICE_FORMAT = [ {$this->MY_INVOICE_FORMAT} ]
|
||||
EOF;
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief check that the filter for ANC operation is valid
|
||||
* @param $p_value (string) list of digit for accounting separated by comma
|
||||
* @return void
|
||||
* @throws if value contains a no-digit value
|
||||
*/
|
||||
function check_anc_filter($p_value):void
|
||||
{
|
||||
$tmp_value=$p_value;
|
||||
|
|
@ -137,12 +145,17 @@ EOF;
|
|||
}
|
||||
|
||||
break;
|
||||
case 'MY_INVOICE_FORMAT':
|
||||
if ( !in_array($this->MY_INVOICE_FORMAT, Noalyss_Parameter_Folder::VALID_INVOICE_FORMAT))
|
||||
{
|
||||
throw new \Exception ('Format facture invalide');
|
||||
}
|
||||
default :
|
||||
$ret_value=htmlspecialchars($p_value);
|
||||
}
|
||||
return $ret_value;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
**************************************************
|
||||
* \brief save the parameter into the database by inserting or updating
|
||||
|
|
@ -188,10 +201,11 @@ EOF;
|
|||
$this->save('MY_TVA');
|
||||
$this->save('MY_STREET');
|
||||
$this->save('MY_NUMBER');
|
||||
$this->save('MY_CP');
|
||||
$this->save('MY_TEL');
|
||||
$this->save('MY_PAYS');
|
||||
$this->save('MY_COMMUNE');
|
||||
$this->save('MY_POSTCODE');
|
||||
$this->save('MY_PHONE');
|
||||
$this->save('MY_COUNTRY');
|
||||
$this->save('MY_COUNTRY_CODE');
|
||||
$this->save('MY_CITY');
|
||||
$this->save('MY_FAX');
|
||||
$this->save('MY_ANALYTIC');
|
||||
$this->save('MY_STRICT');
|
||||
|
|
@ -206,6 +220,7 @@ EOF;
|
|||
$this->save('MY_DEFAULT_ROUND_ERROR_CRED');
|
||||
$this->save("MY_ANC_FILTER");
|
||||
$this->save("MY_REPORT");
|
||||
$this->save("MY_INVOICE_FORMAT");
|
||||
|
||||
}
|
||||
/**
|
||||
|
|
@ -224,5 +239,15 @@ EOF;
|
|||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief build a SELECT html input
|
||||
* @return \ISelect
|
||||
*/
|
||||
function input_select_format() {
|
||||
$select_format_invoice=new \ISelect('invoice_format');
|
||||
$a_label=[_("Basic"),_("UBL21 Belgique"),_("FacturX France")];
|
||||
$select_format_invoice->transform(array_combine(Noalyss_Parameter_Folder::VALID_INVOICE_FORMAT,$a_label));
|
||||
$select_format_invoice->selected=$this->MY_INVOICE_FORMAT;
|
||||
return $select_format_invoice;
|
||||
}
|
||||
}
|
||||
|
|
@ -623,7 +623,7 @@ class Noalyss_User
|
|||
[uj_priv]
|
||||
@endverbatim
|
||||
*/
|
||||
function get_ledger($p_type='ALL', $p_access=3, $disable=TRUE)
|
||||
function get_ledger($p_type='ALL', $p_access=3, $all=TRUE)
|
||||
{
|
||||
$p_type=strtoupper($p_type);
|
||||
if (!in_array($p_type, ["FIN", "ALL", "ODS", "VEN", 'ACH']))
|
||||
|
|
@ -631,7 +631,7 @@ class Noalyss_User
|
|||
record_log(sprintf("UGL1, p_type %s", $p_type));
|
||||
throw new Exception("UGL1"._("Type incorrecte"));
|
||||
}
|
||||
if ($disable==TRUE)
|
||||
if ($all==TRUE)
|
||||
{
|
||||
$sql_enable="";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,10 +227,10 @@ select sum(signed_amount) delta,sum(debit) debit,sum(credit) credit from saldo_d
|
|||
$ledger->save($oe_data);
|
||||
$oe_result=_("Détail opération");
|
||||
$oe_result.=sprintf('<a class="detail" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a><hr>',
|
||||
$ledger->jr_id, dossier::id(), $ledger->internal);
|
||||
$ledger->jr_id, dossier::id(), $ledger->jr_internal);
|
||||
|
||||
$cn->exec_sql("update operation_exercice set oe_transfer_date=to_timestamp($1,'DD.MM.YY HH24:MI') , jr_internal=$2 where oe_id=$3",
|
||||
[date('d.m.Y H:i'),$ledger->internal,$this->operation_exercice_sql->oe_id]);
|
||||
[date('d.m.Y H:i'),$ledger->jr_internal,$this->operation_exercice_sql->oe_id]);
|
||||
|
||||
$cn->commit();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class Package_Repository
|
|||
*/
|
||||
function __construct()
|
||||
{
|
||||
if ( DEBUGNOALYSS > 1) self::$time_cache_second=1;
|
||||
// Check we can resolve the name
|
||||
$host=parse_url(NOALYSS_PACKAGE_REPOSITORY,PHP_URL_HOST);
|
||||
$file=$_ENV['TMP']."/web.xml";
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class PDF_Operation extends PDF {
|
|||
$this->pdf->write_cell(100, 6, $this->acc_detail->det->jr_pj_number);
|
||||
$this->pdf->line_new(4);
|
||||
$this->pdf->write_cell(50, 6, _("Commentaire"));
|
||||
$this->pdf->LongLine(130, 3 , $this->acc_detail->det->jr_comment);
|
||||
$this->pdf->write_multi(130, 3 , $this->acc_detail->det->jr_comment);
|
||||
$this->pdf->line_new(4);
|
||||
$this->pdf->write_cell(50, 6, _("Nom document"));
|
||||
$this->pdf->write_cell(100, 6, $this->acc_detail->det->jr_pj_name);
|
||||
|
|
@ -192,7 +192,7 @@ class PDF_Operation extends PDF {
|
|||
$fiche=new Fiche($this->cn,$fiche_id);
|
||||
$this->pdf->write_cell($width[0],6,$i+1);
|
||||
$this->pdf->write_cell($width[1],6,$fiche->get_quick_code());
|
||||
$this->pdf->LongLine($width[2],6,$row['j_text']);
|
||||
$this->pdf->write_multi($width[2],3,$row['j_text']);
|
||||
$this->pdf->write_cell($width[3],6,nbm($row["qs_price"],2),"",0,"R");
|
||||
$str=$this->str_vat($row["qs_vat_code"]);
|
||||
$this->pdf->write_cell($width[4],6,$str);
|
||||
|
|
@ -243,7 +243,7 @@ class PDF_Operation extends PDF {
|
|||
$fiche=new Fiche($this->cn,$fiche_id);
|
||||
$this->pdf->write_cell($width[0],6,$i+1);
|
||||
$this->pdf->write_cell($width[1],6,$fiche->get_quick_code());
|
||||
$this->pdf->LongLine($width[2],6,$row['j_text']);
|
||||
$this->pdf->write_multi($width[2],3,$row['j_text']);
|
||||
$this->pdf->write_cell($width[3],6,nbm($row["qp_price"],2),"",0,"R");
|
||||
$str=$this->str_vat($row["qp_vat_code"]);
|
||||
$this->pdf->write_cell($width[4],6,$str);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@
|
|||
|
||||
class PDFBalance_simple extends PDF
|
||||
{
|
||||
var $dossier; /*!< $dossier (string) Title */
|
||||
var $from_poste ; /*! $from_poste (text) lowest limit (alpha. order)*/
|
||||
var $to_poste ; /*! $from_poste (text) highest limit (alpha. order)*/
|
||||
var $from ; /*! $from(date dd.mm.yyyy) lowest date */
|
||||
var $to; /*! $to (date dd.mm.yyyy) highest date */
|
||||
/**
|
||||
*@brief set_info(dossier,from poste,to poste, from periode, to periode)
|
||||
*@param $p_from_poste start = poste
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ EOF;
|
|||
/**
|
||||
* @brief Display each row for the global
|
||||
* @param $obj Parm_Periode_SQL
|
||||
* @param $p_nb not used so far
|
||||
* @param $p_nb used to highlight odd rows
|
||||
* @param $p_js javascript variable
|
||||
*/
|
||||
static function display_row_global(Parm_Periode_SQL $obj, $p_nb, $p_js)
|
||||
|
|
|
|||
|
|
@ -228,10 +228,10 @@ class Pre_op_ach extends Pre_operation_detail
|
|||
{
|
||||
$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).' ';
|
||||
$e_client_label=$fClient->get_attribute(ATTR_DEF_NAME).' '.
|
||||
' Adresse : '.$fClient->get_attribute(ATTR_DEF_ADRESS).' '.
|
||||
$fClient->get_attribute(ATTR_DEF_POSTCODE).' '.
|
||||
$fClient->get_attribute(ATTR_DEF_CITY).' ';
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -296,11 +296,11 @@ class Pre_op_ach extends Pre_operation_detail
|
|||
{
|
||||
$fMarch=new Fiche($ledger->db);
|
||||
$fMarch->get_by_qcode($march);
|
||||
$march_label=$fMarch->strAttribut(ATTR_DEF_NAME);
|
||||
$march_label=$fMarch->get_attribute(ATTR_DEF_NAME);
|
||||
if ( $flag_tva=='Y')
|
||||
{
|
||||
if ( ! (isset($p_array["e_march$i"."_tva_id"])))
|
||||
$march_tva_id=$fMarch->strAttribut(ATTR_DEF_TVA);
|
||||
$march_tva_id=$fMarch->get_attribute(ATTR_DEF_TVA);
|
||||
}
|
||||
}
|
||||
// Show input
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ class Pre_Op_Advanced extends Pre_operation_detail
|
|||
{
|
||||
$Fiche = new Fiche($legder->db);
|
||||
$Fiche->get_by_qcode($quick_code->value);
|
||||
$label = $Fiche->strAttribut(ATTR_DEF_NAME);
|
||||
$label = $Fiche->get_attribute(ATTR_DEF_NAME);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -215,10 +215,10 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
{
|
||||
$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).' ';
|
||||
$e_client_label=$fClient->get_attribute(ATTR_DEF_NAME).' '.
|
||||
' Adresse : '.$fClient->get_attribute(ATTR_DEF_ADRESS).' '.
|
||||
$fClient->get_attribute(ATTR_DEF_POSTCODE).' '.
|
||||
$fClient->get_attribute(ATTR_DEF_CITY).' ';
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -283,11 +283,11 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
{
|
||||
$fMarch=new Fiche($ledger->db);
|
||||
$fMarch->get_by_qcode($march);
|
||||
$march_label=$fMarch->strAttribut(ATTR_DEF_NAME);
|
||||
$march_label=$fMarch->get_attribute(ATTR_DEF_NAME);
|
||||
if ( $flag_tva=='Y')
|
||||
{
|
||||
if ( ! (isset($p_array["e_march$i"."_tva_id"])))
|
||||
$march_tva_id=$fMarch->strAttribut(ATTR_DEF_TVA);
|
||||
$march_tva_id=$fMarch->get_attribute(ATTR_DEF_TVA);
|
||||
}
|
||||
}
|
||||
// Show input
|
||||
|
|
|
|||
|
|
@ -28,25 +28,42 @@
|
|||
* @brief Strategie class for the print_ledger class
|
||||
*
|
||||
*/
|
||||
#[AllowDynamicProperties]
|
||||
class Print_Ledger extends PDF
|
||||
{
|
||||
protected $filter_operation; //!< See Acc_Ledger_History::filter_operation
|
||||
private $ledger ; //!< concerned Ledger
|
||||
private $from ; //! integer parm_periode.p_id , start periode;
|
||||
private $to ; //! integer parm_periode.p_id , end periode;
|
||||
protected $a_TVA; //!< array of VAT
|
||||
protected $rap_tva; //!< VAT when page starts
|
||||
protected $rap_other; //!< VAT when page starts
|
||||
protected $jrn_type; //!< ledger type (VEN, ODS, FIN,ACH)
|
||||
protected $previous; //!< previous amount
|
||||
protected $other_tax_previous;
|
||||
protected $rap_htva; //!< price without when page starts
|
||||
protected $rap_tvac; //!< VAT+price when page starts
|
||||
protected $rap_priv;//!< Private when page starts
|
||||
protected $rap_nd;//!< ND VAT when page starts
|
||||
protected $rap_tva_np;//!< NP VAT when page starts
|
||||
protected $flag_other_tax; //! if other tax
|
||||
|
||||
protected $ledger ; //!< concerned Ledger
|
||||
protected $from ; //<! integer parm_periode.p_id , start periode;
|
||||
protected $to ; //<! integer parm_periode.p_id , end periode;
|
||||
|
||||
/**************************************************************************
|
||||
*internal variables for computing sum on PDF Listing
|
||||
*************************************************************************/
|
||||
protected $previous;//! $previous (array) see Acc_Ledger->previous_amount
|
||||
protected $rap_htva; //!< $rap_htva (float) previous price w/o VAT
|
||||
protected $rap_tvac; //!< $rap_tvac (float) previous amount
|
||||
//All Tax Include (full price)
|
||||
protected $rap_tva; //!< $rap_tva array(tva_id,amount)
|
||||
protected $rap_priv; //!< $rap_priv (float) personal expense
|
||||
protected $rap_other_tax; //!< $rap_other_tav, amount to report for other tax than VAT
|
||||
protected $other_tax_previous;//! $other_tax_previous (array)
|
||||
//see Acc_Ledger->previous_other_tax
|
||||
protected $a_Tva; //!< $a_Tva array ( tva_id,tva_label,tva_poste ) of existing_vat
|
||||
protected $jrn_type; //<! $jrn_type (string) 'VEN','ACH','ODS','FIN'
|
||||
protected $rap_nd; //!< $rap_nd (float) $no-deductible tax
|
||||
protected $rap_tva_np; //!< $rap_tva_np VAT not deductible
|
||||
|
||||
protected $flag_other_tax; //!< $flag_other_tax(bool) true if other tax exists
|
||||
protected $tp_htva; //!< $tp_htva (float) total page price w/o VAT
|
||||
protected $tp_tva; //!< $tp_tva (float) total page VAT
|
||||
protected $tp_tvac; //!< $tp_tvac (float) total page full price All Tax Incl.
|
||||
protected $tp_priv;//!< $tp_priv (float) total page personal expense
|
||||
protected $tp_nd;//!< $tp_nd (float) total page price w/o VAT
|
||||
protected $tp_tva_np;//!< $tp_tva_np (float) total page not deductible
|
||||
protected $show_col;
|
||||
protected $rap_other; //!< VAT when page starts
|
||||
|
||||
public function __construct(\Database $p_cn,
|
||||
$orientation,
|
||||
$unit,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Print_Ledger_Detail extends Print_Ledger
|
|||
public function __construct (Database $p_cn , Acc_Ledger $ledger,$p_from,$p_to)
|
||||
{
|
||||
|
||||
parent::__construct($p_cn,'L', 'mm', 'A4',$ledger,$p_from,$p_to,'all');
|
||||
parent::__construct($p_cn,'P', 'mm', 'A4',$ledger,$p_from,$p_to,'all');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -79,12 +79,12 @@ class Print_Ledger_Detail extends Print_Ledger
|
|||
$array=$this->get_ledger()->get_operation($this->get_from(),$this->get_to());
|
||||
|
||||
$this->SetFont('DejaVu','BI',7);
|
||||
$this->write_cell(215,7,'report Débit',0,0,'R');
|
||||
$this->write_cell(155,7,'report Débit',0,0,'R');
|
||||
$this->write_cell(30,7,nbm($rap_deb),0,0,'R');
|
||||
$this->line_new(4);
|
||||
$this->write_cell(215,7,'report Crédit',0,0,'R');
|
||||
$this->write_cell(155,7,'report Crédit',0,0,'R');
|
||||
$this->write_cell(30,7,nbm($rap_cred),0,0,'R');
|
||||
$this->line_new(4);
|
||||
$this->line_new(10);
|
||||
|
||||
// print all operation
|
||||
for ($i=0;$i< count($array);$i++)
|
||||
|
|
@ -92,13 +92,14 @@ class Print_Ledger_Detail extends Print_Ledger
|
|||
$this->SetFont('DejaVuCond','B',7);
|
||||
$row=$array[$i];
|
||||
|
||||
$this->LongLine(20,7,$row['pj']);
|
||||
$this->write_cell(15,7,$row['date_fmt']);
|
||||
$this->write_cell(20,7,$row['internal']);
|
||||
$this->LongLine(170,7,$row['comment']);
|
||||
$this->write_cell(20,7,nbm($row['montant']),0,0,'R');
|
||||
$this->write_multi(20, 4,$row['pj'],'T');
|
||||
$this->write_cell(15,4,$row['date_fmt'],'T');
|
||||
$this->write_cell(20,4,$row['internal'],'T');
|
||||
$this->write_multi(100,4,$row['comment'],'T');
|
||||
$this->write_cell(40,4,nbm($row['montant']),'T',0,'R');
|
||||
|
||||
|
||||
$this->line_new();
|
||||
$this->line_new(7);
|
||||
// get the entries
|
||||
$aEntry=$this->cn->get_array("select j_id,j_poste,j_qcode,j_montant,j_debit, j_text,".
|
||||
" case when j_text='' or j_text is null then pcm_lib else j_text end as desc,".
|
||||
|
|
@ -126,7 +127,7 @@ class Print_Ledger_Detail extends Print_Ledger
|
|||
}
|
||||
else
|
||||
$name=$entry['desc'];
|
||||
$this->write_cell(150,6,$name,0,0,'L');
|
||||
$this->write_cell(100,6,$name,0,0,'L');
|
||||
|
||||
// print amount
|
||||
$str_amount=nbm($entry['j_montant']);
|
||||
|
|
@ -134,6 +135,7 @@ class Print_Ledger_Detail extends Print_Ledger
|
|||
{
|
||||
$this->write_cell(20,6,$str_amount,0,0,'R');
|
||||
$this->write_cell(20,6,'',0,0,'R');
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -142,6 +144,7 @@ class Print_Ledger_Detail extends Print_Ledger
|
|||
}
|
||||
$this->line_new(4);
|
||||
}
|
||||
$this->line_new(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@
|
|||
|
||||
class Print_Ledger_Detail_Item extends Print_Ledger
|
||||
{
|
||||
|
||||
protected $show_col; //!< $show_col (bool) show columns
|
||||
|
||||
public function __construct (Database $p_cn,Acc_Ledger $p_jrn,$p_from,$p_to,$p_filter_operation)
|
||||
{
|
||||
|
||||
|
|
@ -110,7 +113,8 @@ class Print_Ledger_Detail_Item extends Print_Ledger
|
|||
$this->SetFont('DejaVu', '', 6);
|
||||
$internal="";
|
||||
$this->SetFillColor(220,221,255);
|
||||
$high=4;
|
||||
$high=8;
|
||||
$high_lg=8;
|
||||
for ( $i=0;$i< $nb ;$i++)
|
||||
{
|
||||
|
||||
|
|
@ -119,10 +123,10 @@ class Print_Ledger_Detail_Item extends Print_Ledger
|
|||
{
|
||||
|
||||
// Print the general info line width=270mm
|
||||
$this->LongLine(20, $high, $row['jr_date'],1, 'L', true);
|
||||
$this->write_multi(20, $high_lg, $row['jr_date'],1, 'L', true);
|
||||
$this->write_cell(20, $high,$row['jr_pj_number'].".". $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->write_multi(50, $high_lg, $row['quick_code']." ".$row['tiers_name'],1,'L',true);
|
||||
$this->write_multi(80, $high_lg, $row['jr_comment'],1,'L',true);
|
||||
$this->write_cell(20, $high, nbm($row['htva']), 1, 0, 'R', true);
|
||||
$this->write_cell(20, $high, nbm($row['tot_tva_np']), 1, 0, 'R', true);
|
||||
$this->write_cell(20, $high, nbm($row['other_tax_amount']), 1, 0, 'R', true);
|
||||
|
|
@ -152,9 +156,9 @@ class Print_Ledger_Detail_Item extends Print_Ledger
|
|||
|
||||
|
||||
// Header detail
|
||||
$this->LongLine(30,$high,_('QuickCode'));
|
||||
$this->write_multi(30,$high_lg,_('QuickCode'));
|
||||
$this->write_cell(30,$high,_('Poste'));
|
||||
$this->LongLine(70,$high,_('Libellé'));
|
||||
$this->write_multi(70,$high_lg,_('Libellé'));
|
||||
$this->write_cell(20,$high,_('Prix/Unit'),0,0,'R');
|
||||
$this->write_cell(20,$high,_('Quant.'),0,0,'R');
|
||||
$this->write_cell(20,$high,_('HTVA'),0,0,'R');
|
||||
|
|
@ -167,10 +171,10 @@ class Print_Ledger_Detail_Item extends Print_Ledger
|
|||
}
|
||||
}
|
||||
// Print detail sale / purchase
|
||||
$this->LongLine(30,$high,$row['j_qcode']);
|
||||
$this->write_multi(30,$high_lg,$row['j_qcode']);
|
||||
$this->write_cell(30,$high,$row['j_poste']);
|
||||
$comment=($row['j_text']=="")?$row['item_name']:$row['j_text'];
|
||||
$this->LongLine(70,$high,$comment);
|
||||
$this->write_multi(70,$high_lg,$comment);
|
||||
$this->write_cell(20,$high,nbm($row['price_per_unit']),0,0,'R');
|
||||
$this->write_cell(20,$high,nbm($row['quantity']),0,0,'R');
|
||||
$this->write_cell(20,$high,nbm($row['price']),0,0,'R');
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class Print_Ledger_Financial extends Print_Ledger
|
|||
$name=$ledger->get_tiers($this->jrn_type,$row['id']);
|
||||
$this->write_cell(40,5,$name,0,0,'L');
|
||||
|
||||
$this->LongLine(60,5,$row['comment'],0,'L');
|
||||
$this->write_multi(60,3,$row['comment'],0,'L');
|
||||
$amount=$this->cn->get_value('select qf_amount from quant_fin where jr_id=$1',array( $row['id']));
|
||||
$ret_amount_cur=$this->cn->execute("amount_cur",array($row['id']));
|
||||
|
||||
|
|
|
|||
|
|
@ -78,28 +78,29 @@ class Print_Ledger_Misc extends Print_Ledger
|
|||
$this->SetFont('DejaVu', '', 6);
|
||||
if ( $a_jrn == null ) return;
|
||||
$ledger=$this->get_ledger();
|
||||
$border='0';
|
||||
for ( $i=0;$i<count($a_jrn);$i++)
|
||||
{
|
||||
$row=$a_jrn[$i];
|
||||
|
||||
$this->write_cell(10,5, smaller_date($row['date']));
|
||||
$this->LongLine(30,5,$row['jr_pj_number']);
|
||||
$this->write_cell(20,5,$row['jr_internal']);
|
||||
$this->write_cell(10,3, smaller_date($row['date']),border:$border);
|
||||
$this->write_multi(30,3,$row['jr_pj_number'],border:$border);
|
||||
$this->write_cell(20,3,$row['jr_internal'],border:$border);
|
||||
$type=$this->cn->get_value("select jrn_def_type from jrn_def where jrn_def_id=$1",array($a_jrn[$i]['jr_def_id']));
|
||||
$other=mb_substr($ledger->get_tiers($type,$a_jrn[$i]['jr_id']),0,25);
|
||||
$this->LongLine(25,5,$other,0,'L');
|
||||
$this->write_multi(25,3,$other,$border,'L');
|
||||
$positive=$row['montant'];
|
||||
$this->LongLine(60,5,$row['comment'],0,'L');
|
||||
$this->write_multi(60,3,$row['str_comment'],$border,'L');
|
||||
if ( $type == 'FIN' ) {
|
||||
$positive = $this->cn->get_value("select qf_amount from quant_fin ".
|
||||
" where jr_id=".$row['jr_id']);
|
||||
}
|
||||
if ( $row['currency_id'] != 0 ) {
|
||||
$this->write_cell(20,5,nbm(bcadd($row['sum_ocvat_amount'],$row['sum_ocamount']),2).$row['cr_code_iso'],0,0,'R');
|
||||
$this->write_cell(20,3,nbm(bcadd($row['sum_ocvat_amount'],$row['sum_ocamount']),2).$row['cr_code_iso'],border:$border);
|
||||
} else {
|
||||
$this->write_cell(20,5,"");
|
||||
$this->write_cell(20,3,"",border:$border);
|
||||
}
|
||||
$this->write_cell(15,5,nbm($positive),0,0,'R');
|
||||
$this->write_cell(15,3,nbm($positive),$border,0,'R');
|
||||
$this->line_new(5);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
class Print_Ledger_Simple extends \Print_Ledger
|
||||
{
|
||||
|
||||
|
||||
public function __construct ($p_cn, Acc_Ledger $p_jrn,$p_from,$p_to,$p_filter_operation)
|
||||
{
|
||||
|
||||
|
|
@ -295,14 +297,14 @@ class Print_Ledger_Simple extends \Print_Ledger
|
|||
}
|
||||
$row=$a_jrn[$i];
|
||||
$ret_reconcile=$ledger->db->execute('reconcile_date',array($row['jr_id']));
|
||||
$this->LongLine(15,5,($row['jr_pj_number']),0);
|
||||
$this->write_cell(10,5,$row['str_date_short'],0,0);
|
||||
$this->write_multi(15,5,($row['jr_pj_number']),0);
|
||||
$this->write_multi(11,5,$row['str_date_short'],0,0);
|
||||
$this->write_cell(13,5,$row['jr_internal'],0,0);
|
||||
list($qc,$name)=$this->get_tiers($row['jr_id'],$this->jrn_type);
|
||||
$this->LongLine(40,5,"[".$qc."]".$name,0,'L');
|
||||
$this->write_multi(40,5,"[".$qc."]".$name,0,'L');
|
||||
|
||||
if ( !$flag_tva ) {
|
||||
$this->LongLine(65,5,mb_substr($row['jr_comment'],0,150),0,'L');
|
||||
$this->write_multi(65,5,mb_substr($row['jr_comment'],0,150),0,'L');
|
||||
}
|
||||
|
||||
/* get other amount (without vat, total vat included, private, ND */
|
||||
|
|
|
|||
|
|
@ -170,14 +170,14 @@ class Print_Ledger_Simple_Without_Vat extends Print_Ledger
|
|||
{
|
||||
|
||||
$row=$a_jrn[$i];
|
||||
$this->LongLine(15,5,($row['jr_pj_number']),0);
|
||||
$this->write_multi(15,3,($row['jr_pj_number']),0);
|
||||
$this->write_cell(15,5,$row['str_date_short'],0,0);
|
||||
$this->write_cell(20,5,$row['jr_internal'],0,0);
|
||||
list($qc,$name)=$this->get_tiers($row['jr_id'],$this->jrn_type);
|
||||
$this->write_cell(20,5,$qc,0,0);
|
||||
$this->LongLine(40,5,$name,0,'L');
|
||||
$this->write_multi(40,3,$name,0,'L');
|
||||
|
||||
$this->LongLine(105,5,$row['jr_comment'],0,'L');
|
||||
$this->write_multi(105,3,$row['jr_comment'],0,'L');
|
||||
|
||||
/* get other amount (without vat, total vat included, private, ND */
|
||||
$other=$ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class Stock_Goods extends Stock_Goods_Sql
|
|||
// Retrieve the good account for stock
|
||||
$code = new Fiche($p_cn);
|
||||
$code->get_by_qcode($goods);
|
||||
$code_marchandise = $code->strAttribut(ATTR_DEF_STOCK);
|
||||
$code_marchandise = $code->get_attribute(ATTR_DEF_STOCK);
|
||||
if ($code_marchandise == NOTFOUND || $code_marchandise=='')
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ require_once NOALYSS_INCLUDE.'/lib/user_common.php';
|
|||
* \brief class Supplier are a specific kind of card
|
||||
*/
|
||||
|
||||
// Use the view vw_supplier
|
||||
///@brief Use the view vw_supplier and the trait Trait_Card
|
||||
//
|
||||
class Supplier extends Fiche
|
||||
{
|
||||
|
|
@ -38,6 +38,9 @@ class Supplier extends Fiche
|
|||
var $cp; /*!< $cp Zip code */
|
||||
var $vat_number; /*!< $vat_number vat number */
|
||||
|
||||
use Trait_Card;
|
||||
|
||||
|
||||
/*! \brief Constructor
|
||||
* only a db connection is needed */
|
||||
function __construct($p_cn,$p_id=0)
|
||||
|
|
|
|||
|
|
@ -145,7 +145,9 @@ class Tax_Summary
|
|||
", [$this->date_start, $this->date_end]);
|
||||
if ($cnt==0 && $cnt_ledger !=0)
|
||||
{
|
||||
|
||||
throw new Exception('TX148:'._("Données manquantes"),100);
|
||||
|
||||
}
|
||||
/* -------------Purchase --------------------------------- */
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,8 @@ class Todo_List
|
|||
}
|
||||
if ( strcmp ($p_idx, 'tl_date') == 0 )
|
||||
{
|
||||
if ( noalyss_strlentrim($p_value) ==0 ||strlen($p_value) > 12 || isDate ($p_value) == false) return false;
|
||||
if ( noalyss_strlentrim($p_value) ==0 ||strlen($p_value) > 12 || isDate ($p_value) == false)
|
||||
{ $p_value = null;return true;}
|
||||
}
|
||||
if ( strcmp ($p_idx, 'tl_title') == 0 )
|
||||
{
|
||||
|
|
@ -113,7 +114,7 @@ class Todo_List
|
|||
{
|
||||
if ( isDate($this->tl_date) == false )
|
||||
{
|
||||
$this->tl_date=date('d.m.Y');
|
||||
$this->tl_date=null;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -129,7 +130,7 @@ class Todo_List
|
|||
{
|
||||
if ( $this->verify() != 0 ) return;
|
||||
if (trim($this->tl_title)=='')
|
||||
$this->tl_title=mb_substr(trim($this->tl_desc),0,30);
|
||||
$this->tl_title=mb_substr(trim($this->tl_desc??""),0,30);
|
||||
|
||||
if (trim($this->tl_title)=='')
|
||||
{
|
||||
|
|
@ -142,6 +143,12 @@ class Todo_List
|
|||
|
||||
$sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login,is_public) ".
|
||||
" values (to_date($1,'DD.MM.YYYY'),$2,$3,$4,$5) returning tl_id";
|
||||
|
||||
if ($this->tl_date == null) {
|
||||
$sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login,is_public) ".
|
||||
" values ($1,$2,$3,$4,$5) returning tl_id";
|
||||
|
||||
}
|
||||
$res=$this->cn->exec_sql(
|
||||
$sql,
|
||||
array($this->tl_date,
|
||||
|
|
@ -172,6 +179,11 @@ class Todo_List
|
|||
|
||||
$sql="update todo_list set tl_title=$1,tl_date=to_date($2,'DD.MM.YYYY'),tl_desc=$3,is_public=$5 ".
|
||||
" where tl_id = $4";
|
||||
|
||||
if ($this->tl_date == null) {
|
||||
$sql="update todo_list set tl_title=$1,tl_date=$2,tl_desc=$3,is_public=$5 ".
|
||||
" where tl_id = $4";
|
||||
}
|
||||
$res=$this->cn->exec_sql(
|
||||
$sql,
|
||||
array($this->tl_title,
|
||||
|
|
@ -296,7 +308,7 @@ class Todo_List
|
|||
}
|
||||
|
||||
/**
|
||||
* Display the note
|
||||
* @brief Display the note
|
||||
* @return html string
|
||||
*/
|
||||
function display()
|
||||
|
|
|
|||
46
include/class/trait_card.php
Normal file
46
include/class/trait_card.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?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 22/10/23
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Contains function used by object Customer , Supplier, Bank, ... that
|
||||
* are derivated from Fiche
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @brief Contains function used by object Customer , Supplier, Bank, ... that
|
||||
* are derivated from Fiche
|
||||
*/
|
||||
trait Trait_Card {
|
||||
/**
|
||||
* @brief For the follow-up module for customer, supplier, ... display a
|
||||
* filter
|
||||
* @param $url (string URL) url with folder id, access code ,...
|
||||
* @param $type_card (int) category of card see FICHE_TYPE_* in
|
||||
* include/constant.php
|
||||
*/
|
||||
public static function form_search($url,$type_card)
|
||||
{
|
||||
require_once NOALYSS_TEMPLATE."/trait_card-form_search.php";
|
||||
}
|
||||
}
|
||||
|
|
@ -46,6 +46,7 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
function __construct(V_Tva_rate_SQL $p_table)
|
||||
{
|
||||
parent::__construct($p_table);
|
||||
$this->icon_mod='left';
|
||||
$this->set_col_label("tva_id", _("id"));
|
||||
$this->set_col_label("tva_code", _("Code"));
|
||||
$this->set_col_label("tva_label", _("label"));
|
||||
|
|
@ -55,8 +56,11 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
$this->set_col_label("tva_reverse_account", _('Poste comptable autoliquidation'));
|
||||
$this->set_col_label("tva_sale", _("TVA Vente (C)"));
|
||||
$this->set_col_label("tva_purchase", _("TVA Achat (D)"));
|
||||
$this->set_col_label("tva_peppol_code", _("Code Facture électronique UBL"));
|
||||
$this->set_col_label("vx_code", _("Code Exemption TVA (vatex)"));
|
||||
|
||||
$this->set_property_visible('tva_reverse_account', false);
|
||||
$this->set_property_visible('tva_peppol_code', false);
|
||||
|
||||
$this->set_col_type("tva_both_side", "select",
|
||||
array(
|
||||
|
|
@ -89,7 +93,9 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
'tva_sale'=>_("Ne donnez pas ce poste comptable si ce code n'est pas utilisé à la vente"),
|
||||
'tva_payment_purchase'=>_('TVA due ou récupérable quand l\'opération est payée ou exécutée'),
|
||||
'tva_payment_sale'=>_('TVA due ou récupérable quand l\'opération est payée ou exécutée'),
|
||||
'tva_reverse_account'=>_("Forcer ce poste comptable pour autoliquidation : par défault, le poste d'autoliquidation est calculé : soit celui qui est en contrepartie, soit le même (voir manuel)")
|
||||
'tva_reverse_account'=>_("Forcer ce poste comptable pour autoliquidation : par défault, le poste d'autoliquidation est calculé : soit celui qui est en contrepartie, soit le même (voir manuel)"),
|
||||
'tva_peppol_code'=>_("Code TVA est utilisé pour les factures électroniques, plus d'information dans le manuel"),
|
||||
'vx_code'=>_("Code exemption pour facture PEPPOL (ubl)")
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +126,7 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
{
|
||||
$nb_order=count($this->a_order);
|
||||
$this->set_property_visible('tva_reverse_account', true);
|
||||
$this->set_property_visible('tva_peppol_code', true);
|
||||
echo "<table>";
|
||||
for ($i=0; $i<$nb_order; $i++)
|
||||
{
|
||||
|
|
@ -181,15 +188,33 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
$text->set_attribute('account', 'tva_sale');
|
||||
$text->size=$min_size;
|
||||
echo $text->input();
|
||||
}
|
||||
elseif ($this->a_type[$key]=="text")
|
||||
{
|
||||
$text=new IText($key);
|
||||
$text->value=$value;
|
||||
$min_size=(strlen($value??"")<30)?30:strlen($value)+5;
|
||||
$text->size=$min_size;
|
||||
}elseif ($key=='tva_peppol_code') {
|
||||
$text=new ISelect('tva_peppol_code');
|
||||
$text->selected=$value;
|
||||
$text->transform(array(
|
||||
null=>_('-')
|
||||
,"S"=>_('S Taux standard')
|
||||
,'AE'=>_('AE Autoliquidate mais pas INTRACOMM.')
|
||||
,'Z'=>_("Z TVA à 0%")
|
||||
,'K'=>_('K Autoliquidation INTRACOMM.')
|
||||
,'G'=>_('G TVA exempt pour export hors Europe')
|
||||
,'O'=>_('O TVA Hors périmètre application')
|
||||
,'E'=>_('E Exempté de TVA')
|
||||
));
|
||||
echo $text->input();
|
||||
} elseif ($key == "tva_id") {
|
||||
} elseif ($key == 'vx_code')
|
||||
{
|
||||
$text=\HtmlInput::hidden("vx_code",$value);
|
||||
echo $text;
|
||||
if ( $value !="") {
|
||||
$value= \Icon_Action::trash(uniqid(),"vat_code.select_value('xx')").$value;
|
||||
}
|
||||
echo span($value,'id="vx_value"');
|
||||
$js=sprintf("vat_code.list_vatex()");
|
||||
echo \Icon_Action::icon_magnifier(uniqid(),$js );
|
||||
|
||||
}
|
||||
elseif ($key == "tva_id") {
|
||||
$inum=new INum($key,$value);
|
||||
echo $inum->input();
|
||||
echo \HtmlInput::hidden("old_tva_id",$value);
|
||||
|
|
@ -204,6 +229,13 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
$text->set_attribute('account', 'tva_reverse_account');
|
||||
$text->size=$min_size;
|
||||
echo $text->input();
|
||||
}elseif ($this->a_type[$key]=="text")
|
||||
{
|
||||
$text=new IText($key);
|
||||
$text->value=$value;
|
||||
$min_size=(strlen($value??"")<30)?30:strlen($value)+5;
|
||||
$text->size=$min_size;
|
||||
echo $text->input();
|
||||
}
|
||||
echo "</td>";
|
||||
}
|
||||
|
|
@ -213,9 +245,21 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
HtmlInput::hidden($key, $value)
|
||||
);
|
||||
}
|
||||
echo '<td class="text-muted">';
|
||||
echo '<td >';
|
||||
if (isset ($this->a_comment[$key])) {
|
||||
print '<p class="text-muted">';
|
||||
echo $this->a_comment[$key];
|
||||
print '</p>';
|
||||
}
|
||||
if( $key == 'vx_code') {
|
||||
echo '<span id="vx_code_description">';
|
||||
$row=$this->table->cn->get_row("select vx_code,vx_code_name,vx_description,vx_remark from vatex_code where vx_code=$1",
|
||||
[$value]);
|
||||
if ( ! empty ($row)) {
|
||||
echo $row['vx_description'].span($row['vx_remark'],' class="text-muted" ');
|
||||
|
||||
}
|
||||
echo '</span>';
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
|
|
@ -233,6 +277,8 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
parent::from_request();
|
||||
$http=new \HttpInput();
|
||||
$this->table->tva_reverse_account=$http->request('tva_reverse_account');
|
||||
$this->table->tva_peppol_code=$http->request('tva_peppol_code');
|
||||
$this->table->vx_code=$http->request('vx_code');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -270,6 +316,8 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
$tva_rate->setp("tva_comment", $this->table->tva_comment);
|
||||
$tva_rate->setp("tva_both_side", $this->table->tva_both_side);
|
||||
$tva_rate->setp("tva_reverse_account", $this->table->tva_reverse_account);
|
||||
$tva_rate->setp("tva_peppol_code", $this->table->tva_peppol_code);
|
||||
$tva_rate->setp("vx_code", $this->table->vx_code);
|
||||
|
||||
// TVA accounting must be joined and separated with a comma
|
||||
$tva_purchase=(trim($this->table->tva_purchase)=="")?"#":$this->table->tva_purchase;
|
||||
|
|
@ -285,7 +333,9 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
if ( $this->previous_id != - 1 && $this->previous_id != $new_tva_id) {
|
||||
$cn->exec_sql("update tva_rate set tva_id = $1 where tva_id = $2",[$new_tva_id,$this->previous_id]);
|
||||
$this->table->setp("tva_id",$new_tva_id);
|
||||
}else $this->table->setp("tva_id",$tva_rate->getp("tva_id"));
|
||||
}else {
|
||||
$this->table->setp("tva_id",$tva_rate->getp("tva_id"));
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
|
|
@ -400,6 +450,23 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
if ( trim($this->table->tva_label??"")=="") {
|
||||
$this->set_error("tva_label", _('Le label ne peut être vide'));
|
||||
}
|
||||
|
||||
// if vatex is set then code invoice must be different from S and Z
|
||||
if ( trim($this->table->vx_code??"") != "" && in_array($this->table->tva_peppol_code,['S','Z'] ))
|
||||
{
|
||||
$this->set_error("vx_code",_("Le code d'exemption TVA ne peut être utilisé avec ce code Facture électronique UBL "));
|
||||
}
|
||||
// if vatex is set then code invoice must be different from S and Z
|
||||
if ( trim($this->table->vx_code??"") != "" && $this->table->tva_peppol_code=="")
|
||||
{
|
||||
$this->set_error("vx_code",_("Le code d'exemption TVA n' pas de sens sans code Facture électronique"));
|
||||
}
|
||||
// if tva_peppol_code is not S or Z then a VATEX code must be supplied
|
||||
if ( ! in_array($this->table->tva_peppol_code??"",["Z","S"]) && trim($this->table->vx_code??"" ) =="")
|
||||
{
|
||||
$this->set_error("vx_code",_("Un code d'exemption de TVA doit être fourni, voyez le manuel"));
|
||||
|
||||
}
|
||||
if ($this->count_error()!=0)
|
||||
return false;
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue