Merge branch 'dev7109'

This commit is contained in:
Dany De Bontridder 2019-09-04 21:24:13 +02:00
commit c249f398bd
33 changed files with 555 additions and 97 deletions

View file

@ -2946,7 +2946,7 @@ function init_scroll()
"style":"padding:5px;left:auto;width:auto;height: auto;display:none;position:fixed;bottom:30%;right:50px;text-align:center;font-size:20px",
id:"go_up"
});
up.innerHTML=' <a class="icon" href="#up_top" >&#xe81a;</a><a href="javascript:show_calc()" class="icon">&#xf1ec;</a>';
up.innerHTML='<a class="icon" onclick="document.getElementById(\'go_up\').hide()" style="float:right;font-size:70%">&#xe816;</a> <a class="icon" href="#up_top" >&#xe81a;</a><a href="javascript:show_calc()" class="icon">&#xf1ec;</a>';
document.body.appendChild(up);
window.onscroll=function () {
if ( document.viewport.getScrollOffsets().top> 0) {

View file

@ -48,7 +48,7 @@ catch (Exception $exc)
error_log($exc->getTraceAsString());
return;
}
ob_start();
$compute_key=new Anc_Key($key);
$pos=strrpos($target,"t");
$row=substr($target,$pos+1);

View file

@ -70,8 +70,7 @@ switch ($action)
Dossier::id(), $frd_id, $objname, $ad_id);
$answer['content']=$cn->get_value("select ad_text from attr_def where ad_id=$1",
[$ad_id]).
HtmlInput::anchor(SMALLX, "javascript:void(0)", $js,
' class="smallbutton" style="padding:0px;display:inline" ');
Icon_Action::trash(uniqid(), $js);
}
catch (Exception $exc)
{

View file

@ -171,7 +171,7 @@ if ($sa=='anc_menu')
echo '<div class="content">';
echo '<TABLE class="vert_mtitle">';
echo '<TR><TD class="first">';
echo '<a href="?'.$url.'">'._("Ajout d'un plan comptable").'</a>';
echo '<a href="?'.$url.'">'._("Ajout d'un plan analytique").'</a>';
echo '</TD></TR>';
echo '</TABLE>';
@ -191,7 +191,7 @@ if ($sa=='anc_menu')
if ($obj->isAppend()==true)
{
echo '<TR><TD class="first">';
echo '<a href="?'.$url.'">'._("Ajout d'un plan comptable").'</a>';
echo '<a href="?'.$url.'">'._("Ajout d'un plan analytique").'</a>';
echo '</TD></TR>';
}
foreach ($list as $line)

View file

@ -714,7 +714,7 @@ class Acc_Ledger extends jrn_def_sql
// CA
if ($g_parameter->MY_ANALYTIC!='nu') // use of AA
{
if (preg_match("/^[6,7]+/", $strPoste)==1)
if ($g_parameter->match_analytic( $strPoste)==TRUE)
{
// show form
$op=new Anc_Operation($this->db);
@ -1293,7 +1293,7 @@ class Acc_Ledger extends jrn_def_sql
$tot_cred+=($acc_op->type=='c')?$acc_op->amount:0;
if ($g_parameter->MY_ANALYTIC!="nu")
{
if (preg_match("/^[6,7]+/", $poste)==1)
if ($g_parameter->match_analytic( $poste)==TRUE)
{
// for each item, insert into operation_analytique */
@ -2357,10 +2357,12 @@ class Acc_Ledger extends jrn_def_sql
{
throw new Exception(_('Choix du type de journal est obligatoire'));
}
if ($negative_amount == 1 && trim($negative_warning)=="") {
if (isset( $negative_warning) && $negative_amount == 1 && trim($negative_warning)=="") {
throw new Exception(_("Avertissement ne peut être vide"));
}
if ( $negative_amount <> 0 && $negative_amount <> 1 ){
if ( isset( $negative_amount) && $negative_amount <> 0 && $negative_amount <> 1 ){
throw new Exception(_("Valeur invalide"));
}
}
@ -2391,8 +2393,8 @@ class Acc_Ledger extends jrn_def_sql
$this->jrn_deb_max_line=($min_row<1)?1:$min_row;
$this->jrn_def_description=$p_description;
$this->jrn_enable=$jrn_enable;
$this->jrn_def_negative_amount=$negative_amount;
$this->jrn_def_negative_warning=$negative_warning;
$this->jrn_def_negative_amount=(isset($negative_amount))?$negative_amount:'0';
$this->jrn_def_negative_warning=(isset ($negative_warning))?$negative_warning:_("Attention, ce journal doit utiliser des montants négatifs");
switch ($this->jrn_def_type)
{

View file

@ -612,7 +612,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
}
$r.='</td>';
// encode the pa
if ($g_parameter->MY_ANALYTIC != 'nu' && preg_match("/^[6,7]/", $fTiers->strAttribut(ATTR_DEF_ACCOUNT)) == 1) // use of AA
if ($g_parameter->MY_ANALYTIC != 'nu' && $g_parameter->match_analytic($fTiers->strAttribut(ATTR_DEF_ACCOUNT)) == 1) // use of AA
{
// show form
$anc_op = new Anc_Operation($this->db);

View file

@ -656,7 +656,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
Stock_Goods::insert_goods($this->db,array('j_id'=>$j_id,'goods'=>${'e_march'.$i},'quant'=>$nNeg*${'e_quant'.$i},'dir'=>$dir,'repo'=>$repo)) ;
}
if ( $g_parameter->MY_ANALYTIC != "nu" )
if ( $g_parameter->MY_ANALYTIC != "nu" && $g_parameter->match_analytic($poste_val))
{
// for each item, insert into operation_analytique */
$op=new Anc_Operation($this->db);

View file

@ -282,7 +282,13 @@ class Acc_Ledger_Search
*/
public function build_search_sql($p_array, $p_order="", $p_where="")
{
$sql="select jr_id ,
$sql="with cas as (
select distinct jr_id
from jrn
join jrnx on (jr_grpt_id=j_grpt)
where
exists(select 1 from operation_analytique where j_id=jrnx.j_id) )
select jr_id ,
jr_montant,
substr(jr_comment,1,60) as jr_comment,
to_char(jr_ech,'DD.MM.YY') as str_jr_ech,
@ -336,11 +342,15 @@ class Acc_Ledger_Search
else null
end as total_invoice,
jr_date_paid,
to_char(jr_date_paid,'DD.MM.YY') as str_jr_date_paid
to_char(jr_date_paid,'DD.MM.YY') as str_jr_date_paid,
cas.jr_id as analytic_op
from
jrn as X left join jrn_note using(jr_id)
jrn as X
left join jrn_note using(jr_id)
left join cas using( jr_id)
join jrn_def on jrn_def_id=jr_def_id
join parm_periode on p_id=jr_tech_per";
join parm_periode on p_id=jr_tech_per
";
if (!empty($p_array))
extract($p_array, EXTR_SKIP);
@ -771,6 +781,8 @@ class Acc_Ledger_Search
$r.="<TD>";
$tmp_jr_comment=h($row['jr_comment']);
$r.=$tmp_jr_comment;
if ( $row['analytic_op'] != "")
$r.=sprintf('<span style="float:right;background:black;color:white;">&ni;</span>');
$r.="</TD>";
$r.=td(h($row['n_text']), ' style="font-size:0.87em%"');
// Amount

View file

@ -364,7 +364,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
}
if ($g_parameter->MY_ANALYTIC != "nu") {
if ($g_parameter->MY_ANALYTIC != "nu" && $g_parameter->match_analytic($poste_val)) {
// for each item, insert into operation_analytique */
$op = new Anc_Operation($this->db);
$op->oa_group = $group;
@ -819,7 +819,8 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$r.='</td>';
}
// encode the pa
if ($g_parameter->MY_ANALYTIC != 'nu') { // use of AA
if ($g_parameter->MY_ANALYTIC != 'nu'
&& $g_parameter->match_analytic($fiche->strAttribut(ATTR_DEF_ACCOUNT))==TRUE) { // use of AA
// show form
$anc_op = new Anc_Operation($this->db);
$null = ($g_parameter->MY_ANALYTIC == 'op') ? 1 : 0;

View file

@ -324,6 +324,7 @@ class Anc_Key
{
$val[$number][$i]=bcmul($p_amount,$a_amount[$i]['ke_percent']);
$val[$number][$i]=bcdiv($val[$number][$i],100);
$val[$number][$i]=abs($val[$number][$i]);
}
$array['val']=$val;

View file

@ -59,6 +59,7 @@ class Anc_Plan
"pa_description as description from plan_analytique $p_order";
$ret=$this->db->exec_sql($sql);
$array=Database::fetch_all($ret);
if ($array == FALSE ) return array();
return $array;
}

View file

@ -45,6 +45,7 @@ class Noalyss_Parameter_Folder
var $MY_ALPHANUM;
var $MY_UPDLAB;
var $MY_STOCK;
var $MY_ANC_FILTER;
// constructor
function __construct($p_cn)
@ -61,14 +62,51 @@ class Noalyss_Parameter_Folder
}
}
function check(&$p_value)
function check_anc_filter($p_value)
{
if ($p_value == 'MY_STRICT'
&& $this->MY_STRICT != 'Y'
&& $this->MY_STRICT != 'N')
$p_value='N';
$p_value=htmlspecialchars($p_value);
$tmp_value=$p_value;
$tmp_value=preg_replace("/[0-9]|,/", '', $p_value);
if ( $tmp_value != "") {
throw new Exception (sprintf(_("Valeur invalide %s"),$tmp_value),1000);
}
if (trim($p_value) == "") {
throw new Exception (sprintf(_("Erreur Filtre analytique %s"),$tmp_value),1001);
}
}
function check($p_attr, $p_value)
{
$ret_value=$p_value;
switch ($p_attr)
{
case 'MY_STRICT':
if (empty(trim($p_value)) ||($p_value!='Y'&&$p_value!='N'))
{
$ret_value='N';
}
break;
case 'MY_ANC_FILTER':
try
{
$p_value=str_replace(" ", "", $p_value);
$this->check_anc_filter($p_value);
$ret_value=$p_value;
}
catch (Exception $exc)
{
throw $exc;
}
break;
default :
$ret_value=htmlspecialchars($p_value);
}
return $ret_value;
}
/*!
**************************************************
* \brief save the parameter into the database by inserting or updating
@ -79,20 +117,24 @@ class Noalyss_Parameter_Folder
*/
function save($p_attr)
{
$this->check($p_attr);
$value=$this->$p_attr;
// check if the parameter does exist
if ( $this->db->get_value('select count(*) from parameter where pr_id=$1',array($p_attr)) != 0 )
{
$Res=$this->db->exec_sql("update parameter set pr_value=$1 where pr_id=$2",
array($value,$p_attr));
}
else
{
try {
$value=$this->check($p_attr,$this->$p_attr);
$Res=$this->db->exec_sql("insert into parameter (pr_id,pr_value) values( $1,$2)",
array($p_attr,$value));
// check if the parameter does exist
if ( $this->db->get_value('select count(*) from parameter where pr_id=$1',array($p_attr)) != 0 )
{
$Res=$this->db->exec_sql("update parameter set pr_value=$1 where pr_id=$2",
array($value,$p_attr));
}
else
{
$Res=$this->db->exec_sql("insert into parameter (pr_id,pr_value) values( $1,$2)",
array($p_attr,$value));
}
} catch (Exception $e) {
throw $e;
}
}
@ -124,8 +166,19 @@ class Noalyss_Parameter_Folder
$this->save('MY_ALPHANUM');
$this->save('MY_UPDLAB');
$this->save('MY_STOCK');
$this->save("MY_ANC_FILTER");
}
/**
* Check if an accounting match the anc_filter
* @param string $p_accounting
* @return boolean FALSE does not match , TRUE matches
*/
function match_analytic($p_accounting)
{
$string="/^[".$this->MY_ANC_FILTER."]+/";
if ( preg_match($string,$p_accounting) == 0 ) return FALSE;
return TRUE;
}
}

View file

@ -26,6 +26,7 @@
* @see ajax_payment_method.php
*/
require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
require_once NOALYSS_INCLUDE."/database/jrn_def_sql.class.php";
class Payment_Method_MTable extends Manage_Table_SQL
{
@ -92,11 +93,15 @@ class Payment_Method_MTable extends Manage_Table_SQL
$this->set_error("mp_lib", _("Un libellé est obligatoire"));
$has_error++;
}
if (trim ($table->mp_qcode) != "" && $a_row['jrn_def_type'] != 'FIN') {
$fiche=new Fiche($cn);
if ( $fiche->get_by_qcode($table->mp_qcode,FALSE) == 1) {
$this->set_error("mp_qcode",_("Fiche inexistante"));
$has_error++;
if (trim ($table->mp_qcode) != "") {
$ledger=new Jrn_def_SQL($cn , $table->jrn_def_id);
if ( $ledger->get('jrn_def_type') == 'FIN'){
$fiche=new Fiche($cn);
if ( $fiche->get_by_qcode($table->mp_qcode,FALSE) == 1) {
$this->set_error("mp_qcode",_("Fiche inexistante"));
$has_error++;
}
}
}
// get the type of the ledger

View file

@ -134,10 +134,9 @@ class Template_Card_Category extends Manage_Table_SQL
if (!in_array($a_attribut[$i]['ad_id'], [ATTR_DEF_NAME, ATTR_DEF_QUICKCODE])&&$used==0)
{
// allow to remove attribute
$js=sprintf("onclick=\"category_card.remove_attribut('%s','%s','%s',%d)\"",
$js=sprintf("category_card.remove_attribut('%s','%s','%s',%d)",
Dossier::id(), $this->table->frd_id, $objname, $a_attribut[$i]['ad_id']);
echo HtmlInput::anchor(SMALLX, "", $js,
' class="smallbutton" style="padding:0px;display:inline" ');
echo Icon_Action::trash(uniqid(), $js);
}
echo '</li>';
}
@ -159,9 +158,7 @@ class Template_Card_Category extends Manage_Table_SQL
echo $sel_attribut->input();
$js_script=sprintf("category_card.add_attribut('%s','%s','%s')",
$dossier_id, $this->table->frd_id, $objname);
echo HtmlInput::button_image($js_script, uniqid(),
'class="smallbutton image_search"',
"image/bouton-plus.png");
echo Icon_Action::icon_add(uniqid(), $js_script);
}
}
}

View file

@ -48,8 +48,12 @@ if (isset($_POST['record_company']))
$m->MY_ALPHANUM = $http->post("p_alphanum");
$m->MY_UPDLAB = $http->post("p_updlab");
$m->MY_STOCK =$http->post("p_stock");
$m->Update();
$m->MY_ANC_FILTER=$http->post("p_anc_filter");
try {
$m->Update();
} catch (Exception $e) {
alert($e->getMessage());
}
}
$my = new Noalyss_Parameter_Folder($cn);
@ -111,6 +115,10 @@ $stock->value = array(
$stock->selected = $my->MY_STOCK;
$stock->table = 1;
$anc_filter=new IText("p_anc_filter", $my->MY_ANC_FILTER);
$anc_filter->placeholder='6,7';
$anc_filter->title=_("Uniquement des chiffres séparés par des virgules");
// other parameters
$all = new IText();
$all->table = 1;
@ -135,6 +143,12 @@ echo "<tr>" . td(_("Pays"), 'style="text-align:right"') . $all->input("p_pays",
$all->value = '';
echo "<tr>" . td(_("Numéro de Tva"), 'style="text-align:right"') . $all->input("p_tva", $my->MY_TVA) . "</tr>";
echo "<tr>" . td(_("Utilisation de la compta. analytique"), 'style="text-align:right"') . $compta->input("p_compta", $array) . "</tr>";
echo '<tr>'. td(_("Opération analytique uniquement pour les postes comptables commençant par")).
'<td>'.
$anc_filter->input().
Icon_Action::tips($anc_filter->title);
'</td>'.
'</tr>';
echo "<tr>" . td(_("Utilisation des stocks"), 'style="text-align:right"') . $stock->input() . "</tr>";
echo "<tr>" . td(_("Utilisation du mode strict "), 'style="text-align:right"') . $strict->input("p_strict", $strict_array) . "</tr>";

View file

@ -68,7 +68,6 @@ if (isset($_POST['view_invoice']))
echo '<div class="content">';
echo '<div id="confirm_div_id" style="width: 47%; float: left;">';
echo h1(_("Confirmation"));
echo h1(_("Confirmation"));
echo span(_("Vous devez encore confirmer"),' class="notice"');
echo '</div>';
@ -312,4 +311,4 @@ echo '</div>';
return;
// end record invoice
?>
?>

View file

@ -108,7 +108,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
if ( ! defined ("SYSINFO_DISPLAY")) {
define ("SYSINFO_DISPLAY",TRUE);
}
define ("DBVERSION",137);
define ("DBVERSION",138);
define ("MONO_DATABASE",25);
define ("DBVERSIONREPO",18);
define ('NOTFOUND','--not found--');

View file

@ -110,6 +110,11 @@ $max_line = $cn->count_sql($sql);
$step = $_SESSION['g_pagesize'];
$page = (isset($_GET['offset'])) ? $_GET['page'] : 1;
$offset = (isset($_GET['offset'])) ? $_GET['offset'] : 0;
// check if number
$page=(isNumber($page)==0)?1:$page;
$offset=(isNumber($offset)==0)?0:$offset;
$bar = navigation_bar($offset, $max_line, $step, $page);
echo $msg;
@ -142,13 +147,16 @@ $r = HtmlInput::get_to_hidden(array('search_opnb_jrn',
'search_opr_jrn'));
if (isset($_GET['r_jrn']))
{
foreach ($_GET['r_jrn'] as $k => $v)
$r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v);
$a_rjn=$http->get('r_jrn','array');
foreach ($a_rjn as $k => $v) {
if (isNumber($v)) $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v);
}
}
if (isset($_GET['search_opr_jrn']))
{
foreach ($_GET['search_opr_jrn'] as $k => $v)
$r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v);
$a_search_opr_jrn=$http->get('search_opr_jrn','array');
foreach ($a_search_opr_jrn as $k => $v)
if (isNumber($v)) $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v);
}
echo $r;
@ -164,13 +172,13 @@ $r = HtmlInput::get_to_hidden(array('l', 'date_paid_start','date_paid_end',
'accounting', 'unpaid', 'gDossier', 'ledger_type', 'p_action'));
if (isset($_GET['search_opr_jrn']))
{
foreach ($_GET['search_opr_jrn'] as $k => $v)
$r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v);
foreach ($a_search_opr_jrn as $k => $v)
if (isNumber($v)) $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v);
}
if (isset($_GET['r_jrn']))
{
foreach ($_GET['r_jrn'] as $k => $v)
$r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v);
foreach ($a_rjn as $k => $v)
if (isNumber($v)) $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v);
}
echo '<form action="export.php" method="get">';
echo $r;

