Merged revisions 5550-5553 via svnmerge from

svn+ssh://danydb@ns352270.ovh.net/svn/phpcompta/tags/rel670

........
  r5550 | danydb | 2013-11-28 17:22:58 +0100 (jeu., 28 nov. 2013) | 1 line
  
  Empeche fermeture si une seule periode, empeche erreur si periode inexistante
........
  r5551 | danydb | 2013-11-28 20:55:32 +0100 (jeu., 28 nov. 2013) | 1 line
  
  resolve bug in export stock
........
  r5552 | danydb | 2013-11-28 20:55:34 +0100 (jeu., 28 nov. 2013) | 1 line
  
  Correct stock insert and reporting
........
  r5553 | danydb | 2013-11-29 13:52:45 +0100 (ven., 29 nov. 2013) | 2 lines
  
  Bug #922 : cosmetic
  Task #922 - Totaux à 0 dans la fiche COMPTA/MENUACH/ACH
........
This commit is contained in:
Dany De Bontridder 2013-11-29 14:46:54 +00:00
parent f3488ac37a
commit f64c79ca70
8 changed files with 48 additions and 26 deletions

View file

@ -1482,7 +1482,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$r.='<tr>'.td(_('Total TVAC')).td(hb(nbm($tot)),'class="num"');
$r.='</table>';
} else {
$r.='<br>Total '.nbm(hb($tot));
$r.='<br>Total '.hb(nbm($tot));
}
$r.='</p>';
/* Add hidden */

View file

@ -809,7 +809,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$r.='<tr>'.td(_('Total TVAC')).td(hb(nbm($tot)),'class="num"');
$r.='</table>';
} else {
$r.='<br>Total '.nbm(hb($tot));
$r.='<br>Total '.hb(nbm($tot));
}
$r.='</p>';
if (!$p_summary) {

View file

@ -415,7 +415,7 @@ class Periode
*/
function load()
{
if ($this->p_id == '') $this->p_id=-1;
$row=$this->cn->get_array("select p_start,p_end,p_exercice,p_closed,p_central from parm_periode where p_id=$1",
array($this->p_id));
if ($row == null ) return -1;

View file

@ -259,6 +259,18 @@ class Stock extends Stock_Sql
function build_tmp_table($p_array)
{
global $cn,$g_user;
// exercice
if (isset ($p_array['state_exercice']))
{
$periode=new Periode($cn);
$date= format_date($p_array['state_exercice'], 'YYYY-MM-DD');
$periode->find_periode($date);
} else {
$periode_id=$g_user->get_periode();
$periode=new Periode($cn,$periode_id);
}
$periode->load();
$tmp_id = $cn->get_next_seq("public.tmp_stockgood_s_id_seq");
$cn->exec_sql("delete from tmp_stockgood where s_date < now() - interval '2 days' ");
$cn->exec_sql("insert into tmp_stockgood(s_id) values ($1)", array($tmp_id));
@ -266,16 +278,6 @@ class Stock extends Stock_Sql
// get all readable repository
$a_repository = $g_user->get_available_repository('R');
$end_date = $cn->get_value("select to_char(max(p_end),'DD.MM.YYYY') from parm_periode");
if (isset($p_array['state_exercice']))
{
$tmp_date= format_date($p_array['state_exercice'],'YYYY-MM-DD','DD.MM.YYYY');
if (isDate($tmp_date) == $tmp_date)
{
$end_date = $tmp_date;
}
}
// From ACH : IN
$sql_repo_detail = "
insert into tmp_stockgood_detail(s_id,sg_code,s_qin,r_id,f_id)
@ -284,13 +286,13 @@ class Stock extends Stock_Sql
where
sg_type='d'
and j_id is not null
and j_id in (select j_id from jrnx where j_date <= to_date($2,'DD.MM.YYYY'))
and j_id in (select j_id from jrnx where j_tech_per in (select p_id from parm_periode where p_exercice=$2))
and r_id in (select r_id from profile_sec_repository where p_id=$1)
group by r_id,trim(sg_code),f_id
";
// From VEN : out
$cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $end_date));
$cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $periode->p_exercice));
$sql_repo_detail = "
insert into tmp_stockgood_detail(s_id,sg_code,s_qout,r_id,f_id)
select $tmp_id,trim(sg_code) , coalesce(sum(sg_quantity),0) as qout,r_id,f_id
@ -298,11 +300,11 @@ class Stock extends Stock_Sql
where
sg_type='c'
and sg.j_id is not null
and sg.j_id in (select j_id from jrnx where j_date <= to_date($2,'DD.MM.YYYY'))
and sg.j_id in (select j_id from jrnx where j_tech_per in (select p_id from parm_periode where p_exercice=$2))
and sg.r_id in (select r_id from profile_sec_repository where p_id=$1)
group by r_id,trim(sg_code),f_id
";
$cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $end_date));
$cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $periode->p_exercice));
// From INV IN
$sql_repo_detail = "
@ -312,13 +314,13 @@ class Stock extends Stock_Sql
where
sg_type='d'
and j_id is null
and sg_tech_date <= to_date($2,'DD.MM.YYYY')
and sg_date >= ( select min(p_start) from parm_periode where p_exercice=$2)
and sg_date <= ( select max(p_end) from parm_periode where p_exercice=$2)
and sg.r_id in (select r_id from profile_sec_repository where p_id=$1)
group by r_id,trim(sg_code),f_id
";
// From INV: OUT
$cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $end_date));
$cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $periode->p_exercice));
$sql_repo_detail = "
insert into tmp_stockgood_detail(s_id,sg_code,s_qout,r_id,f_id)
select $tmp_id,trim(sg_code), coalesce(sum(sg_quantity),0) as qout,r_id,f_id
@ -327,10 +329,10 @@ class Stock extends Stock_Sql
sg_type='c'
and j_id is null
and r_id in (select r_id from profile_sec_repository where p_id=$1)
and sg_tech_date <= to_date($2,'DD.MM.YYYY')
and sg_date <= to_date($2,'DD.MM.YYYY')
group by r_id,trim(sg_code),f_id
";
$cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $end_date));
$cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $periode->p_exercice));
return $tmp_id;
}

