From 0288ed13dca9cfc630c7ebeeacd053577203ebbd Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 28 Apr 2021 10:44:47 +0200 Subject: [PATCH] Cosmetic : position of "invoice, template , ..." after saving an operation --- html/css/style-classic7.css | 8 ++-- include/class/acc_ledger.class.php | 63 ++++++++++++++++++++++---- include/class/acc_ledger_fin.class.php | 9 +++- include/compta_ach.inc.php | 2 +- include/compta_fin.inc.php | 3 +- include/compta_ven.inc.php | 8 ++-- include/operation_ods_confirm.inc.php | 2 +- 7 files changed, 76 insertions(+), 19 deletions(-) diff --git a/html/css/style-classic7.css b/html/css/style-classic7.css index 691fee598..d5ce1438c 100644 --- a/html/css/style-classic7.css +++ b/html/css/style-classic7.css @@ -2474,6 +2474,10 @@ span.warning { /* LI as list * Tabs like row ****************************************************************************/ + #tab_id { + margin-bottom: 30px; + position:static; + } ul.tab_row { padding-top: 25px; display:block; @@ -2890,7 +2894,3 @@ span.tagcell { .content .h3, .content h3 { font-size: 1.4rem; } - -#facturation_div_id { - margin-top:2rem; -} diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index d22da1eed..07453dbc0 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -62,27 +62,47 @@ require_once NOALYSS_INCLUDE.'/class/html_input_noalyss.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 $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 */ + protected $is_loaded ; + + /** * @param $p_cn database connexion * @param $p_id jrn.jrn_def_id */ function __construct($p_cn, $p_id) { + parent::__construct($p_cn, $p_id); $this->id=$p_id; $this->ledger_name=&$this->jrn_def_name; $this->jrn_def_id=&$this->id; $this->db=$p_cn; $this->row=null; $this->nb=MAX_ARTICLE; - if ($p_id <> 0 ) parent::__construct($p_cn, $p_id); + $this->is_loaded=false; + + if ($p_id <> 0 ) { + + $this->is_loaded=true; + } } - /** + public function get_is_loaded() + { + return $this->is_loaded; + } + + public function set_is_loaded($is_loaded): void + { + $this->is_loaded=$is_loaded; + } + + /** * retrieve currency_id from database */ function set_currency_id() @@ -98,7 +118,6 @@ class Acc_Ledger extends jrn_def_sql if (isNumber($this->id)==0) { throw new Exception(_("Paramètre invalide")); - return; } if ($this->db->exist_sequence("s_jrn_pj".$this->id)) { @@ -113,7 +132,9 @@ class Acc_Ledger extends jrn_def_sql return $last; } else + { $this->db->create_sequence("s_jrn_pj".$this->id); + } return 0; } /** @@ -175,11 +196,15 @@ class Acc_Ledger extends jrn_def_sql function delete() { if ($this->id==0) + { return; + } $grpt_id=$this->db->get_value('select jr_grpt_id from jrn where jr_id=$1', array($this->jr_id)); if ($this->db->count()==0) + { return; + } $this->db->exec_sql('delete from jrnx where j_grpt=$1', array($grpt_id)); $this->db->exec_sql('delete from jrn where jr_id=$1', array($this->jr_id)); @@ -228,11 +253,15 @@ class Acc_Ledger extends jrn_def_sql { $this->db->start(); if (!isset($this->jr_id)||$this->jr_id=='') + { throw new Exception(_("this->jr_id is not set ou opération inconnue")); + } /* check if the date is valid */ if (isDate($p_date)==null) + { throw new Exception(_('Date invalide').$p_date); + } // if the operation is in a closed or centralized period // the operation is voided thanks the opposite operation @@ -254,7 +283,9 @@ class Acc_Ledger extends jrn_def_sql $per->find_periode($p_date); if ($per->is_open()==0) + { throw new Exception(_('PERIODE FERMEE')); + } @@ -272,7 +303,9 @@ class Acc_Ledger extends jrn_def_sql // Check return code if ($Res==false) + { throw new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"); + } ////////////////////////////////////////////////// // Reverse in jrnx* tables @@ -297,7 +330,9 @@ class Acc_Ledger extends jrn_def_sql $row)); // Check return code if ($Res==false) + { throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]")); + } $aj_id=$this->db->fetch(0); $j_id=$aj_id['j_id']; @@ -315,7 +350,9 @@ class Acc_Ledger extends jrn_def_sql array($p_internal, $j_id, $row)); if ($Res==false) + { throw new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"); + } $Res=$this->db->exec_sql("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, @@ -327,7 +364,9 @@ class Acc_Ledger extends jrn_def_sql array($p_internal, $j_id, $row)); if ($Res==false) + { throw new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]"); + } } $sql="insert into jrn ( jr_id, @@ -354,7 +393,9 @@ class Acc_Ledger extends jrn_def_sql array($seq, $p_date, $grp_new, $p_internal, $per->p_id, $this->jr_id,$p_label)); // Check return code if ($Res==false) + { 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,j_id) @@ -362,7 +403,9 @@ class Acc_Ledger extends jrn_def_sql FROM quant_fin where jr_id=$2", array($seq, $this->jr_id,$j_id)); if ($Res==false) + { throw (new Exception(__FILE__.__LINE__."SQL ERROR[ $sql ]")); + } // Add a "concerned operation to bound these op.together // @@ -384,7 +427,9 @@ class Acc_Ledger extends jrn_def_sql from stock_goods natural join jrnx where j_grpt=".$this->jr_grpt_id.")"; $Res=$this->db->exec_sql($sql); if ($Res==false) + { throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]")); + } $this->db->commit(); } catch (Exception $e) @@ -411,7 +456,9 @@ class Acc_Ledger extends jrn_def_sql " jrn_def where jrn_def_id=$1", array($this->id)); $Max=Database::num_row($Res); if ($Max==0) + { return null; + } $ret=Database::fetch_array($Res, 0); $this->ledger_name=$ret['jrn_def_name']; return $ret['jrn_def_name']; diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index ab8fb04f9..8ee6a25c7 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -460,6 +460,9 @@ class Acc_Ledger_Fin extends Acc_Ledger { global $g_parameter, $g_user; $r=""; + if ( ! $this->get_is_loaded()) { + $this->load(); + } bcscale(2); extract($p_array, EXTR_SKIP); $pPeriode=new Periode($this->db); @@ -744,6 +747,10 @@ class Acc_Ledger_Fin extends Acc_Ledger public function insert($p_array=null) { global $g_parameter; + + if ( ! $this->get_is_loaded()) { + $this->load(); + } bcscale(2); $internal_code=""; $oid=0; @@ -792,7 +799,6 @@ class Acc_Ledger_Fin extends Acc_Ledger - try { $this->db->start(); @@ -813,6 +819,7 @@ class Acc_Ledger_Fin extends Acc_Ledger } if (DEBUGNOALYSS>1) { + printf("

currency_id %s

",$this->currency_id); printf("

rate %s

", $currency_rate); } // for each item diff --git a/include/compta_ach.inc.php b/include/compta_ach.inc.php index d02c09736..a7e902c69 100644 --- a/include/compta_ach.inc.php +++ b/include/compta_ach.inc.php @@ -88,6 +88,7 @@ if (isset($_POST['view_invoice']))
  • " onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'modele_div_id')">
  • " onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'reverse_div_id')">
  • + select_depot(false, -1); echo $Ledger->extra_info(); @@ -120,7 +121,6 @@ if (isset($_POST['view_invoice'])) show_tabs(a_tab,'facturation_div_id'); '; return; } } diff --git a/include/compta_fin.inc.php b/include/compta_fin.inc.php index 01f2e4750..419aac188 100644 --- a/include/compta_fin.inc.php +++ b/include/compta_fin.inc.php @@ -60,7 +60,8 @@ if ( $jrn_priv == 'X') NoAccess(); exit -1; } -$Ledger->set_currency_id(); + +$Ledger->load(); $p_msg=""; //---------------------------------------- diff --git a/include/compta_ven.inc.php b/include/compta_ven.inc.php index bbb76ed45..56f95aeae 100644 --- a/include/compta_ven.inc.php +++ b/include/compta_ven.inc.php @@ -96,7 +96,7 @@ $p_msg="";
  • " onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'modele_div_id')">
  • " onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'reverse_div_id')">
  • - + select_depot(false, -1); echo $Ledger->extra_info(); @@ -129,7 +129,6 @@ $p_msg=""; show_tabs(a_tab,'facturation_div_id'); '; return; } } @@ -262,7 +261,10 @@ if (isset($_REQUEST['p_jrn_predef'])) echo '
    '; -if ( $p_msg !="" ) echo ''.$p_msg.''; +if ($p_msg!="") +{ + echo ''.$p_msg.''; +} try { $payment=$http->request("e_mp","string", 0); diff --git a/include/operation_ods_confirm.inc.php b/include/operation_ods_confirm.inc.php index 34f3ba174..1bc569e74 100644 --- a/include/operation_ods_confirm.inc.php +++ b/include/operation_ods_confirm.inc.php @@ -54,7 +54,7 @@ echo $ledger->confirm($_POST,false);
  • " onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'operationtype_div_id')">
  • -
    +