View file

@ -42,12 +42,41 @@
* After you call the parent constructor
* @note the view or the table must include an unique key, otherwise the load
* doesn't work.
*
* @pnote
* Name is an array the key is the logical name and the value is the name of the column
@code
$this->name=array(
"id"=>"o_id",
"program"=>"o_prog",
"date"=>"o_date",
"qcode"=>"o_qcode",
"fiche"=>"f_id",
);
@endcode
*
the type is an array , key = column name , value = type
* @code
$this->type = array(
"o_id"=>"numeric",
"o_prog"=>"numeric",
"o_date"=>"date",
"o_qcode"=>"text",
"f_id"=>"numeric",
);
@endcode
*
*/
abstract class Data_SQL
{
function __construct($p_cn, $p_id=-1)
private $cn; //! Database connection
var $name; //! Array of logical and real name
var $primary_key; //! Column name of the primary key
var $type; //! Type of the data
var $date_format; //! defaullt date format
function __construct(DatabaseCore $p_cn, $p_id=-1)
{
$this->cn=$p_cn;
$pk=$this->primary_key;
@ -64,6 +93,7 @@ abstract class Data_SQL
$this->$pk=$p_id;
/* load it */
if ($p_id != -1 )$this->load();
if ( empty($this->date_format) ) $this->date_format="DD.MM.YYYY";
}
/**
* Insert or update : if the row already exists, update otherwise insert
@ -263,6 +293,63 @@ abstract class Data_SQL
* @return integer 0 doesn't exist , 1 exists
*/
abstract function exist() ;
public function get_cn()
{
return $this->cn;
}
public function get_name()
{
return $this->name;
}
public function get_primary_key()
{
return $this->primary_key;
}
public function get_type()
{
return $this->type;
}
public function set_cn($cn)
{
$this->cn=$cn;
return $this;
}
/**
*
* @param string $name
* @return $this
*/
public function set_name($name)
{
$this->name=$name;
return $this;
}
/**
*
* @param string $primary_key
* @return $this
*/
public function set_primary_key($primary_key)
{
$this->primary_key=$primary_key;
return $this;
}
/**
*
* @param array $type
* @return $this
*/
public function set_type($type)
{
$this->type=$type;
return $this;
}
}
?>

View file

@ -946,6 +946,14 @@ class DatabaseCore
$csv->write();
}
}
/**
* Returns the number of columns in a ret
* @param handler $p_ret handler to a query
*/
static function nb_column($p_ret) {
return pg_num_fields($p_ret);
}
}
/* test::test_me(); */

View file

@ -96,13 +96,31 @@ class Icon_Action
*/
static function tips($p_comment)
{
$p_comment=htmlentities($p_comment);
$p_comment=str_replace("'",' ',$p_comment);
$r='<span tabindex="-1" class="icon" style="cursor:pointer;display:inline;text-decoration:none;" onmouseover="displayBulle(\''.$p_comment.'\')" onclick="displayBulle(\''.$p_comment.'\')" onmouseout="hideBulle(0)">';
$r.="&#xf086;";
$r.='</span>';
return $r;
}
/**
* Display a info in a bubble, text is given as parameter
* @param string $p_comment
*
* @return html string
*/
static function comment($p_comment)
{
$p_comment=str_replace("'",' ',$p_comment);
$js=sprintf("displayBulle('%s')",$p_comment);
$r=sprintf('<span tabindex="-1" class="icon" style="cursor:pointer;display:inline;text-decoration:none;" onmouseover="%s" onclick="%s" onmouseout="hideBulle(0)">',
$js,$js);
$r.="&#xf0e5;";
$r.='</span>';
return $r;
}
/**
* Display a icon ON
* @param string $p_div id of element
@ -177,7 +195,7 @@ class Icon_Action
*/
static function warnbulle($p_comment)
{
$r=sprintf('<span tabindex="-1" onmouseover="showBulle(\'%s\')" onclick="showBulle(\'%s\')" onmouseout="hideBulle(0)" style="color:red" class="icon">&#xe818;</span>',
$r=sprintf('<span tabindex="-1" onmouseover="showBulle(\'%s\')" onclick="showBulle(\'%s\')" onmouseout="hideBulle(0)" style="color:red" class="icon">&#xe80e;</span>',
$p_comment, $p_comment);
return $r;
@ -307,4 +325,21 @@ class Icon_Action
$lock_cur);
return $r;
}
/**
* Display the icon of a slider
* @param string $p_id DOMid
* @param string $p_javascript
* @return htmlString
*/
static function slider($p_id,$p_javascript)
{
$lock_cur="&#xf1de;";
$r=sprintf( '<span id="%s" onclick="%s" class="icon smallicon">%s</span>',
$p_id,
$p_javascript,
$lock_cur);
return $r;
}
}

