diff --git a/include/class_document.php b/include/class_document.php index f9dc57c4c..1d15af8f2 100644 --- a/include/class_document.php +++ b/include/class_document.php @@ -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;$ad_lob)) != 0) { $d_id = new IHidden(); - $doc_ref = "

Document " . $doc->a_ref() . '

'; + $doc_ref = "

Document " . $doc->anchor() . '

'; $doc_ref.=$h2->input() . $d_id->input('d_id', $this->d_id); } } diff --git a/sql/upgrade.sql b/sql/upgrade.sql index cd8690d11..8d681f36f 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -261,4 +261,7 @@ COMMENT ON TABLE user_sec_repository IS 'Available profile for user'; COMMENT ON COLUMN user_sec_repository.ur_id IS 'pk'; COMMENT ON COLUMN user_sec_repository.p_id IS 'fk to profile'; COMMENT ON COLUMN user_sec_repository.r_id IS 'fk to stock_repository'; -COMMENT ON COLUMN user_sec_repository.ur_right IS 'Type of right : R for readonly W for write'; \ No newline at end of file +COMMENT ON COLUMN user_sec_repository.ur_right IS 'Type of right : R for readonly W for write'; + +alter table user_sec_repository add constraint user_sec_repository_r_id_p_id_u unique (r_id,p_id); +alter table user_sec_action_profile add constraint user_sec_action_profile_p_id_p_granted_u unique (p_id,p_granted); \ No newline at end of file