diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index c4d89c5e3..e111760f4 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -133,7 +133,7 @@ $html = var_export($_REQUEST, true);
set_language();
if ( LOGINPUT)
{
- $file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
+ $file_loginput=fopen($_ENV['TMP'].'/scenario-ajax-'.$_SERVER['REQUEST_TIME'].'.php','a+');
fwrite ($file_loginput,"db->start();
@@ -282,6 +283,8 @@ class Acc_Ledger extends jrn_def_sql
//////////////////////////////////////////////////
$a_jid=$this->db->get_array("select j_id,j_debit from jrnx where j_grpt=$1",
array($this->jr_grpt_id));
+ $anc_group_id=0;
+ // for each item in JRNX
for ($l=0; $lMY_ANALYTIC != 'nu') {
+ // if there is the first operation_analytic to insert , compute the group_id (operation_analytic.oa_group)
+ if ($anc_group_id == 0 ) $anc_group_id=$this->db->get_next_seq('s_oa_group');
+ $this->db->exec_sql("
+ insert into operation_analytique (po_id,oa_amount
+ ,oa_description
+ ,oa_debit
+ ,j_id
+ , oa_date
+ , oa_row
+ , oa_positive
+ , f_id
+ ,oa_jrnx_id_source
+ ,oa_group)
+ select po_id
+ ,oa_amount
+ ,oa_description
+ ,case oa_debit when true then false else true end
+ , $j_id
+ , to_date($2,'DD.MM.YYYY')
+ , oa_row
+ , oa_positive
+ , f_id
+ ,oa_jrnx_id_source
+ ,$anc_group_id from operation_analytique
+ where
+ j_id=$1
+ ",[$row, $p_date]);
+
+ }
- }
+ } // end for each item in JRNX
$old_receipt=$this->db->get_row("select jr_pj_number,jr_def_id from jrn where jr_id=$1",[$this->jr_id]);
$sql="insert into jrn (
jr_id,
@@ -405,7 +439,7 @@ class Acc_Ledger extends jrn_def_sql
// Add a "concerned operation to bound these op.together
//
- $rec=new Acc_Reconciliation($this->db);
+ $rec=new Acc_Reconciliation($this->db);
$rec->set_jr_id($seq);
$rec->insert($this->jr_id);
@@ -415,17 +449,19 @@ class Acc_Ledger extends jrn_def_sql
throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]"));
}
-
-
// the table stock must updated
// also in the stock table
$sql="delete from stock_goods where sg_id = any ( select sg_id
- from stock_goods natural join jrnx where j_grpt=".$this->jr_grpt_id.")";
- $Res=$this->db->exec_sql($sql);
+ from stock_goods natural join jrnx where j_grpt=$1)";
+ $Res=$this->db->exec_sql($sql,array($this->jr_grpt_id));
if ($Res==false)
{
throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]"));
}
+ /**
+ * reverse also in analytic account;
+ */
+
$this->db->commit();
}
catch (Exception $e)
@@ -1259,7 +1295,11 @@ class Acc_Ledger extends jrn_def_sql
if (isset(${'qc_'.$i})&&trim(${'qc_'.$i})!="")
{
$f=new Fiche($this->db);
+ $f->get_by_qcode(${'qc_'.$i});
$f->quick_code=${'qc_'.$i};
+
+ if ($f->get_f_enable() == '0')
+ throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),${'qc_'.$i}), 50);
if ($f->belong_ledger($p_jrn) < 1 )
throw new Exception("La fiche quick_code = ".
$f->quick_code." n'est pas dans ce journal", 4);
@@ -2874,7 +2914,7 @@ class Acc_Ledger extends jrn_def_sql
}
/**
- * display screen to enter a new ledger
+ * @brief display FORM to enter parameters to create a new ledger.
*/
function input_new()
{
diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php
index de3a2ea72..808d625ed 100644
--- a/include/class/acc_ledger_fin.class.php
+++ b/include/class/acc_ledger_fin.class.php
@@ -133,6 +133,11 @@ class Acc_Ledger_Fin extends Acc_Ledger
{
if (noalyss_strlentrim(${'e_other'.$i})==0)
continue;
+ /* check if all card has a ATTR_DEF_ACCOUNT */
+ $fiche=new Fiche($this->db);
+ $fiche->get_by_qcode(${'e_other'.$i});
+ if ($fiche->get_f_enable() == '0')
+ throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),${'e_other'.$i}), 50);
/* check if amount are numeric and */
if (isNumber(${'e_other'.$i.'_amount'})==0)
throw new Exception('La fiche '.${'e_other'.$i}.'a un montant invalide ['.${'e_other'.$i.'_amount'}.']',
@@ -140,9 +145,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
/* compute the total */
$tot_amount+=round(${'e_other'.$i.'_amount'}, 2);
- /* check if all card has a ATTR_DEF_ACCOUNT */
- $fiche=new Fiche($this->db);
- $fiche->get_by_qcode(${'e_other'.$i});
+
if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT)==true)
throw new Exception('La fiche '.${'e_other'.$i}.'n\'a pas de poste comptable', 8);
diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php
index c5b36ca87..d9a5ff7af 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -111,10 +111,14 @@ class Acc_Ledger_Purchase extends Acc_Ledger
/* check the account */
$fiche=new Fiche($this->db);
$fiche->get_by_qcode($e_client);
+ if ($fiche->get_f_enable() == '0')
+ throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),$e_client), 50);
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception(_('La fiche ').$e_client._('n\'a pas de poste comptable'),8);
+
+
/* get the account and explode if necessary */
$sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
// if 2 accounts, take only the credit one for supplier
@@ -158,6 +162,13 @@ class Acc_Ledger_Purchase extends Acc_Ledger
for ($i=0;$i< $nb_item;$i++)
{
if ( noalyss_strlentrim(${'e_march'.$i})== 0) continue;
+
+ /* check if all card has a ATTR_DEF_ACCOUNT*/
+ $fiche=new Fiche($this->db);
+ $fiche->get_by_qcode(${'e_march'.$i});
+ if ($fiche->get_f_enable() == '0')
+ throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"), ${'e_march' . $i}), 50);
+
/* check if amount are numeric and */
if ( isNumber(${'e_march'.$i.'_price'}) == 0 )
throw new Exception(_('La fiche ').${'e_march'.$i}._('a un montant invalide').' ['.${'e_march'.$i}.']',6);
@@ -181,9 +192,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
throw new Exception(_(" La TVA ".$tva_rate->tva_label." utilise des postes comptables inexistants"));
}
- /* check if all card has a ATTR_DEF_ACCOUNT*/
- $fiche=new Fiche($this->db);
- $fiche->get_by_qcode(${'e_march'.$i});
+
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception(_('La fiche ').${'e_march'.$i}._('n\'a pas de poste comptable'),8);
@@ -1366,7 +1375,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$W1->label="";
$W1->name="e_march".$i;
$W1->value=$march;
- $W1->table=1;
+ $W1->table=0;
$W1->set_dblclick("fill_ipopcard(this);");
$W1->set_attribute('ipopup','ipopcard');
@@ -1803,27 +1812,32 @@ class Acc_Ledger_Purchase extends Acc_Ledger
EOF;
- if ($p_currency_code !=0) {
- $rate=_("Taux ");
-$r.=<<
- {$decalage}
-
EOF;
diff --git a/include/class/acc_ledger_sale.class.php b/include/class/acc_ledger_sale.class.php
index bde50793d..c567bd3f3 100644
--- a/include/class/acc_ledger_sale.class.php
+++ b/include/class/acc_ledger_sale.class.php
@@ -108,9 +108,15 @@ class Acc_Ledger_Sale extends Acc_Ledger {
$fiche = new Fiche($this->db);
$fiche->get_by_qcode($e_client);
+
+ if ($fiche->get_f_enable() == '0')
+ throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),$e_client), 50);
+
if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception(_('La fiche ') . $e_client . _('n\'a pas de poste comptable'), 8);
+
+
/* get the account and explode if necessary */
$sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
// if 2 accounts, take only the debit one for customer
@@ -142,14 +148,19 @@ class Acc_Ledger_Sale extends Acc_Ledger {
for ($i = 0; $i < $nb_item; $i++) {
if (! isset (${'e_march' . $i}) || noalyss_strlentrim(${'e_march' . $i}) == 0)
continue;
+ /* check if all card has a ATTR_DEF_ACCOUNT */
+ $fiche = new Fiche($this->db);
+ $fiche->get_by_qcode(${'e_march' . $i});
+ if ($fiche->get_f_enable() == '0')
+ throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"), ${'e_march' . $i}), 50);
+
+
/* check if amount are numeric and */
if (isNumber(${'e_march' . $i . '_price'}) == 0)
throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a un montant invalide [') . ${'e_march' . $i} . ']', 6);
if (isNumber(${'e_quant' . $i}) == 0)
throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a une quantité invalide [') . ${'e_quant' . $i} . ']', 7);
- /* check if all card has a ATTR_DEF_ACCOUNT */
- $fiche = new Fiche($this->db);
- $fiche->get_by_qcode(${'e_march' . $i});
+
if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('n\'a pas de poste comptable'), 8);
@@ -1064,9 +1075,9 @@ if ( $g_parameter->MY_TVA_USE=="Y") {
EOF;
- $sql_currency=new Currency_SQL($this->cn,$p_currency_code);
- $iso_code=$sql_currency->getp("cr_code_iso");
if ($p_currency_code !=0) {
+ $sql_currency=new Currency_SQL($this->cn,0);
+ $iso_code=$sql_currency->getp("cr_code_iso");
$r.=<<
@@ -1089,7 +1100,9 @@ EOF;
} else {
$sql_currency=new Currency_SQL($this->cn,$p_currency_code);
- $iso_code=$sql_currency->getp("cr_code_iso");
+ $str_code=$sql_currency->getp("cr_code_iso");
+ $sql_currencydefault=new Currency_SQL($this->cn,0);
+ $iso_code=$sql_currencydefault->getp("cr_code_iso");
// without VAT
$r.=<<
@@ -1104,7 +1117,7 @@ EOF;
- {$tot_str}
+ {$tot_str} {$str_code}
@@ -1487,7 +1500,7 @@ EOF;
$W1->label = "";
$W1->name = "e_march" . $i;
$W1->value = $march;
- $W1->table = 1;
+ $W1->table = 0;
$W1->set_attribute('typecard', 'cred');
$W1->set_dblclick("fill_ipopcard(this);");
$W1->set_attribute('ipopup', 'ipopcard');
diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php
index bc236d354..0811cfff0 100644
--- a/include/class/acc_operation.class.php
+++ b/include/class/acc_operation.class.php
@@ -266,7 +266,8 @@ EOF;
return $sum;
}
- /*!\brief set the pj of a operation in jrn. the jr_id must be set
+ /*!
+ *\brief set the pj of a operation in jrn. the jr_id must be set
*\note if the jr_id it fails
*/
function set_pj()
@@ -394,7 +395,8 @@ EOF;
$this->jr_internal= $l_line['jr_internal'];
return $this->jr_internal;
}
- /*!\brief search an operation thankx it internal code
+ /*!
+ * \brief search an operation thankx it internal code
* \param internal code
* \return 0 ok -1 nok
*/
@@ -406,10 +408,11 @@ EOF;
$this->jr_id=Database::fetch_result($res,0,0);
return 0;
}
- /*!\brief retrieve data from jrnx
- *\note the data are filtered by the access of the current user
- * \return an array or FALSE if nothing found
- */
+ /*!
+ * \brief retrieve data from jrnx
+ *\note the data are filtered by the access of the current user
+ * \return an array or FALSE if nothing found
+ */
function get_jrnx_detail()
{
global $g_user;
@@ -848,8 +851,6 @@ EOF;
}
static function test_me()
{
- $_SESSION[SESSION_KEY.'g_user']=NOALYSS_ADMINISTRATOR;
- $_SESSION[SESSION_KEY.'g_pass']='dany';
global $g_user;
$cn=Dossier::connect();
$g_user=new Noalyss_user($cn);
@@ -881,7 +882,12 @@ EOF;
return $type_operation;
}
/**
- * @brief create a form to recreate the operation and returns it, just like a correct
+ * @brief create a form to recreate the operation and returns it,
+ * it works the same as when you want to correct an operation instead of confirming
+ *
+ * @see compta_ach.inc.php
+ * @see compta_ven.inc.php
+ *
* @param $p_id string DOMID of the form
*/
function form_clone_operation($p_id) {
@@ -903,12 +909,22 @@ EOF;
"ac"=>$a_code[0]['code'],"gDossier"=>Dossier::id()
]));
$r.=Dossier::hidden();
+ $default_currency=new Acc_Currency($this->db,0);
// select the menu where the operation will be duplicated
+
$r.="
",_("Montant "),nbm($operation->det->jr_montant),$default_currency->get_code());
+ // Add info if the operation using a currency
+ if ( $operation->det->currency_id != 0 ) {
+ $currency=$this->db->get_value("select cr_code_iso from currency where id=$1",[$operation->det->currency_id]);
+ $r.=sprintf("