#621 Génération de document: tag généric
#620 Génération de document : acompte replace Document::a_ref by Document::anchor Add constraint for user_sec_repository user_sec_action_profile
This commit is contained in:
parent
ffb3d3bf06
commit
c005f8b91d
3 changed files with 83 additions and 3 deletions
|
|
@ -359,7 +359,7 @@ class Document
|
|||
*
|
||||
* \return a string
|
||||
*/
|
||||
function a_ref()
|
||||
function anchor()
|
||||
{
|
||||
if ( $this->d_id == 0 )
|
||||
return '';
|
||||
|
|
@ -496,6 +496,7 @@ class Document
|
|||
* - [BENEF_CO]
|
||||
* - [BENEF_CITY]
|
||||
* - [BENEF_VAT]
|
||||
* - [ACOMPTE]
|
||||
*
|
||||
* \param $p_tag TAG
|
||||
* \param $p_array data from $_POST
|
||||
|
|
@ -1074,6 +1075,39 @@ class Document
|
|||
if ( isset($p_array['e_comm']))
|
||||
return $p_array['e_comm'];
|
||||
break;
|
||||
case 'ACOMPTE':
|
||||
if ( isset($p_array['acompte']))
|
||||
return $p_array['acompte'];
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* retrieve the value of ATTR for e_march
|
||||
*/
|
||||
if (preg_match('/^ATTR/', $p_tag) == 1)
|
||||
{
|
||||
// Retrieve f_id
|
||||
if ( isset ($p_array['e_march'.$counter]))
|
||||
{
|
||||
$id = $p_array['e_march' . $counter];
|
||||
$r=$this->replace_special_tag($id,$p_tag);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* retrieve the value of ATTR for e_march
|
||||
*/
|
||||
if (preg_match('/^BENEFATTR/', $p_tag) == 1)
|
||||
{
|
||||
$qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
|
||||
// Retrieve f_id
|
||||
$r=$this->replace_special_tag($qcode,$p_tag);
|
||||
}
|
||||
if (preg_match('/^CUSTATTR/', $p_tag) == 1)
|
||||
{
|
||||
if ( isset($p_array['qcode_dest']) || isset($p_array['e_client']) )
|
||||
{
|
||||
$qcode=(isset($p_array['qcode_dest']))?$p_array['qcode_dest']:$p_array['e_client'];
|
||||
$r=$this->replace_special_tag($id,$p_tag);
|
||||
}
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
|
@ -1106,6 +1140,49 @@ class Document
|
|||
|
||||
|
||||
}
|
||||
/**
|
||||
*Replace a special tag *TAGxxxx with the value from fiche_detail, the xxxx
|
||||
* is the ad_value
|
||||
* @param $p_qcode qcode of the card
|
||||
* @param $p_tag tag to parse
|
||||
* @return the ad_value contained in fiche_detail or for the type "select" the
|
||||
* label
|
||||
*/
|
||||
function replace_special_tag($p_qcode, $p_tag)
|
||||
{
|
||||
// check if the march exists
|
||||
if ($qcode == "")
|
||||
return "";
|
||||
|
||||
$f = new Fiche($this->db);
|
||||
$found = $f->get_by_qcode($qcode, false);
|
||||
// if not found exit
|
||||
if ($found == 1)
|
||||
return "";
|
||||
|
||||
// get the ad_id
|
||||
$attr=preg_replace("/^.*ATTR/","",$p_tag);
|
||||
|
||||
if (isNumber($attr) == 0) return "";
|
||||
$ad_type=$this->db->get_value("select ad_type from attr_def where ad_id=$1",$attr);
|
||||
|
||||
// get ad_value
|
||||
$ad_value=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=$2",array($f->id,$attr));
|
||||
|
||||
// if ad_id is type select execute select and get value
|
||||
if ( $ad_type=="select")
|
||||
{
|
||||
$sql=$this->db->get_value("select ad_extra from attr_def where ad_id=$1",$attr);
|
||||
$array= $this->db->make_array($sql);
|
||||
for ($a=0;$a<count ($array);$a++)
|
||||
{
|
||||
if ($array[$a]['value']==$ad_value)
|
||||
return $array[$a]['label'];
|
||||
}
|
||||
|
||||
}
|
||||
// if ad_id is not type select get value
|
||||
return $ad_value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue