Merge branch 'master' of gitlab.noalyss.eu:noalyss/noalyss

This commit is contained in:
Dany De Bontridder 2018-12-27 20:11:54 +01:00
commit 6b2b579bab
30 changed files with 4763 additions and 2080 deletions

View file

@ -7,8 +7,11 @@
# Author D. DE BONTRIDDER danydb@aevalys.eu
echo "Extract"
cd ..
FILE=/tmp/file-list.$$
find . -type f -name \*.php > $FILE
# CATALOG
xgettext -L PHP -j --from-code=UTF-8 -p html/lang/ html/*.php include/*.php include/template/*.php include/ext/*/*.php include/ext/*/include/*.php include/ext/*/include/template/*.php include/lib/*.php include/ajax/*.php include/export/*.php include/class/*.php
xgettext -L PHP -j --from-code=UTF-8 -p html/lang -f $FILE
# For dutch
echo "Dutch"

View file

@ -1,5 +1,4 @@
<?php
/*
* This file is part of NOALYSS.
*
@ -112,26 +111,37 @@ if ( DEBUG ) {
?>
<div id="debug_div" style="border:slategray solid 1px;margin-left: 0px;position:absolute;background:white;display:fixed;top:2px;left:25px;z-index:1000;display:none">
<h2>$_POST</h2>
<pre>
<?php
var_dump($_POST);
print_r($_POST);
?>
</pre>
<h2>$_GET</h2>
<pre>
<?php
var_dump($_GET);
print_r($_GET);
?>
</pre>
<h2>$_REQUEST</h2>
<pre>
<?php
var_dump($_REQUEST);
print_r($_REQUEST);
?>
</pre>
<h2>$_SESSION</h2>
<pre>
<?php
var_dump($_SESSION);
print_r($_SESSION);
?>
</pre>
<h2>$GLOBALS</h2>
<pre>
<?php
var_dump($GLOBALS);
print_r($GLOBALS);
?>
</pre>
</div>
<script>
@ -301,10 +311,12 @@ if (isset($_REQUEST['ac']))
echo '<a class="button" href="do.php?'.Dossier::get().'">';
echo _('Retour');
echo '</a>';
return;
}
else {
alert($e->getMessage());
record_log($e->getTraceAsString());
throw $e;
}
}
}
@ -335,6 +347,7 @@ else
{
echo $exc->getMessage();
record_log($exc->getTraceAsString());
throw $e;
}
}

View file

@ -705,6 +705,7 @@ function add_div(obj)
/* elt.setStyle({visibility:'visible'}); */
elt.style.visibility = 'visible';
elt.show();
return elt;
}
catch (e)
{
@ -1270,15 +1271,14 @@ function save_predf_op(obj)
*amount_id is either a html obj. or an amount and the field tiers if given
* @param {type} dossier
* @param {type} ctl_concern
* @param {type} amount_id
* @param {type} ledger
* @param {float or string} amount_id Amount or DOM Id of the element containing the amount
* @param {float} ledger
* @param {type} p_id_targetDom Element (div) where to display the search result
* @param p_tiers id of the Tiers
* @returns {undefined}
*/
function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target,p_tiers)
{
var dossier = g('gDossier').value;
if (amount_id === undefined)
{
amount_id = 0;
@ -1294,7 +1294,7 @@ function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target,p
amount_id = $(amount_id).innerHTML;
}
}
var tiers=""
var tiers="";
if ( p_tiers ) tiers=p_tiers;
var target = "";
if ( p_id_target !="") {
@ -1420,7 +1420,8 @@ function remove_waiting_node()
}
function remove_waiting_box()
{
removeDiv('wait_box');
if ( $('wait_box') ) { Effect.Fade('wait_box', { duration: 0.6 }); }
remove_waiting_node();
}
/**
@ -2973,7 +2974,7 @@ function confirm_box(p_obj, p_message,p_callback_true)
*/
function alert_box(p_message)
{
smoke.alert(p_message,false , {ok:'ok',classname:"inner_box"});
smoke.alert(p_message, undefined,{ok:'ok',classname:"inner_box"});
}
@ -3410,7 +3411,7 @@ var progressIdx = 0;
/**
* Start the progress bar
* @param {string} p_taskid id to monitor
* @param {int} p_dossier
* @param {int} p_message
*/
function progress_bar_start(p_taskid,p_message)
{

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -34,7 +34,7 @@ BODY {
color:darkblue;
/*font-size:0.9em;
font-size:0.95rem;*/
/*! background-color: #FBF9F4; */
background-color:#FCFDFD;
}
input{
font-family: 'OpenSansRegular';
@ -315,7 +315,7 @@ td.selectedcell{
/*color:#FFFFFF;*/
width:250px;
text-align:center;
background-color: lightsteelblue;
background-color: #002ba3;
border-style: solid;
border-width: 1px;
border-color:white;
@ -356,7 +356,6 @@ td.selectedcell a.mtitle,div.content td.selectedcell a.mtitle {
/*! height: 100%; */
width: 100%;
font-size: 1rem;
/* background-color:lightsteelblue;*/
font-weight: normal;
}
a.dossier {
@ -454,17 +453,15 @@ div.content a.mtitle {
color:#0000FF;
cursor: pointer;
/*! background-color: white; */
background-color: transparent;
}
div.content a.mtitle:hover {
text-decoration:none;
display:inline;
background-color:#888;
color:orangered;
background-color:transparent;
color:lightskyblue;
cursor: pointer;
}
@ -1075,16 +1072,16 @@ ul {
a.line,div.content a.line
{
text-decoration:underline;
display:inline;
display:inline !important;
/* color: #0000FF; */
cursor:pointer;
}
a.line:hover,div_content a.line
{
text-decoration:underline;
display:inline;
color: #FFFFFF;
background-color:#336699;
display:inline !important;
color: #FFFFFF !important;
background-color:#336699 !important;
cursor:pointer;
}

View file

@ -319,4 +319,7 @@ span.inplace_edit
span.inplace_edit_input
{
text-decoration: none;
}
.inum {
text-align: right;
}

View file

@ -29,7 +29,7 @@ require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php';
html_page_start($_SESSION['g_theme']);
@html_page_start($_SESSION['g_theme']);
$rep=new Database();
require_once NOALYSS_INCLUDE.'/class/user.class.php';
$User=new User($rep);

View file

@ -37,6 +37,8 @@ $pa_id=$http->request("pa_id");
$anc=new Poste_analytique_SQL($cn, $p_id);
$anc->pa_id=$pa_id;
$anc->ga_id=$http->request("ga_id","string",null);
$accounting=new Anc_Account_Table($anc);
$accounting->set_object_name($ctl_id);
$accounting->set_callback("ajax_misc.php");

View file

@ -102,8 +102,8 @@ echo _('Filtre')." ";
$rad=new IRadio();
$array_ledger=$g_user->get_ledger('ALL',3);
$array=get_array_column($array_ledger,'jrn_def_id');
$selected=(isset($_GET['r_jrn']))?$_GET['r_jrn']:null;
$select_cat=(isset($_GET['r_cat']))?$_GET['r_cat']:null;
$selected=(isset($_GET['r_jrn']))?$_GET['r_jrn']:array();
$select_cat=(isset($_GET['r_cat']))?$_GET['r_cat']:array();
$array_cat=Acc_Ledger::array_cat();
echo '<ul style="list-style-type:none">';

View file

@ -324,10 +324,10 @@ class Acc_Ledger extends jrn_def_sql
throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]"));
// reverse in QUANT_FIN table
$Res=$this->db->exec_sql(" INSERT INTO quant_fin(
qf_bank, qf_other, qf_amount,jr_id)
SELECT qf_bank, qf_other, qf_amount*(-1),$1
qf_bank, qf_other, qf_amount,jr_id,j_id)
SELECT qf_bank, qf_other, qf_amount*(-1),$1,$3
FROM quant_fin where jr_id=$2",
array($seq, $this->jr_id));
array($seq, $this->jr_id,$j_id));
if ($Res==false)
throw (new Exception(__FILE__.__LINE__."SQL ERROR[ $sql ]"));

View file

@ -524,7 +524,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
$r.='</fieldset>';
$r.='<div class="myfieldset"><h1 class="legend">Extrait de compte</h1>';
$r.='<div class="myfieldset"><h1 class="legend">'._("Extrait de compte").'</h1>';
//--------------------------------------------------
// Saldo begin end
//-------------------------------------------------
@ -532,10 +532,10 @@ class Acc_Ledger_Fin extends Acc_Ledger
$r.='<tr>';
// Extrait
//--
$r.=tr('<td> Numéro d\'extrait</td>' . td(h($e_pj)));
$r.='<tr><td >Solde début extrait </td>';
$r.=tr('<td>'._("Numéro d'extrait").' </td>' . td(h($e_pj)));
$r.='<tr><td >'._("Solde début extrait").' </td>';
$r.='<td style="num">' . nbm($first_sold) . '</td></tr>';
$r.='<tr><td>Solde fin extrait </td>';
$r.='<tr><td>'._("Solde fin extrait").' </td>';
$r.='<td style="num">' . nbm($last_sold) . '</td></tr>';
$r.='</table>';
@ -545,11 +545,11 @@ class Acc_Ledger_Fin extends Acc_Ledger
//-------------------------------------------------
$r.='<TABLE style="width:100%" id="fin_item">';
$r.="<TR>";
if ($chdate==2) $r.='<th>Date</th>';
$r.="<th style=\"width:auto;text-align:left\" colspan=\"2\">Nom</TH>";
$r.="<th style=\"text-align:left\" >Commentaire</TH>";
$r.="<th style=\"text-align:right\">Montant</TH>";
$r.='<th colspan="2"> Op. Concern&eacute;e(s)</th>';
if ($chdate==2) $r.='<th>'._("Date").'</th>';
$r.="<th style=\"width:auto;text-align:left\" colspan=\"2\">"._("Nom")."</th>";
$r.="<th style=\"text-align:left\" >"._("Commentaire")."</th>";
$r.="<th style=\"text-align:right\">"._("Montant")."</th>";
$r.='<th colspan="2">'._("Op. Concernée(s)").'</th>';
/* if we use the AC */
if ($g_parameter->MY_ANALYTIC != 'nu')
@ -631,14 +631,14 @@ class Acc_Ledger_Fin extends Acc_Ledger
$r.="</TABLE>";
// saldo
$r.='<br>Ancien solde = ' . $solde;
$r.='<br>'.sprintf(_("Ancien solde = %d"), $solde);
$new_solde+=$tot_amount;
$r.='<br>Nouveau solde = ' . $new_solde;
$r.='<br>Difference =' . $tot_amount;
$r.='<br>'.sprintf(_("Nouveau solde = %d"),$new_solde);
$r.='<br>'.sprintf(_("Difference = %d"), $tot_amount);
// check for upload piece
$file = new IFile();
$r.="<br>Ajoutez une pi&egrave;ce justificative ";
$r.="<br>"._("Ajoutez une pièce justificative")." ";
$r.=$file->input("pj", "");
$r.='</div>';
@ -739,7 +739,8 @@ class Acc_Ledger_Fin extends Acc_Ledger
$amount = 0.0;
$idx_operation = 0;
$ret = '<table class="result" >';
$ret.=tr(th('Date').th('n° interne') . th('Quick Code') . th('Nom') . th('Libellé') . th('Montant', ' style="text-align:right"'));
$ret.=tr(th(_('Date')).th(_('n° interne')) . th(_('Quick Code'))
. th(_('Nom')) . th(_('Libellé')) . th(_('Montant'), ' style="text-align:right"'));
// Credit = goods
$get_solde=true;
for ($i = 0; $i < $nb_item; $i++)
@ -814,7 +815,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
}
$acc_operation->periode = $tperiode;
$acc_operation->qcode = ${"e_other" . $i};
$j_id = $acc_operation->insert_jrnx();
$j_id_other = $acc_operation->insert_jrnx();
$acc_operation = new Acc_Operation($this->db);
$acc_operation->date = $e_date;
@ -931,7 +932,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
/**
* save also into quant_fin
*/
$this->insert_quant_fin($fBank->id, $jr_id, $fPoste->id, ${"e_other$i" . "_amount"});
$this->insert_quant_fin($fBank->id, $jr_id, $fPoste->id, ${"e_other$i" . "_amount"},$j_id_other);
if ($g_parameter->MY_ANALYTIC != "nu")
{
@ -950,7 +951,12 @@ class Acc_Ledger_Fin extends Acc_Ledger
$js_detail = HtmlInput::detail_op($jr_id, $internal);
// Compute display
$row = td($e_date).td($js_detail) . td(${"e_other$i"}) . td($fPoste->strAttribut(ATTR_DEF_NAME)) . td(${"e_other" . $i . "_comment"}) . td(nbm(${"e_other$i" . "_amount"}), 'class="num"');
$row = td($e_date)
. td($js_detail)
. td(${"e_other$i"})
. td($fPoste->strAttribut(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);
@ -1147,17 +1153,18 @@ class Acc_Ledger_Fin extends Acc_Ledger
/**
* insert into the quant_fin table
* @param $bank_id is the f_id of the bank
* @param $jr_id is the jrn.jr_id of the operation
* @param $other is the f_id of the benefit
* @param $amount is the amount
* @param integer $bank_id is the f_id of the bank
* @param integer $jr_id is the jrn.jr_id of the operation
* @param integer $other is the f_id of the benefit
* @param integer $amount is the amount
* @param integer $p_j_id is the j_id of the operation
*/
function insert_quant_fin($p_bankid, $p_jrid, $p_otherid, $p_amount)
function insert_quant_fin($p_bankid, $p_jrid, $p_otherid, $p_amount,$p_j_id)
{
$sql = "INSERT INTO quant_fin(qf_bank, jr_id, qf_other, qf_amount)
VALUES ($1, $2, $3, $4);";
$sql = "INSERT INTO quant_fin(qf_bank, jr_id, qf_other, qf_amount,j_id)
VALUES ($1, $2, $3, $4,$5);";
$this->db->exec_sql($sql, array($p_bankid, $p_jrid, $p_otherid, round($p_amount, 2)));
$this->db->exec_sql($sql, array($p_bankid, $p_jrid, $p_otherid, round($p_amount, 2),$p_j_id));
}
}

View file

@ -244,15 +244,15 @@ j1.j_poste as poste
*/
function get ( )
{
$sql=" select jr_id as cn from jrn_rapt where jra_concerned=".$this->jr_id.
" union ".
" select jra_concerned as cn from jrn_rapt where jr_id=".$this->jr_id;
$Res=$this->db->exec_sql($sql);
$sql=" select jr_id as cn from jrn_rapt where jra_concerned=$1
union
select jra_concerned as cn from jrn_rapt where jr_id=$2";
$Res=$this->db->exec_sql($sql,array($this->jr_id,$this->jr_id));
// If nothing is found return null
$n=Database::num_row($Res);
if ($n ==0 ) return null;
if ($n ==0 ) return [];
// put everything in an array
for ($i=0;$i<$n;$i++)

View file

@ -237,7 +237,6 @@ class Document
$lt="<";
$gt=">";
}
//read the file
while(! feof($h))
{
@ -270,33 +269,8 @@ class Document
* Change type of cell to numeric
* allow numeric cel in ODT for the formatting and formula
*/
if ( is_numeric($value) && $p_type=='OOo')
{
// For libreOffice <=4
$searched='/office:value-type="string"><text:p>'.$pattern.'/i';
$replaced='office:value-type="float" office:value="'.$value.'"><text:p>'.$pattern;
$buffer=preg_replace($searched, $replaced, $buffer,1);
// For libreOffice >=4
$searched='/office:value-type="string" calcext:value-type="string"><text:p>'.$pattern.'/i';
$replaced='office:value-type="float" office:value="'.$value.'" calcext:value-type="float"><text:p>'.$pattern;
$buffer=preg_replace($searched, $replaced, $buffer,1);
}
// replace into the $buffer
// take the position in the buffer
$pos=strpos($buffer,$to_remove);
// get the length of the string to remove
$len=strlen($to_remove);
if ( $p_type=='OOo' )
{
$value=str_replace('&','&amp;',$value);
$value=str_replace('<','&lt;',$value);
$value=str_replace('>','&gt;',$value);
$value=str_replace('"','&quot;',$value);
$value=str_replace("'",'&apos;',$value);
}
$buffer=substr_replace($buffer,$value,$pos,$len);
// if the pattern if found we replace it
$buffer=\Document::replace_value($buffer,$pattern, $value, 1,$p_type);
}
}
}
@ -1111,9 +1085,9 @@ class Document
}
$sell=${'e_march'.$i.'_price'};
$qt=${'e_quant'.$i};
$tot=bcmul($sell,$qt);
$tot=bcadd($tot,$tva_amount);
$sum=bcadd($sum,$tot);
$tot=bcmul($sell,$qt);
$tot=bcadd($tot,$tva_amount);
$sum=bcadd($sum,$tot);
}
$r=round($sum,2);
@ -1125,10 +1099,10 @@ class Document
{
$tva='e_march'.$i.'_tva_amount';
if (! isset(${$tva})) $tva_amount=0.0;
else $tva_amount=$
{
$tva
};
else {
$tva_amount=${$tva};
$tva_amount=($tva_amount=="")?0:$tva_amount;
}
$sum+=$tva_amount;
$sum=round($sum,2);
}
@ -1303,5 +1277,48 @@ class Document
$this->db->exec_sql('update document set d_description = $1 where d_id=$2',
array($p_desc,$this->d_id));
}
/**
* 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
* @param mixed $p_value
*/
static function replace_value($p_buffer, $p_pattern, $p_value,$p_limit=-1,$p_type='OOo')
{
$check=$p_pattern;
$check=str_replace(['&lt;','&gt;','<','>','='], "", $check);
if ( preg_replace('/[^[:alnum:]^_]/', '', $check) != $check)
{
throw new Exception(sprintf(_("chaine à remplacer [%s] contient un caractère interdit"), $p_pattern));
}
$count=0;
if (is_numeric($p_value) && $p_type == 'OOo')
{
/* -- works only with OOo Calc -- */
$searched='/office:value-type="string"><text:p>'.$p_pattern.'/i';
$replaced='office:value-type="float" office:value="'.$p_value.'"><text:p>'.$p_value;
$p_buffer=preg_replace($searched, $replaced, $p_buffer,$p_limit,$count);
if ( $count == 0) {
/* -- work with libreOffice > 5 -- */
$searched='/office:value-type="string" calcext:value-type="string"><text:p>(<text:s\/>)*'.$p_pattern.'/i';
$replaced='office:value-type="float" office:value="'.$p_value.'" calcext:value-type="float"><text:p>'.$p_value;
$p_buffer=preg_replace($searched, $replaced, $p_buffer,$p_limit,$count);
}
}
if ($count == 0)
{
if ( $p_type=='OOo' )
{
$p_value=str_replace('&','&amp;',$p_value);
$p_value=str_replace('<','&lt;',$p_value);
$p_value=str_replace('>','&gt;',$p_value);
$p_value=str_replace('"','&quot;',$p_value);
$p_value=str_replace("'",'&apos;',$p_value);
}
$p_buffer=preg_replace('/'.$p_pattern.'/i', $p_value, $p_buffer,$p_limit);
}
return $p_buffer;
}
}