View file

@ -87,6 +87,7 @@ require NOALYSS_INCLUDE."/lib/data_sql.class.php";
abstract class Noalyss_SQL extends Data_SQL
{
var $default;
function __construct(&$p_cn, $p_id=-1)
{
$this->cn=$p_cn;
@ -104,6 +105,7 @@ abstract class Noalyss_SQL extends Data_SQL
$this->$pk=$p_id;
/* load it */
if ($p_id != -1 )$this->load();
}
/**
* Insert or update : if the row already exists, update otherwise insert
@ -255,23 +257,8 @@ abstract class Noalyss_SQL extends Data_SQL
public function load()
{
$sql=" select ";
$sep="";
foreach ($this->name as $key) {
switch ($this->type[$key])
{
case "date":
$sql .= $sep.'to_char('.$key.",'".$this->date_format."') as ".$key;
break;
default:
$sql.=$sep.$key;
}
$sep=",";
}
$sql=$this->build_query();
$pk=$this->primary_key;
$sql.=" from ".$this->table;
$sql.=" where ".$this->primary_key." = $1";
$result=$this->cn->get_array($sql,array ($this->$pk));
if ($this->cn->count()==0)
@ -412,6 +399,33 @@ abstract class Noalyss_SQL extends Data_SQL
$count=$this->cn->get_value("select count(*) from ".$this->table." where ".$this->primary_key."=$1",array($this->$pk));
return $count;
}
/**
* Build the SQL select statement for querying the object and returns it
* @return string Query of the object
*/
public function build_query()
{
$sql=" select ";
$sep="";
foreach ($this->name as $key) {
switch ($this->type[$key])
{
case "date":
$sql .= $sep.'to_char('.$key.",'".$this->date_format."') as ".$key;
break;
default:
$sql.=$sep.$key;
}
$sep=",";
}
$pk=$this->primary_key;
$sql.=" from ".$this->table;
$sql.=" where ".$this->primary_key." = $1";
return $sql;
}
}
?>