View file

@ -135,9 +135,17 @@ class Stock_Goods extends Stock_Goods_Sql
if ($p_array['sg_quantity' . $i] != 0 &&
trim($p_array['sg_code' . $i]) != '')
{
$stock= strtoupper(trim($p_array['sg_code' . $i]));
$fiche=new Fiche($cn);
$fiche->get_by_qcode($p_array['sg_code' . $i]);
$stock=$fiche->strAttribut(ATTR_DEF_STOCK);
/*
* check if code stock does exist
*/
$count=$cn->get_value('select count(*) from fiche_detail where ad_id=$1 and ad_value=$2',
array(ATTR_DEF_STOCK,$stock));
if ( $count==0) {
throw new Exception("Code stock inexistant");
}
$a->f_id=$fiche->id;
$a->sg_code = $stock;
$a->sg_quantity = abs($p_array['sg_quantity' . $i]);

View file

@ -28,8 +28,9 @@
*/
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
require_once 'class_stock.php';
global $cn;
// var_dump($_GET);
$stock=new Stock();
$stock=new Stock($cn);
$tmp_id = $stock->build_tmp_table($_GET);
header('Pragma: public');

View file

@ -89,7 +89,13 @@ if ( $action== "delete_per" )
}
else
{
$Res=$cn->exec_sql("delete from parm_periode where p_id=$p_per");
$count=$cn->get_value("select count(*) from parm_periode;");
if ( $count > 1 ) {
$Res=$cn->exec_sql("delete from parm_periode where p_id=$p_per");
}
{
alert(' Désolé mais vous devez avoir au moins une période');
}
}
$choose="yes";
}

View file

@ -35,7 +35,12 @@ require_once 'class_stock.php';
// Get type = table or list
$iexercice=new ISelect('state_exercice');
$iexercice->value=$cn->make_array("select max(p_end) as date_end, p_exercice from parm_periode group by p_exercice order by 2 desc");
$iexercice->selected=(isset($_GET['state_exercice']))?$_GET['state_exercice']:"";
$per=new Periode($cn,$g_user->get_periode());
$per->load();
$date_limit=$per->limit_year($per->p_exercice);
$last_day=$per->last_day($date_limit['end']);
$last_day=format_date($last_day,'DD.MM.YYYY','YYYY-MM-DD');
$iexercice->selected=(isset($_GET['state_exercice']))?$_GET['state_exercice']:$last_day;
$presentation=new ISelect("present");
$presentation->value=array (