View file

@ -57,6 +57,8 @@ class Fiche
$this->cn=$p_cn;
$this->id=$p_id;
$this->quick_code='';
$this->attribut=[];
}
/**
*@brief used with a usort function, to sort an array of Fiche on the name
@ -344,8 +346,8 @@ class Fiche
*/
function strAttribut($p_ad_id,$p_return=1)
{
$return=($p_return==1)?NOTFOUND:"";
if ( sizeof ($this->attribut) == 0 )
$return=($p_return==1)?NOTFOUND:"";
if (is_array($this->attribut) && sizeof ($this->attribut) == 0 )
{
if ($this->id==0) {

View file

@ -248,7 +248,7 @@ class Pre_Op_Advanced extends Pre_operation_detail
if ($poste->value != '')
{
$Poste = new Acc_Account($legder->db);
$Poste->set_parameter('value', $poste->value);
$Poste->find_by_value($poste->value);
$label = $Poste->get_lib();
}

View file

@ -39,6 +39,7 @@ class Pre_operation
var $p_jrn; /*!< $p_jrn jrn_def_id */
var $jrn_type; /*!< $jrn_type */
var $name; /*!< $name name of the predef. operation */
var $detail; /*!< Pre_operation_detail */
function __construct($cn,$p_id=0)
{

View file

@ -62,11 +62,9 @@ if ( strpos($inc_path,";") != 0 ) {
$os=1; /* $os is 1 for unix */
}
set_include_path($new_path);
ini_set ('default_charset',"UTF-8");
ini_set ('session.use_cookies',1);
ini_set ('magic_quotes_gpc','off');
ini_set ('session.use_only_cookies','on');
ini_set ('session.use_cookies',1);
@ini_set ('default_charset',"UTF-8");
@ini_set ('session.use_cookies',1);
@ini_set ('magic_quotes_gpc','off');
if ( ! defined('OVERRIDE_PARAM')) {
ini_set ('max_execution_time',240);
@ -110,7 +108,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
if ( ! defined ("SYSINFO_DISPLAY")) {
define ("SYSINFO_DISPLAY",TRUE);
}
define ("DBVERSION",129);
define ("DBVERSION",132);
define ("MONO_DATABASE",25);
define ("DBVERSIONREPO",18);
define ('NOTFOUND','--not found--');

View file

@ -1103,10 +1103,18 @@ function show_menu($module)
}
// if file is not a plugin, include the file, otherwise
// include the plugin launcher
if ( $file[0]['me_type'] != 'PL')
if ( $file[0]['me_type'] != 'PL') {
if (file_exists ($file[0]['me_file']) )
{
require_once $file[0]['me_file'];
else
} elseif ( file_exists(NOALYSS_INCLUDE.'/'.$file[0]['me_file'])) {
require_once NOALYSS_INCLUDE.'/'.$file[0]['me_file'];
}else {
echo echo_warning(_("Fichier non trouvé"));
}
} else {
require 'extension_get.inc.php';
}
exit();
}

View file

@ -80,7 +80,9 @@ class HttpInput
throw new Exception(_("Type invalide")."[ $p_name ] = {$this->array[$p_name]}"
, EXC_PARAM_TYPE);
}
$this->array[$p_name]=h($this->array[$p_name]);
if (is_string($this->array )) {
$this->array[$p_name]=h($this->array[$p_name]);
}
}else {
throw new Exception(_("Unknown type"));
}

View file

@ -29,16 +29,21 @@
require_once NOALYSS_INCLUDE.'/lib/html_input.class.php';
class ISelect extends HtmlInput
{
/**
* Constructor , $p_value is supposed to be an array
* @param string $p_name name of the element
* @param array $p_value
* @param DOMID $p_id
*/
function __construct($p_name="", $p_value="", $p_id="")
{
parent::__construct($p_name,$p_value,$p_id);
$this->name=$p_name;
if ( $p_value == "" || ! is_array($p_value)) {
$this->value=array();
} else {
$this->value=$p_value;
}
$this->id=$p_id;
parent::__construct($p_name, $p_value, $p_id);
if ( $p_value =="" )
{
$this->value=[];
} else {
$this->value=$p_value;
}
}
/*!\brief show the html input of the widget*/
public function input($p_name=null,$p_value=null)

View file

@ -810,27 +810,24 @@ function check()
* we translate the code from the database into a hardcoded label
*/
$idx=$p_row[$v];
if ( ! isset($this->a_select[$v][$idx])) {
/*
* Check if index exists
*/
$array_to_search=$this->a_select[$v];
$value=$p_row[$v];
$nb_search=count($array_to_search);
$found=FALSE;
for ( $e=0;$e< $nb_search;$e++) {
if (isset ($array_to_search[$e]['value']) && $array_to_search[$e]['value']==$value ) {
$found=TRUE;
echo td($array_to_search[$e]['label']);
}
/*
* Check if index exists
*/
$array_to_search=$this->a_select[$v];
$value=$p_row[$v];
$nb_search=(is_array($array_to_search))?count($array_to_search):0;
$found=FALSE;
for ( $e=0;$e< $nb_search;$e++) {
if (isset ($array_to_search[$e]['value']) && $array_to_search[$e]['value']==$value ) {
$found=TRUE;
echo td($array_to_search[$e]['label']);
}
}
if ( ! $found) {
echo td("--");
if ( ! $found) {
echo td("--");
}
} else {
echo td($this->a_select[$v][$idx]["label"]);
}
}else {

View file

@ -79,7 +79,7 @@ echo $mtable->display_table(" where pcm_val::text like '{$g_start}%' order by pc
<div id="go_up" class="inner_box" style="padding:0px;left:auto;width:250px;height: 100px;display:none;position:fixed;bottom:5px;right:20px">
<div style="margin:3%;padding:3%">
<a class="icon" href="#up_top" >&#xe81a;</a><a href="javascript:show_calc()" class="icon">&#xf1ec;</a>
<input type="button" id="pcmn_update_add_bt3" value="<?php echo _('Ajout poste comptable'); ?>">
<input type="button" class="smallbutton" id="pcmn_update_add_bt3" value="<?php echo _('Ajout poste comptable'); ?>">
</div>
</div>
</div>

View file

@ -159,11 +159,11 @@ if (isset($_POST['clone']))
where p_id=$2
", array($new_id, $p_id));
$cn->exec_sql("select menu_complete_dependency($1)",array($new_id));
$cn->exec_sql("update profile_menu
set pm_id_dep=(select distinct higher_dep
from v_menu_dependency as a
$cn->exec_sql("update profile_menu
set pm_id_dep=(select distinct higher_dep
from v_menu_dependency as a
where
a.pm_id= profile_menu.pm_id)
a.pm_id= profile_menu.pm_id)
where pm_id_dep is null and p_id=$1",array($new_id));
$cn->commit();
$p_id=$new_id;
@ -203,7 +203,7 @@ if (isset($_POST['delete_profil']))
}
}
//************************************
// Modify the menu
// Modify the menu
//************************************
if (isset($_POST['mod']))
{
@ -213,7 +213,7 @@ if (isset($_POST['mod']))
$pm_id=$http->post("pm_id", "number");
// profile id
$p_id=$http->post("p_id", "number");
// display order
// display order
$p_order=$http->post("p_order", "number");
// code to add
$me_code=$http->post("me_code");
@ -268,7 +268,7 @@ if (isset($_POST['add_menu'])||isset($_POST['add_impress']))
$p_dep=$http->post("dep","number",null);
// profile id
$p_id=$http->post("p_id", "number");
// display order
// display order
$p_order=$http->post("p_order");
// code to add
$me_code=$http->post("me_code");
@ -326,9 +326,9 @@ if (isset($_POST['add_menu'])||isset($_POST['add_impress']))
* if me_code_dep == -1, it means it is null
*/
$me_code_dep=($me_code_dep==-1)?null:$me_code_dep;
/*
* Do not insert twice the same menu
* Do not insert twice the same menu
*/
$duplicate = $cn->get_value(" select count(*) from profile_menu where "
. " pm_id_dep = $1 and me_code = $2",array($pm_id_dep,$me_code));
@ -348,7 +348,7 @@ if (isset($_POST['add_menu'])||isset($_POST['add_impress']))
catch (Exception $exc)
{
alert($exc->getMessage());
$cn->rollback;
$cn->rollback();
}
}
@ -439,5 +439,5 @@ $dep=$http->post("dep","string","");
}
selected_menu=rowid;
}
</script>
</script>

View file

@ -0,0 +1,109 @@
begin;
INSERT INTO public.menu_ref
(me_code, me_menu, me_file, me_url, me_description, me_parameter, me_javascript, me_type, me_description_etendue)
VALUES('CFGCURRENCY', 'Devises', 'acc_currency_cfg.inc.php', NULL, 'Configuration des devises', NULL,NULL,'ME','Permet de configurer les devises');
INSERT INTO public.profile_menu
(pm_id, me_code, me_code_dep, p_id, p_order, p_type_display, pm_default, pm_id_dep)
VALUES(nextval('profile_menu_pm_id_seq'), 'CFGCURRENCY', 'PARAM', 1, 50, 'E', 0, 45);
-- Drop table
-- DROP TABLE public.currency
CREATE TABLE public.currency (
id serial NOT NULL,
cr_code_iso varchar(10) NULL,
CONSTRAINT currency_pk PRIMARY KEY (id),
CONSTRAINT currency_un UNIQUE (cr_code_iso)
);
-- Drop table
-- DROP TABLE public.currency_history
CREATE TABLE public.currency_history (
id serial NOT NULL,
ch_value numeric(20,6) NOT NULL,
ch_from date NOT NULL,
currency_id int4 NOT NULL,
CONSTRAINT currency_history_pk PRIMARY KEY (id),
CONSTRAINT currency_history_currency_fk FOREIGN KEY (currency_id) REFERENCES currency(id)
ON DELETE RESTRICT ON UPDATE CASCADE
)
;
-- Ajouter commentaire sur colonne
ALTER TABLE public.currency ADD cr_name varchar(80) NULL;
insert into currency (id,cr_code_iso,cr_name) values (0,'EUR','EUR');
insert into currency (cr_code_iso,cr_name) values ('XCFA','XCFA');
insert into currency_history (ch_value,ch_from,currency_id) values (1,to_date('01.01.2000','DD.MM.YYYY'),0);
insert into currency_history (ch_value,ch_from,currency_id) values (655.95700,to_date('01.01.2000','DD.MM.YYYY'),1);
ALTER TABLE public.currency_history ADD CONSTRAINT currency_history_check CHECK (ch_value > 0) ;
-- Create view to manage the table
create view v_currency_last_value as
with recent_rate as
( select
currency_id,max(ch_from) as rc_from
from
currency_history
group by currency_id
)
select
cr1.id as currency_id,
cr1.cr_name,
cr1.cr_code_iso,
ch1.id as currency_history_id,
ch1.ch_value as ch_value,
to_char(rc_from,'DD.MM.YYYY') as str_from
from
currency as cr1
join recent_rate on (currency_id=cr1.id)
join currency_history as ch1 on (recent_rate.currency_id=ch1.currency_id and rc_from=ch1.ch_from);
COMMENT ON COLUMN public.currency_history.id IS 'pk' ;
COMMENT ON COLUMN public.currency_history.ch_value IS 'rate of currency depending of currency of the folder' ;
COMMENT ON COLUMN public.currency_history.ch_from IS 'Date when the rate is available' ;
COMMENT ON COLUMN public.currency_history.currency_id IS 'FK to currency' ;
COMMENT ON COLUMN public.currency.cr_code_iso IS 'Code ISO' ;
COMMENT ON COLUMN public.currency.cr_name IS 'Name of the currency' ;
-- Drop table
-- DROP TABLE public.operation_currency
CREATE TABLE public.operation_currency (
id bigserial NOT NULL,
oc_amount numeric(20,6) NOT NULL, -- amount in currency
oc_vat_amount numeric(20,6) NULL DEFAULT 0, -- vat amount in currency
oc_price_unit numeric(20,6) NULL, -- unit price in currency
j_id int8 NOT NULL, -- fk to jrnx
CONSTRAINT operation_currency_pk PRIMARY KEY (id)
);
ALTER TABLE public.operation_currency ADD CONSTRAINT operation_currency_jrnx_fk FOREIGN KEY (j_id) REFERENCES public.jrnx(j_id) ON DELETE CASCADE ON UPDATE CASCADE;
-- Column comments
COMMENT ON COLUMN public.operation_currency.oc_amount IS 'amount in currency' ;
COMMENT ON COLUMN public.operation_currency.oc_vat_amount IS 'vat amount in currency' ;
COMMENT ON COLUMN public.operation_currency.oc_price_unit IS 'unit price in currency' ;
COMMENT ON COLUMN public.operation_currency.j_id IS 'fk to jrnx' ;
alter table jrn add currency_id bigint default 0;
update jrn set currency_id=0;
alter table jrn add currency_rate numeric (20,6) default 1;
update jrn set currency_rate=1;
alter table jrn add currency_rate_ref numeric(20,6) default 1;
update jrn set currency_rate_ref=1;
ALTER TABLE public.jrn ADD CONSTRAINT jrn_currency_fk FOREIGN KEY (currency_id) REFERENCES public.currency(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
insert into version (val,v_description) values (130,'Currency : create view , create tables ');
commit;

View file

@ -0,0 +1,46 @@
begin;
CREATE OR REPLACE FUNCTION isnumeric(text) RETURNS BOOLEAN AS $$
DECLARE x NUMERIC;
BEGIN
x = $1::NUMERIC;
RETURN TRUE;
EXCEPTION WHEN others THEN
RETURN FALSE;
END;
$$
STRICT
LANGUAGE plpgsql IMMUTABLE;
CREATE OR REPLACE FUNCTION isdate(text,text) RETURNS BOOLEAN AS $$
DECLARE x timestamp;
BEGIN
x := to_date($1,$2);
RETURN TRUE;
EXCEPTION WHEN others THEN
RETURN FALSE;
END;
$$
LANGUAGE plpgsql;
ALTER TABLE public.jrn_def ADD currency_id int NULL;
ALTER TABLE public.jrn_def ALTER COLUMN currency_id SET DEFAULT 0;
update public.jrn_def set currency_id = 0 ;
ALTER TABLE public.jrn_def ALTER COLUMN currency_id SET NOT NULL;
ALTER TABLE public.jrn_def ADD CONSTRAINT jrn_def_currency_fk FOREIGN KEY (currency_id) REFERENCES public.currency(id);
COMMENT ON COLUMN public.jrn_def.currency_id IS 'Default currency for financial ledger';
alter table quant_fin add j_id bigint;
with j_fin as (
select jrnx.j_id,quant_fin.qf_id from quant_fin join jrn using (jr_id) join jrnx on (j_grpt=jr_grpt_id and f_id=qf_other)
)
update quant_fin set j_id =j_fin.j_id from j_fin where j_fin.qf_id=quant_fin.qf_id;
alter table quant_fin add constraint jrnx_j_id_fk foreign key (j_id ) references jrnx(j_id) on delete cascade on update cascade;
insert into version (val,v_description) values (131,'Currency : adapt quant_fin');
commit;

View file

@ -0,0 +1,180 @@
begin;
drop VIEW public.v_detail_sale;
CREATE OR REPLACE VIEW public.v_detail_sale as
WITH m AS (
SELECT sum(quant_sold_1.qs_price) AS htva,
sum(quant_sold_1.qs_vat) AS tot_vat,
sum(quant_sold_1.qs_vat_sided) AS tot_tva_np,
jrn_1.jr_id
FROM quant_sold quant_sold_1
JOIN jrnx jrnx_1 USING (j_id)
JOIN jrn jrn_1 ON jrnx_1.j_grpt = jrn_1.jr_grpt_id
GROUP BY jrn_1.jr_id
)
SELECT jrn.jr_id,
jrn.jr_date,
jrn.jr_date_paid,
jrn.jr_ech,
jrn.jr_tech_per,
jrn.jr_comment,
jrn.jr_pj_number,
jrn.jr_internal,
jrn.jr_def_id,
jrnx.j_poste,
jrnx.j_text,
jrnx.j_qcode,
quant_sold.qs_fiche AS item_card,
a.name AS item_name,
quant_sold.qs_client,
b.vw_name AS tiers_name,
b.quick_code,
tva_rate.tva_label,
tva_rate.tva_comment,
tva_rate.tva_both_side,
quant_sold.qs_vat_sided AS vat_sided,
quant_sold.qs_vat_code AS vat_code,
quant_sold.qs_vat AS vat,
quant_sold.qs_price AS price,
quant_sold.qs_quantite AS quantity,
quant_sold.qs_price / quant_sold.qs_quantite AS price_per_unit,
m.htva,
m.tot_vat,
m.tot_tva_np,
oc.oc_amount,
oc.oc_vat_amount,
(select cr_code_iso from currency where jrn.currency_id=currency.id) as cr_code_iso
FROM jrn
JOIN jrnx ON jrn.jr_grpt_id = jrnx.j_grpt
JOIN quant_sold USING (j_id)
JOIN vw_fiche_name a ON quant_sold.qs_fiche = a.f_id
JOIN vw_fiche_attr b ON quant_sold.qs_client = b.f_id
JOIN tva_rate ON quant_sold.qs_vat_code = tva_rate.tva_id
JOIN m ON m.jr_id = jrn.jr_id
left join operation_currency as oc on (oc.j_id=jrnx.j_id)
;
drop VIEW public.v_detail_purchase;
CREATE OR REPLACE VIEW public.v_detail_purchase
AS WITH m AS (
SELECT sum(quant_purchase_1.qp_price) AS htva,
sum(quant_purchase_1.qp_vat) AS tot_vat,
sum(quant_purchase_1.qp_vat_sided) AS tot_tva_np,
jrn_1.jr_id
FROM quant_purchase quant_purchase_1
JOIN jrnx jrnx_1 USING (j_id)
JOIN jrn jrn_1 ON jrnx_1.j_grpt = jrn_1.jr_grpt_id
GROUP BY jrn_1.jr_id
)
SELECT jrn.jr_id,
jrn.jr_date,
jrn.jr_date_paid,
jrn.jr_ech,
jrn.jr_tech_per,
jrn.jr_comment,
jrn.jr_pj_number,
jrn.jr_internal,
jrn.jr_def_id,
jrnx.j_poste,
jrnx.j_text,
jrnx.j_qcode,
quant_purchase.qp_fiche AS item_card,
a.name AS item_name,
quant_purchase.qp_supplier,
b.vw_name AS tiers_name,
b.quick_code,
tva_rate.tva_label,
tva_rate.tva_comment,
tva_rate.tva_both_side,
quant_purchase.qp_vat_sided AS vat_sided,
quant_purchase.qp_vat_code AS vat_code,
quant_purchase.qp_vat AS vat,
quant_purchase.qp_price AS price,
quant_purchase.qp_quantite AS quantity,
quant_purchase.qp_price / quant_purchase.qp_quantite AS price_per_unit,
quant_purchase.qp_nd_amount AS non_ded_amount,
quant_purchase.qp_nd_tva AS non_ded_tva,
quant_purchase.qp_nd_tva_recup AS non_ded_tva_recup,
m.htva,
m.tot_vat,
m.tot_tva_np,
oc.oc_amount,
oc.oc_vat_amount,
(select cr_code_iso from currency where jrn.currency_id=currency.id) as cr_code_iso
FROM jrn
JOIN jrnx ON jrn.jr_grpt_id = jrnx.j_grpt
JOIN quant_purchase USING (j_id)
JOIN vw_fiche_name a ON quant_purchase.qp_fiche = a.f_id
JOIN vw_fiche_attr b ON quant_purchase.qp_supplier = b.f_id
JOIN tva_rate ON quant_purchase.qp_vat_code = tva_rate.tva_id
JOIN m ON m.jr_id = jrn.jr_id
left join operation_currency as oc on (oc.j_id=jrnx.j_id)
;
create or replace view v_all_account_currency as
select sum(oc_amount) as sum_oc_amount,sum(oc_vat_amount) as sum_oc_vat_amount,x.j_poste,x.j_id
from
quant_fin as q1
join (select j_id ,jr_id,f_id,j_poste
from jrnx as j1 join
jrn as j on (j1.j_grpt=jr_grpt_id)
) as x on (q1.jr_id=x.jr_id)
join operation_currency as oc on (oc.j_id=q1.j_id)
group by x.j_poste,x.j_id
union all
select sum(oc_amount),sum(oc_vat_amount),x.j_poste,x.j_id
from
quant_purchase as q1
join (select j_id ,jr_id,f_id,j_poste,jr_internal
from jrnx as j1 join
jrn as j on (j1.j_grpt=jr_grpt_id)
) as x on (q1.qp_internal=x.jr_internal and (x.f_id=q1.qp_fiche or x.f_id=qp_supplier) )
join operation_currency as oc on (oc.j_id=q1.j_id)
group by x.j_poste,x.j_id
union all
select sum(oc_amount),sum(oc_vat_amount),x.j_poste,x.j_id
from
quant_sold as q1
join (select j_id ,jr_id,f_id,j_poste,jr_internal
from jrnx as j1 join
jrn as j on (j1.j_grpt=jr_grpt_id)
) as x on (q1.qs_internal=x.jr_internal and (x.f_id=q1.qs_fiche or x.f_id=q1.qs_client) )
join operation_currency as oc on (oc.j_id=q1.j_id)
group by x.j_poste,x.j_id
;
create or replace view v_all_card_currency as
select sum(oc_amount) as sum_oc_amount,sum(oc_vat_amount) as sum_oc_vat_amount,x.f_id,x.j_id
from
quant_fin as q1
join (select j_id ,jr_id,f_id,j_poste
from jrnx as j1 join
jrn as j on (j1.j_grpt=jr_grpt_id)
) as x on (q1.jr_id=x.jr_id)
join operation_currency as oc on (oc.j_id=q1.j_id)
group by x.f_id,x.j_id
union all
select sum(oc_amount),sum(oc_vat_amount),x.f_id,x.j_id
from
quant_purchase as q1
join (select j_id ,jr_id,f_id,j_poste,jr_internal
from jrnx as j1 join
jrn as j on (j1.j_grpt=jr_grpt_id)
) as x on (q1.qp_internal=x.jr_internal and (x.f_id=q1.qp_fiche or x.f_id=qp_supplier) )
join operation_currency as oc on (oc.j_id=q1.j_id)
group by x.f_id,x.j_id
union all
select sum(oc_amount),sum(oc_vat_amount),x.f_id,x.j_id
from
quant_sold as q1
join (select j_id ,jr_id,f_id,j_poste,jr_internal
from jrnx as j1 join
jrn as j on (j1.j_grpt=jr_grpt_id)
) as x on (q1.qs_internal=x.jr_internal and (x.f_id=q1.qs_fiche or x.f_id=q1.qs_client) )
join operation_currency as oc on (oc.j_id=q1.j_id)
group by x.f_id,x.j_id
;
insert into version (val,v_description) values (132,'Currency : Create view for managing currency ');
commit;

View file

@ -30,12 +30,12 @@ $aRap=$oRap->get();
$nb_document=($detail->det->jr_pj_name != "")?1:0;
$nb_aRap=(is_array($aRap))?count($aRap):0;
// Array of tab
//
$a_tab['writing_div']=array('id'=>'writing_div'.$div,'label'=>_('Ecriture Comptable'),'display'=>'none');
$a_tab['info_operation_div']=array('id'=>'info_operation_div'.$div,'label'=>_('Information'),'display'=>'none');
$a_tab['linked_operation_div']=array('id'=>'linked_operation_div'.$div,'label'=>_('Opérations liées').'('.count($aRap).')','display'=>'none');
$a_tab['linked_operation_div']=array('id'=>'linked_operation_div'.$div,'label'=>_('Opérations liées').'('.$nb_aRap.')','display'=>'none');
$a_tab['document_operation_div']=array('id'=>'document_operation_div'.$div,'label'=>_('Document').'('.$nb_document.')','display'=>'block');
$a_tab['linked_action_div']=array('id'=>'linked_action_div'.$div,'label'=>_('Actions Gestion').'('.count($a_followup).')','display'=>'none');
$a_tab['analytic_div']=array('id'=>'analytic_div'.$div,'label'=>_('Comptabilité Analytique'),'display'=>'none');

View file

@ -1,55 +0,0 @@
CREATE OR REPLACE FUNCTION comptaproc.insert_quant_purchase(p_internal text, p_j_id numeric, p_fiche character varying, p_quant numeric, p_price numeric, p_vat numeric, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, p_nd_tva_recup numeric, p_dep_priv numeric, p_client character varying, p_tva_sided numeric, p_price_unit numeric)
RETURNS void
LANGUAGE plpgsql
AS $function$
declare
fid_client integer;
fid_good integer;
account_priv account_type;
fid_good_account account_type;
n_dep_priv numeric;
begin
n_dep_priv := p_dep_priv;
select p_value into account_priv from parm_code where p_code='DEP_PRIV';
select f_id into fid_client from
fiche_detail where ad_id=23 and ad_value=upper(trim(p_client));
select f_id into fid_good from
fiche_detail where ad_id=23 and ad_value=upper(trim(p_fiche));
select ad_value into fid_good_account from fiche_detail where ad_id=5 and f_id=fid_good;
if strpos( fid_good_account , account_priv ) = 1 then
n_dep_priv=p_price;
end if;
insert into quant_purchase
(qp_internal,
j_id,
qp_fiche,
qp_quantite,
qp_price,
qp_vat,
qp_vat_code,
qp_nd_amount,
qp_nd_tva,
qp_nd_tva_recup,
qp_supplier,
qp_dep_priv,
qp_vat_sided,
qp_unit)
values
(p_internal,
p_j_id,
fid_good,
p_quant,
p_price,
p_vat,
p_vat_code,
p_nd_amount,
p_nd_tva,
p_nd_tva_recup,
fid_client,
n_dep_priv,
p_tva_sided,
p_price_unit);
return;
end;
$function$