View file

@ -58,7 +58,7 @@ class PDF_Core extends TFPDF
public function __construct ( $orientation = 'P', $unit = 'mm', $format = 'A4')
{
$this->bigger=0;
$this->bigger=0;
parent::__construct($orientation, $unit, $format);
$this->AddFont('DejaVu','','DejaVuSans.ttf',true);
@ -68,12 +68,39 @@ class PDF_Core extends TFPDF
$this->AddFont('DejaVuCond','B','DejaVuSansCondensed-Bold.ttf',true);
$this->AddFont('DejaVuCond','I','DejaVuSansCondensed-Oblique.ttf',true);
$this->cells=array();
}
function get_margin_left()
{
return $this->lMargin;
}
function get_margin_bottom()
{
return $this->bMargin;
}
function get_margin_top()
{
return $this->tMargin;
}
function get_margin_right()
{
return $this->rMargin;
}
function get_orientation()
{
return $this->DefOrientation;
}
function get_unit()
{
return $this->k;
}
function get_page_size()
{
return $this->DefPageSize;
}
/**
* Count the number of rows a p_text will take for a multicell
* @param $p_text String

View file

@ -0,0 +1,6 @@
begin;
insert into "parameter" (pr_id,pr_value) values ('MY_ANC_FILTER','6,7');
insert into version (val,v_description) values (138,'Analytic improve');
commit ;

View file

@ -23,15 +23,15 @@
<TD colspan='2'> <INPUT TYPE="CHECKBOX" NAME="create" CHECKED><?php echo _("Création automatique du poste comptable uniquement s'il n'y a qu'un seul poste")?></TD>
</TR>
</table>
<h2>Modèles de catégorie</h2>
<h2><?php echo _("Modèles de catégorie")?></h2>
<ul>
<?php
if ( sizeof($ref) ) {
if ( !empty ($ref) ) {
foreach ($ref as $i=>$v) { ?>
<li style="list-style-type: none">
<?php echo $iradio->input("FICHE_REF",$v['frd_id']);
echo $v['frd_text'];
if ( sizeof ($v['frd_class_base']) != 0 )
if ( !empty ($v['frd_class_base']) != 0 )
echo "&nbsp;&nbsp<I>Class base = ".$v['frd_class_base']."</I>";
}?>

View file

@ -225,7 +225,7 @@ $str_anc="";
if ($owner->MY_ANALYTIC != "nu" /*&& $div == 'popup'*/ )
{
$poste = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
if (preg_match('/^(6|7)/', $poste))
if ( $g_parameter->match_analytic($poste))
{
$anc_op = new Anc_Operation($cn);
$anc_op->j_id = $q['j_id'];

View file

@ -323,7 +323,7 @@ if ( $div != 'popup' ) {
{
$remove=new IButton('Effacer');
$remove->label=_('Effacer');
$remove->javascript="return confirm_box(null,'Vous confirmez effacement ?',function () {removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')})";
$remove->javascript="return confirm_box(null,content[50],function () {removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')})";
echo $remove->input();
}
//----------------------------------------------------
@ -359,7 +359,7 @@ echo '</form>';
$r.='<p style="text-align:center">';
$r.=HtmlInput::submit('x','accepter',
'onclick="confirm_box($(\'form_'.$div.'\'),\'Vous confirmez ? \',function () {$(\'form_'.$div.'\').divname=\''.$div.'\';reverseOperation($(\'form_'.$div.'\'))}); return false"');
'onclick="confirm_box($(\'form_'.$div.'\'),content[50],function () {$(\'form_'.$div.'\').divname=\''.$div.'\';reverseOperation($(\'form_'.$div.'\'))}); return false"');
$r.="</p>";
$r.='</form>';
echo $r;

View file

@ -118,7 +118,7 @@ echo td(_('Pièce')).td($itext->input());
if ( $owner->MY_ANALYTIC != "nu" /*&& $div == 'popup'*/)
{
$poste=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
if ( preg_match('/^(6|7)/',$q[$e]['j_poste']))
if ( $g_parameter->match_analytic($q[$e]['j_poste']))
{
$qcode=$fiche->strAttribut(ATTR_DEF_QUICKCODE);
$anc_op=new Anc_Operation($cn);

View file

@ -161,7 +161,7 @@ $amount_idx=0;
$row.=($q[$e]['j_debit']=='f')?$montant:td('');
/* Analytic accountancy */
if ( $owner->MY_ANALYTIC != "nu" /*&& $div=='popup'*/){
if ( preg_match('/^(6|7)/',$q[$e]['j_poste'])) {
if ( $g_parameter->match_analytic($q[$e]['j_poste'])) {
echo HtmlInput::hidden("amount_t".$amount_idx,$q[$e]['j_montant']);
$anc_op=new Anc_Operation($cn);

View file

@ -223,7 +223,7 @@ echo $ipaid->input();
if ($owner->MY_ANALYTIC != "nu" /*&& $div == 'popup' */ )
{
$poste = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
if (preg_match('/^(6|7)/', $poste))
if ( $g_parameter->match_analytic($poste))
{
$anc_op = new Anc_Operation($cn);
$anc_op->in_div=$div;

View file

@ -50,7 +50,7 @@ $class= ( ($i % 2) == 0 ) ? "odd":"even";
<tr <?php echo "class=\"$class\""; ?> >
<td>
<?php
$letter=($this->content[$i]['letter']==-1)?" aucun lettrage ":strtoupper(base_convert($this->content[$i]['letter'],10,36));
$letter=($this->content[$i]['letter']==-1)?_("aucun lettrage"):strtoupper(base_convert($this->content[$i]['letter'],10,36));
$js="this.gDossier=".dossier::id().
";this.j_id=".$this->content[$i]['j_id'].
";this.obj_type='".$this->object_type."'".

View file

@ -77,4 +77,10 @@ include_once NOALYSS_INCLUDE."/lib/icon_action.class.php";
</p>
<p>
Tips <?php echo Icon_Action::tips("Allo ?")?>
</p>
<p>
Slider <?php echo Icon_Action::slider(uniqid(), "alert('test')")?>
</p>
<p>
Comment<?php echo Icon_Action::comment("Allo ? l'heure d'été ?")?>
</p>

View file

@ -0,0 +1,183 @@
<?php
/*
* This file is part of NOALYSS.
*
* PhpCompta 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.
*
* PhpCompta 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 PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
use PHPUnit\Framework\TestCase;
function trim_parameter($p_value){
return;
}
/**
* Generated by PHPUnit_SkeletonGenerator on 2017-11-26 at 11:24:04.
*/
class Noalyss_Parameter_FolderTest extends TestCase
{
protected $object;
private $a_param;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
*/
protected function setUp()
{
global $g_connection, $g_user;
$_REQUEST['gDossier']=DOSSIER;
$g_connection=new Database(DOSSIER);
$g_user=new User($g_connection);
$this->object=new Noalyss_Parameter_Folder($g_connection);
$this->a_param=explode(",","MY_COUNTRY,".
"MY_DEFAULT_ROUND_ERROR_DEB,".
"MY_DEFAULT_ROUND_ERROR_CRED,".
"MY_ANC_FILTER,".
"MY_NAME,".
"MY_TVA,".
"MY_STREET,".
"MY_NUMBER,".
"MY_CP,".
"MY_TEL,".
"MY_PAYS,".
"MY_COMMUNE,".
"MY_FAX,".
"MY_ANALYTIC,".
"MY_STRICT,".
"MY_TVA_USE,".
"MY_PJ_SUGGEST,".
"MY_CHECK_PERIODE,".
"MY_DATE_SUGGEST,".
"MY_ALPHANUM,".
"MY_UPDLAB,".
"MY_STOCK");
}
public function testNew()
{
global $g_connection ;
$nb_param=count($this->a_param);
$cnt=$g_connection->get_value("select count(*) from parameter where pr_id like 'MY_%'");
$this->assertEquals($nb_param,$cnt,"Number of parameters");
}
/*
* @covers Noalyss_Parameter_Folder::checkTest
*
*/
public function testcheck()
{
$a=$this->object->check('MY_STRICT', 0);
$this->assertEquals($a,"N");
}
/*
* @covers Noalyss_Parameter_Folder::checkTest
*
*/
public function testcheck_anc_filter()
{
try {
$this->object->check_anc_filter('6,7');
$this->assertTrue(TRUE);
} catch (Exception $ex) {
$this->assertTrue(FALSE,'6,7 is valid');
}
try {
$this->object->check_anc_filter('6,7,8,2');
$this->assertTrue(TRUE);
} catch (Exception $ex) {
$this->assertTrue(FALSE,'6,7,8,2 is valid');
}
try {
$this->object->check_anc_filter('6,7,8,2,AA');
$this->assertTrue(FALSE);
} catch (Exception $ex) {
$this->assertTrue(TRUE,'6,7,8,2 is not valid');
}
}
/*
* @covers Noalyss_Parameter_Folder::checkTest
*
*/
public function testupdate()
{
$ok=0;
try {
$this->testsave();
} catch (Exception $e)
{
$ok=1;
}
$this->assertEquals($ok,0);
}
/*
* @covers Noalyss_Parameter_Folder::checkTest
*
*/
public function testsave()
{
global $g_connection;
for ($e =0;$e < count($this->a_param);$e++)
{
$attr=$this->a_param[$e];
$old=$this->object->$attr;
switch ($attr)
{
case "MY_STRICT":
$this->object->$attr='Y';
break;
case "MY_COUNTRY":
$this->object->MY_COUNTRY='XBE';
break;
case "MY_ANC_FILTER":
$this->object->MY_ANC_FILTER='5,4';
break;
default:
$this->object->$attr='000';
break;
}
$this->object->save($this->a_param[$e]);
$cur_value=$g_connection->get_value('select pr_value from "parameter" where pr_id=$1',[$attr]);
$this->assertTrue(($cur_value==$this->object->$attr),sprintf("failed : %s cur_value %s expected %s",$attr,$cur_value,$this->object->$attr));
$this->assertTrue($cur_value != $old,sprintf( "failed : %s cur_value %s old %s",$attr,$cur_value,$old));
$this->object->$attr=$old;
$this->object->save($this->a_param[$e]);
$cur_value=$g_connection->get_value('select pr_value from "parameter" where pr_id=$1',[$attr]);
$this->assertTrue($cur_value == $old,sprintf( "failed : %s cur_value %s old %s",$attr,$cur_value,$old));
}
}
function testMatch_accounting()
{
$this->assertTrue($this->object->match_analytic("612"));
$this->assertTrue($this->object->match_analytic("6"));
$this->assertTrue($this->object->match_analytic("66"));
$this->assertTrue($this->object->match_analytic("71"));
$this->assertTrue($this->object->match_analytic("7"));
$this->assertFalse($this->object->match_analytic("5"));
}
}
?>