noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 158/173: Merge branch 'dev8001'


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 158/173: Merge branch 'dev8001'
Date: Mon, 22 Mar 2021 12:59:21 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 6e37b2793f32235c41f351879093c61447015a8e
Merge: 86de685 a4ed483
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Fri Mar 12 19:28:35 2021 +0100

    Merge branch 'dev8001'
    
    * dev8001:
      Generate document : DESCRIPTION for invoice (e_comm)
      Bug : if all the quantity are NULL, then we have only one row in jrn

 include/class/document.class.php | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --cc include/class/document.class.php
index 9da8e48,c74a0b6..d3c5abb
--- a/include/class/document.class.php
+++ b/include/class/document.class.php
@@@ -951,391 -904,353 +951,389 @@@ class Documen
                  }
                  else
                      $r=$p_array[$id];
 -            break;
 -        case 'VEN_ART_STOCK_CODE':
 -                    $id = 'e_march' . $this->counter;
 -                    // check if the march exists
 -                    if (!isset($p_array[$id]))
 -                        $r= "";
 -                    else 
 -                    {
 +                break;
 +            case 'VEN_ART_STOCK_CODE':
 +                $id='e_march'.$this->counter;
 +                // check if the march exists
 +                if (!isset($p_array[$id]))
 +                    $r="";
 +                else
 +                {
                      // check that something is sold
 -                        if ($p_array['e_march' . $this->counter . '_price'] 
!= 0 
 -                                && $p_array['e_quant' . $this->counter] != 0)
 -                        {
 -                            $f = new Fiche($this->db);
 -                            $f->get_by_qcode($p_array[$id], false);
 -                            $r = $f->strAttribut(ATTR_DEF_STOCK);
 -                            $r=($r == NOTFOUND)?'':$r;
 -                        } 
 +                    if 
($p_array['e_march'.$this->counter.'_price']!=0&&$p_array['e_quant'.$this->counter]!=0)
 +                    {
 +                        $f=new Fiche($this->db);
 +                        $f->get_by_qcode($p_array[$id], false);
 +                        $r=$f->strAttribut(ATTR_DEF_STOCK);
 +                        $r=($r==NOTFOUND)?'':$r;
                      }
 -            break;
 -        case 'VEN_QCODE':
 -            $id='e_march'.$this->counter ;
 -            if ( !isset ($p_array[$id]) ) return "";
 -            return $p_array[$id];
 -            break;
 -        case 'VEN_ART_PRICE':
 -            $id='e_march'.$this->counter.'_price' ;
 -            if ( !isset ($p_array[$id]) ) return "";
 -                      if ( $p_array[$id]  == 0 ) return "";
 -            $r=$p_array[$id];
 -            break;
 -
 -        case 'TVA_RATE':
 -        case 'VEN_ART_TVA_RATE':
 -            $id='e_march'.$this->counter.'_tva_id';
 -            if ( !isset ($p_array[$id]) ) return "";
 -            if ( $p_array[$id] == -1 || $p_array[$id]=='' ) return "";
 -            $march_id='e_march'.$this->counter.'_price' ;
 -            if ( ! isset ($p_array[$march_id])) return '';
 -            $tva=new Acc_Tva($this->db);
 -            $tva->set_parameter("id",$p_array[$id]);
 -            if ( $tva->load() == -1) return '';
 -            return $tva->get_parameter("rate");
 -            break;
 +                }
 +                break;
 +            case 'VEN_QCODE':
 +                $id='e_march'.$this->counter;
 +                if (!isset($p_array[$id]))
 +                    return "";
 +                return $p_array[$id];
 +                break;
 +            case 'VEN_ART_PRICE':
 +                $id='e_march'.$this->counter.'_price';
 +                if (!isset($p_array[$id]))
 +                    return "";
 +                if ($p_array[$id]==0)
 +                    return "";
 +                $r=$p_array[$id];
 +                break;
  
 -        case 'TVA_CODE':
 -        case 'VEN_ART_TVA_CODE':
 -            $id='e_march'.$this->counter.'_tva_id';
 -            if ( !isset ($p_array[$id]) ) return "";
 -            if ( $p_array[$id] == -1 ) return "";
 -            $qt='e_quant'.$this->counter;
 -            $price='e_march'.$this->counter.'_price' ;
 -            if ( $p_array[$price] == 0 || $p_array[$qt] == 0
 -                    || strlen(trim( $p_array[$price] )) ==0
 -                    || strlen(trim($p_array[$qt])) ==0)
 -                return "";
 +            case 'TVA_RATE':
 +            case 'VEN_ART_TVA_RATE':
 +                $id='e_march'.$this->counter.'_tva_id';
 +                if (!isset($p_array[$id]))
 +                    return "";
 +                if ($p_array[$id]==-1||$p_array[$id]=='')
 +                    return "";
 +                $march_id='e_march'.$this->counter.'_price';
 +                if (!isset($p_array[$march_id]))
 +                    return '';
 +                $tva=new Acc_Tva($this->db);
 +                $tva->set_parameter("id", $p_array[$id]);
 +                if ($tva->load()==-1)
 +                    return '';
 +                return $tva->get_parameter("rate");
 +                break;
  
 -            $r=$p_array[$id];
 -            break;
 +            case 'TVA_CODE':
 +            case 'VEN_ART_TVA_CODE':
 +                $id='e_march'.$this->counter.'_tva_id';
 +                if (!isset($p_array[$id]))
 +                    return "";
 +                if ($p_array[$id]==-1)
 +                    return "";
 +                $qt='e_quant'.$this->counter;
 +                $price='e_march'.$this->counter.'_price';
 +                if 
($p_array[$price]==0||$p_array[$qt]==0||strlen(trim($p_array[$price]))==0||strlen(trim($p_array[$qt]))==0)
 +                    return "";
 +
 +                $r=$p_array[$id];
 +                break;
  
 -        case 'TVA_LABEL':
 -            $id='e_march'.$this->counter.'_tva_id';
 -            if ( !isset ($p_array[$id]) ) return "";
 -            $march_id='e_march'.$this->counter.'_price' ;
 -            if ( ! isset ($p_array[$march_id])) return '';
 -            if ( $p_array[$march_id] == 0) return '';
 -            $tva=new Acc_Tva($this->db,$p_array[$id]);
 -            if ($tva->load() == -1 ) return "";
 -            $r=$tva->get_parameter('label');
 +            case 'TVA_LABEL':
 +                $id='e_march'.$this->counter.'_tva_id';
 +                if (!isset($p_array[$id]))
 +                    return "";
 +                $march_id='e_march'.$this->counter.'_price';
 +                if (!isset($p_array[$march_id]))
 +                    return '';
 +                if ($p_array[$march_id]==0)
 +                    return '';
 +                $tva=new Acc_Tva($this->db, $p_array[$id]);
 +                if ($tva->load()==-1)
 +                    return "";
 +                $r=$tva->get_parameter('label');
  
 -            break;
 +                break;
  
              /* total VAT for one sold */
 -        case 'TVA_AMOUNT':
 -        case 'VEN_TVA':
 -            $qt='e_quant'.$this->counter;
 -            $price='e_march'.$this->counter.'_price' ;
 -            $tva='e_march'.$this->counter.'_tva_id';
 -            /* if we do not use vat this var. is not set */
 -            if ( !isset($p_array[$tva]) ) return '';
 -            if ( !isset ($p_array [ 'e_march'.$this->counter ]) ) return "";
 -             if ( !isset ($p_array[$tva]) ) return "";
 -            // check that something is sold
 -            if ( $p_array[$price] == 0 || $p_array[$qt] == 0
 -                    || strlen(trim( $p_array[$price] )) ==0
 -                    || strlen(trim($p_array[$qt])) ==0)
 -                return "";
 -            $r=$p_array['e_march'.$this->counter.'_tva_amount'];
 -            break;
 +            case 'TVA_AMOUNT':
 +            case 'VEN_TVA':
 +                $qt='e_quant'.$this->counter;
 +                $price='e_march'.$this->counter.'_price';
 +                $tva='e_march'.$this->counter.'_tva_id';
 +                /* if we do not use vat this var. is not set */
 +                if (!isset($p_array[$tva]))
 +                    return '';
 +                if (!isset($p_array ['e_march'.$this->counter]))
 +                    return "";
 +                if (!isset($p_array[$tva]))
 +                    return "";
 +                // check that something is sold
 +                if 
($p_array[$price]==0||$p_array[$qt]==0||strlen(trim($p_array[$price]))==0||strlen(trim($p_array[$qt]))==0)
 +                    return "";
 +                $r=$p_array['e_march'.$this->counter.'_tva_amount'];
 +                break;
              /* TVA automatically computed */
 -        case 'VEN_ART_TVA':
 -        
 -            $qt='e_quant'.$this->counter;
 -            $price='e_march'.$this->counter.'_price' ;
 -            $tva='e_march'.$this->counter.'_tva_id';
 -            if ( !isset ($p_array['e_march'.$this->counter]) ) return "";
 -            if ( !isset ($p_array[$tva]) ) return "";
 -            // check that something is sold
 -            if ( $p_array[$price] == 0 || $p_array[$qt] == 0
 -                    || strlen(trim( $p_array[$price] )) ==0
 -                    || strlen(trim($p_array[$qt])) ==0)
 -                return "";
 -            $oTva=new Acc_Tva($this->db,$p_array[$tva]);
 -            if ($oTva->load() == -1 ) return "";
 -            $r=round($p_array[$price],2)*$oTva->get_parameter('rate');
 -            $r=round($r,2);
 -            break;
 -
 -        case 'VEN_ART_TVAC':
 -            $qt='e_quant'.$this->counter;
 -            $price='e_march'.$this->counter.'_price' ;
 -            if ( !isset ($p_array['e_march'.$this->counter]) ) return "";
 -             if ( !isset ($p_array['e_march'.$this->counter.'_tva_id']) ) 
return "";
 -            // check that something is sold
 -            if ( $p_array[$price] == 0 || $p_array[$qt] == 0
 -                    || strlen(trim( $p_array[$price] )) ==0
 -                    || strlen(trim($p_array[$qt])) ==0)
 -                return "";
 -            if ( ! isset ($p_array['e_march'.$this->counter.'_tva_id']) ) 
return '';
 -            $tva=new 
Acc_Tva($this->db,$p_array['e_march'.$this->counter.'_tva_id'] );
 -            if ($tva->load() == -1 )
 -            {
 -                $r=round($p_array[$price],2);
 -            }
 -            else
 -            {
 -                
$r=round($p_array[$price]*$tva->get_parameter('rate')+$p_array[$price],2);
 -            }
 -
 -            break;
 -
 -        case 'VEN_ART_QUANT':
 -            $id='e_quant'.$this->counter;
 -            if ( !isset ($p_array[$id]) ) return "";
 -            // check that something is sold
 -            if ( $p_array['e_march'.$this->counter.'_price'] == 0
 -                    || $p_array['e_quant'.$this->counter] == 0
 -                    || strlen(trim( 
$p_array['e_march'.$this->counter.'_price'] )) ==0
 -                    || strlen(trim($p_array['e_quant'.$this->counter])) ==0 )
 -                return "";
 -            $r=$p_array[$id];
 -            break;
 -
 -        case 'VEN_HTVA':
 -            $id='e_march'.$this->counter.'_price' ;
 -            $quant='e_quant'.$this->counter;
 -            if ( !isset ($p_array[$id]) ) return "";
 -
 -            // check that something is sold
 -            if ( $p_array['e_march'.$this->counter.'_price'] == 0 || 
$p_array['e_quant'.$this->counter] == 0
 -                    || strlen(trim( 
$p_array['e_march'.$this->counter.'_price'] )) ==0
 -                    || strlen(trim($p_array['e_quant'.$this->counter])) ==0)
 -                return "";
 -                      bcscale(4);
 -            $r=bcmul($p_array[$id],$p_array[$quant]);
 -                      $r=round($r,2);
 -            break;
 +            case 'VEN_ART_TVA':
 +
 +                $qt='e_quant'.$this->counter;
 +                $price='e_march'.$this->counter.'_price';
 +                $tva='e_march'.$this->counter.'_tva_id';
 +                if (!isset($p_array['e_march'.$this->counter]))
 +                    return "";
 +                if (!isset($p_array[$tva]))
 +                    return "";
 +                // check that something is sold
 +                if 
($p_array[$price]==0||$p_array[$qt]==0||strlen(trim($p_array[$price]))==0||strlen(trim($p_array[$qt]))==0)
 +                    return "";
 +                $oTva=new Acc_Tva($this->db, $p_array[$tva]);
 +                if ($oTva->load()==-1)
 +                    return "";
 +                $r=round($p_array[$price], 2)*$oTva->get_parameter('rate');
 +                $r=round($r, 2);
 +                break;
  
 -        case 'VEN_TVAC':
 -            $id='e_march'.$this->counter.'_tva_amount' ;
 -            $price='e_march'.$this->counter.'_price' ;
 -            $quant='e_quant'.$this->counter;
 -            if ( ! isset($p_array['e_march'.$this->counter.'_price'])|| 
!isset($p_array['e_quant'.$this->counter])) {
 -                return "";
 -            }
 -            // check that something is sold
 -            if ( $p_array['e_march'.$this->counter.'_price'] == 0 || 
$p_array['e_quant'.$this->counter] == 0 ) { return "";}
 -                      bcscale(4);
 -            // if TVA not exist
 -            if ( ! isset($p_array[$id]))
 -                $r=  bcmul($p_array[$price],$p_array[$quant]);
 -            else{
 -                $r=  bcmul($p_array[$price],$p_array[$quant]);
 -                $r=bcadd($r,$p_array[$id]);
 -                      }
 -                      $r=round($r,2);
 -                      return $r;
 -            break;
 +            case 'VEN_ART_TVAC':
 +                $qt='e_quant'.$this->counter;
 +                $price='e_march'.$this->counter.'_price';
 +                if (!isset($p_array['e_march'.$this->counter]))
 +                    return "";
 +                if (!isset($p_array['e_march'.$this->counter.'_tva_id']))
 +                    return "";
 +                // check that something is sold
 +                if 
($p_array[$price]==0||$p_array[$qt]==0||strlen(trim($p_array[$price]))==0||strlen(trim($p_array[$qt]))==0)
 +                    return "";
 +                if (!isset($p_array['e_march'.$this->counter.'_tva_id']))
 +                    return '';
 +                $tva=new Acc_Tva($this->db, 
$p_array['e_march'.$this->counter.'_tva_id']);
 +                if ($tva->load()==-1)
 +                {
 +                    $r=round($p_array[$price], 2);
 +                }
 +                else
 +                {
 +                    
$r=round($p_array[$price]*$tva->get_parameter('rate')+$p_array[$price], 2);
 +                }
  
 -        case 'TOTAL_VEN_HTVA':
 -            bcscale(4);
 -            $sum=0.0;
 -            if ( !isset($p_array["nb_item"]) ) return "";
 -            for ($i=0;$i<$p_array["nb_item"];$i++)
 -            {
 -                $sell='e_march'.$i.'_price';
 -                $qt='e_quant'.$i;
 +                break;
  
 -                if ( ! isset ($p_array[$sell]) ) break;
 +            case 'VEN_ART_QUANT':
 +                $id='e_quant'.$this->counter;
 +                if (!isset($p_array[$id]))
 +                    return "";
 +                // check that something is sold
 +                if 
($p_array['e_march'.$this->counter.'_price']==0||$p_array['e_quant'.$this->counter]==0||strlen(trim($p_array['e_march'.$this->counter.'_price']))==0||strlen(trim($p_array['e_quant'.$this->counter]))==0)
 +                    return "";
 +                $r=$p_array[$id];
 +                break;
  
 -                if ( strlen(trim($p_array[$sell])) == 0 ||
 -                        strlen(trim($p_array[$qt])) == 0 ||
 -                        $p_array[$qt]==0 || $p_array[$sell]==0)
 -                    continue;
 -                $tmp1=bcmul($p_array[$sell],$p_array[$qt]);
 -                $sum=bcadd($sum,$tmp1);
 +            case 'VEN_HTVA':
 +                $id='e_march'.$this->counter.'_price';
 +                $quant='e_quant'.$this->counter;
 +                if (!isset($p_array[$id]))
 +                    return "";
 +
 +                // check that something is sold
 +                if 
($p_array['e_march'.$this->counter.'_price']==0||$p_array['e_quant'.$this->counter]==0||strlen(trim($p_array['e_march'.$this->counter.'_price']))==0||strlen(trim($p_array['e_quant'.$this->counter]))==0)
 +                    return "";
 +                bcscale(4);
 +                $r=bcmul($p_array[$id], $p_array[$quant]);
 +                $r=round($r, 2);
 +                break;
  
 +            case 'VEN_TVAC':
 +                $id='e_march'.$this->counter.'_tva_amount';
 +                $price='e_march'.$this->counter.'_price';
 +                $quant='e_quant'.$this->counter;
 +                if 
(!isset($p_array['e_march'.$this->counter.'_price'])||!isset($p_array['e_quant'.$this->counter]))
 +                {
 +                    return "";
 +                }
 +                // check that something is sold
 +                if 
($p_array['e_march'.$this->counter.'_price']==0||$p_array['e_quant'.$this->counter]==0)
 +                {
 +                    return "";
 +                }
 +                bcscale(4);
 +                // if TVA not exist
 +                if (!isset($p_array[$id]))
 +                    $r=bcmul($p_array[$price], $p_array[$quant]);
 +                else
 +                {
 +                    $r=bcmul($p_array[$price], $p_array[$quant]);
 +                    $r=bcadd($r, $p_array[$id]);
 +                }
 +                $r=round($r, 2);
 +                return $r;
 +                break;
  
 -            }
 -            $r=round($sum,2);
 -            break;
 -        case 'TOTAL_VEN_TVAC':
 -            if ( !isset($p_array["nb_item"]) ) return "";
 -            $sum=0.0;
 -            bcscale(4);
 -            for ($i=0;$i<$p_array["nb_item"];$i++)
 -            {
 -                $tva='e_march'.$i.'_tva_amount';
 -                $tva_amount=0;
 -                /* if we do not use vat this var. is not set */
 -                if ( isset($p_array[$tva]) )
 +            case 'TOTAL_VEN_HTVA':
 +                bcscale(4);
 +                $sum=0.0;
 +                if (!isset($p_array["nb_item"]))
 +                    return "";
 +                for ($i=0; $i<$p_array["nb_item"]; $i++)
                  {
 -                    $tva_amount=$p_array[$tva];
 +                    $sell='e_march'.$i.'_price';
 +                    $qt='e_quant'.$i;
 +
 +                    if (!isset($p_array[$sell]))
 +                        break;
 +
 +                    if (strlen(trim($p_array[$sell]))==0||
 +                            strlen(trim($p_array[$qt]))==0||
 +                            $p_array[$qt]==0||$p_array[$sell]==0)
 +                        continue;
 +                    $tmp1=bcmul($p_array[$sell], $p_array[$qt]);
 +                    $sum=bcadd($sum, $tmp1);
                  }
 -                $sell=$p_array['e_march'.$i.'_price'];
 -                $qt=$p_array['e_quant'.$i];
 -                $tot=bcmul($sell,$qt);
 -                $tot=bcadd($tot,$tva_amount);
 -                $sum=bcadd($sum,$tot);
 -            }
 -            $r=round($sum,2);
 +                $r=round($sum, 2);
 +                break;
 +            case 'TOTAL_VEN_TVAC':
 +                if (!isset($p_array["nb_item"]))
 +                    return "";
 +                $sum=0.0;
 +                bcscale(4);
 +                for ($i=0; $i<$p_array["nb_item"]; $i++)
 +                {
 +                    $tva='e_march'.$i.'_tva_amount';
 +                    $tva_amount=0;
 +                    /* if we do not use vat this var. is not set */
 +                    if (isset($p_array[$tva]))
 +                    {
 +                        $tva_amount=$p_array[$tva];
 +                    }
 +                    $sell=$p_array['e_march'.$i.'_price'];
 +                    $qt=$p_array['e_quant'.$i];
 +                    $tot=bcmul($sell, $qt);
 +                    $tot=bcadd($tot, $tva_amount);
 +                    $sum=bcadd($sum, $tot);
 +                }
 +                $r=round($sum, 2);
  
 -            break;
 -        case 'TOTAL_TVA':
 -            if ( !isset($p_array["nb_item"]) ) return "";
 -            $sum=0.0;
 -            for ($i=0;$i<$p_array["nb_item"];$i++)
 -            {
 -                $tva='e_march'.$i.'_tva_amount';
 -                if (! isset($p_array[$tva])) $tva_amount=0.0;
 -                else {
 -                    $tva_amount=$p_array[$tva];
 -                    $tva_amount=($tva_amount=="")?0:$tva_amount;
 +                break;
 +            case 'TOTAL_TVA':
 +                if (!isset($p_array["nb_item"]))
 +                    return "";
 +                $sum=0.0;
 +                for ($i=0; $i<$p_array["nb_item"]; $i++)
 +                {
 +                    $tva='e_march'.$i.'_tva_amount';
 +                    if (!isset($p_array[$tva]))
 +                        $tva_amount=0.0;
 +                    else
 +                    {
 +                        $tva_amount=$p_array[$tva];
 +                        $tva_amount=($tva_amount=="")?0:$tva_amount;
 +                    }
 +                    $sum+=$tva_amount;
 +                    $sum=round($sum, 2);
                  }
 -                $sum+=$tva_amount;
 -                $sum=round($sum,2);
 -            }
 -            $r=$sum;
 +                $r=$sum;
  
 -            break;
 -        case 'BON_COMMANDE':
 -            if ( isset($p_array['bon_comm']))
 -                return $p_array['bon_comm'];
 -            else
 -                return "";
 -            break;
 -        case 'PJ':
 -            if ( isset($p_array['e_pj']))
 -                return $p_array['e_pj'];
 -            else
 -                return "";
 +                break;
 +            case 'BON_COMMANDE':
 +                if (isset($p_array['bon_comm']))
 +                    return $p_array['bon_comm'];
 +                else
 +                    return "";
 +                break;
 +            case 'PJ':
 +                if (isset($p_array['e_pj']))
 +                    return $p_array['e_pj'];
 +                else
 +                    return "";
  
 -        case 'OTHER_INFO':
 -            if ( isset($p_array['other_info']))
 -                return $p_array['other_info'];
 -            else
 -                return "";
 -            break;
 -        case 'LABELOP':
 -            if ( isset($p_array['e_comm']))
 -                return $p_array['e_comm'];
 -            break;
 -        case 'ACOMPTE':
 -            if ( isset($p_array['acompte']))
 -                return $p_array['acompte'];
 -                      return "0";
 -            break;
 -        case 'STOCK_NAME':
 -                if ( ! isset ($p_array['repo'])) return "";
 -                $ret=$this->db->get_value('select r_name from 
public.stock_repository where r_id=$1',array($p_array['repo']));
 +            case 'OTHER_INFO':
 +                if (isset($p_array['other_info']))
 +                    return $p_array['other_info'];
 +                else
 +                    return "";
 +                break;
 +            case 'LABELOP':
 +                if (isset($p_array['e_comm']))
 +                    return $p_array['e_comm'];
 +                break;
 +            case 'ACOMPTE':
 +                if (isset($p_array['acompte']))
 +                    return $p_array['acompte'];
 +                return "0";
 +                break;
 +            case 'STOCK_NAME':
 +                if (!isset($p_array['repo']))
 +                    return "";
 +                $ret=$this->db->get_value('select r_name from 
public.stock_repository where r_id=$1',
 +                        array($p_array['repo']));
                  return $ret;
 -        case 'STOCK_ADRESS':
 -                if ( ! isset ($p_array['repo'])) return "";
 -                $ret=$this->db->get_value('select r_adress from 
public.stock_repository where r_id=$1',array($p_array['repo']));
 +            case 'STOCK_ADRESS':
 +                if (!isset($p_array['repo']))
 +                    return "";
 +                $ret=$this->db->get_value('select r_adress from 
public.stock_repository where r_id=$1',
 +                        array($p_array['repo']));
                  return $ret;
 -        case 'STOCK_COUNTRY':
 -                if ( ! isset ($p_array['repo'])) return "";
 -                $ret=$this->db->get_value('select r_country from 
public.stock_repository where r_id=$1',array($p_array['repo']));
 +            case 'STOCK_COUNTRY':
 +                if (!isset($p_array['repo']))
 +                    return "";
 +                $ret=$this->db->get_value('select r_country from 
public.stock_repository where r_id=$1',
 +                        array($p_array['repo']));
                  return $ret;
 -        case 'STOCK_CITY':
 -                if ( ! isset ($p_array['repo'])) return "";
 -                $ret=$this->db->get_value('select r_city from 
public.stock_repository where r_id=$1',array($p_array['repo']));
 +            case 'STOCK_CITY':
 +                if (!isset($p_array['repo']))
 +                    return "";
 +                $ret=$this->db->get_value('select r_city from 
public.stock_repository where r_id=$1',
 +                        array($p_array['repo']));
                  return $ret;
 -        case 'STOCK_PHONE':
 -                if ( ! isset ($p_array['repo'])) return "";
 -                $ret=$this->db->get_value('select r_phone from 
public.stock_repository where r_id=$1',array($p_array['repo']));
 +            case 'STOCK_PHONE':
 +                if (!isset($p_array['repo']))
 +                    return "";
 +                $ret=$this->db->get_value('select r_phone from 
public.stock_repository where r_id=$1',
 +                        array($p_array['repo']));
                  return $ret;
 -        // Follow up
 -        //Title
 -        case 'TITLE':
 -            if ( isset($p_array['ag_title']))                 return 
$p_array['ag_title'];
 -            return "";
 -            break;
 -        // Description is the first comment
 -        case 'DESCRIPTION':
 -            if ( isset($p_array['ag_id'])) {
 -                // retrieve first comment
 -                $description=$this->db->get_value("select agc_comment "
 -                        . "  from action_gestion_comment "
 -                        . "where ag_id=$1 order by AGC_ID asc limit 1"
 -                        ,[$p_array['ag_id']]);
 -                return $description;
 -            }
 +            // Follow up
 +            //Title
 +            case 'TITLE':
 +                if (isset($p_array['ag_title']))
 +                    return $p_array['ag_title'];
 +                return "";
 +                break;
 +            // Description is the first comment
 +            case 'DESCRIPTION':
 +                if (isset($p_array['ag_id']))
 +                {
 +                    // retrieve first comment
 +                    $description=$this->db->get_value("select agc_comment "
 +                            ."  from action_gestion_comment "
 +                            ."where ag_id=$1 order by AGC_ID asc limit 1"
 +                            , [$p_array['ag_id']]);
 +                    return $description;
-                 }
-                 if (isset($p_array['e_comm']))
-                 {
-                     return $p_array['e_comm'];
-                 }
- 
-                 return "";
-                 break;
++              }
+             if ( isset($p_array['e_comm'])) {return $p_array['e_comm'] ; }
+             
+             return "";
+             break;
+       
 -        // Comments, use a counter to move to the next comment, only for 
Follow-Up
 -        //
 -        case 'COMMENT':
 -            if ( isset($p_array['ag_id'])) {
 -                // Static value, if null the retrieve all of them
 -                if ( $aComment == NULL ) {
 -                    // retrieve comments
 -                    $aComment=$this->db->get_array("select AGC_ID,agc_comment 
,"
 -                            ." to_char(agc_date,'DD-MM-YY HH24:MI') as 
str_date ,"
 -                            . " tech_user "
 -                            . "  from action_gestion_comment "
 -                            . "where ag_id=$1 order by 1"
 -                            ,[$p_array['ag_id']]);
 -                }
 -                $nb_comment=count($aComment);
 -                $description="";
 -                if (count ($aComment) >  $counter_comment) {
 -                    $description.= sprintf(_('le %s , %s écrit %s'),
 -                            $aComment[$counter_comment]['str_date'],
 -                            $aComment[$counter_comment]['tech_user'],
 -                            $aComment[$counter_comment]['agc_comment']);
 -                    $counter_comment++;
 +
 +            // Comments, use a counter to move to the next comment, only for 
Follow-Up
 +            //
 +            case 'COMMENT':
 +                if (isset($p_array['ag_id']))
 +                {
 +                    // Static value, if null the retrieve all of them
 +                    if ($aComment==NULL)
 +                    {
 +                        // retrieve comments
 +                        $aComment=$this->db->get_array("select 
AGC_ID,agc_comment ,"
 +                                ." to_char(agc_date,'DD-MM-YY HH24:MI') as 
str_date ,"
 +                                ." tech_user "
 +                                ."  from action_gestion_comment "
 +                                ."where ag_id=$1 order by 1"
 +                                , [$p_array['ag_id']]);
 +                    }
 +                    $nb_comment=count($aComment);
 +                    $description="";
 +                    if (count($aComment)>$counter_comment)
 +                    {
 +                        $description.=sprintf(_('le %s , %s écrit %s'), 
$aComment[$counter_comment]['str_date'],
 +                                $aComment[$counter_comment]['tech_user'], 
$aComment[$counter_comment]['agc_comment']);
 +                        $counter_comment++;
 +                    }
 +                    return $description;
                  }
 -                return $description;
 -            }
 -            return "";
 -            break;
 -        // Related Action, use a counter to move to the next related action, 
only for Follow-Up
 -        //
 -        case 'RELATED_ACTION':
 -            if ( isset($p_array['ag_id'])) {
 -                // Static value, if null the retrieve all of them
 -                if ( $aRelatedAction == NULL ) {
 -                    // retrieve parent
 -                    $followup=new Follow_Up($this->db,$p_array["ag_id"]);
 -                    $aRelatedAction=array();
 -                    $aParent=$followup->get_parent();
 -                    if ($aParent == -1 )return "";
 -                    $nb_parent=count($aParent);
 -                    $sql_related_action = "
 +                return "";
 +                break;
 +            // Related Action, use a counter to move to the next related 
action, only for Follow-Up
 +            //
 +            case 'RELATED_ACTION':
 +                if (isset($p_array['ag_id']))
 +                {
 +                    // Static value, if null the retrieve all of them
 +                    if ($aRelatedAction==NULL)
 +                    {
 +                        // retrieve parent
 +                        $followup=new Follow_Up($this->db, $p_array["ag_id"]);
 +                        $aRelatedAction=array();
 +                        $aParent=$followup->get_parent();
 +                        if ($aParent==-1)
 +                            return "";
 +                        $nb_parent=count($aParent);
 +                        $sql_related_action="
                   select ag_id,
                      f_id_dest,
                      (select ad_value from fiche_detail fd1 where fd1.ad_id=23 
and fd1.f_id=f_id_dest) as qcode,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]