diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php index aa73b65a3..fe8834f2e 100644 --- a/include/ajax/ajax_card.php +++ b/include/ajax/ajax_card.php @@ -99,31 +99,9 @@ $extra=""; $http=new \HttpInput(); switch($op2) { - /* ------------------------------------------------------------ */ - /* Remove a attribut */ - /* ------------------------------------------------------------ */ -case 'rmfa': - if ($g_user->check_action(FICCAT)==0)exit(); - - ob_start(); - try - { - $ad_id= $http->get("ad_id","number"); - $cn->start(); - $fa=new Fiche_Attr($cn,$ad_id); - $fa->delete(); - $cn->commit(); - } - catch (Exception $e) - { - $cn->rollback(); - record_log($e->getMessage()); - record_log($e); - echo $e->getMessage(); - } - $html=ob_get_contents(); - ob_end_clean(); - break; + case 'attribute': + require_once "ajax/ajax_card_attribute.php"; + return ; /* ------------------------------------------------------------ */ /* Display card detail */ /* ------------------------------------------------------------ */ diff --git a/include/ajax/ajax_card_attribute.php b/include/ajax/ajax_card_attribute.php new file mode 100644 index 000000000..feedef07b --- /dev/null +++ b/include/ajax/ajax_card_attribute.php @@ -0,0 +1,102 @@ + + +/** + * @file + * @brief answer to card_attr_inc.php + */ +global $g_user; +// security +$g_user->can_request("CFGATCARD"); +require_once NOALYSS_INCLUDE."/lib/inplace_switch.class.php"; +require_once NOALYSS_INCLUDE.'/class/card_attribut_mtable.class.php'; + +$http=new HttpInput(); + +try +{ + $action=$http->request("action", "string"); +} +catch (Exception $ex) +{ + record_log("ACA01".$ex->getMessage().$ex->getTraceAsString()); +} + +if ($action=="enable_search") +{ + $value=$http->request("value"); + $ad_id=$http->request("ad_id"); + $name=$http->request("name"); + if ($value==1) + { + $cn->exec_sql("update attr_def set ad_search_followup=0 where ad_id=$1", [$ad_id]); + $value=0; + } + else + { + $cn->exec_sql("update attr_def set ad_search_followup=1 where ad_id=$1", [$ad_id]); + $value=1; + } + $ic=new Inplace_Switch($name, $value); + $ic->set_callback("ajax_misc.php"); + $ic->add_json_param("op", "card"); + $ic->add_json_param("gDossier", Dossier::id()); + $ic->add_json_param("op2", "attribute"); + $ic->add_json_param("action", "enable_search"); + $ic->add_json_param("ad_id", $ad_id); + $ic->add_json_param("ctl", $ad_id); + echo $ic->input(); +} +else +{ + $obj=new Fiche_Attr($cn); + $mtable=new Card_Attribut_MTable($obj); + $mtable->add_json_param("op", "card"); + $mtable->add_json_param("op2", "attribute"); + $mtable->set_callback("ajax_misc.php"); + $mtable->set_object_name($http->request("ctl")); + $ad_id=$http->request("p_id"); + $mtable->get_table()->set_parameter("id", $ad_id); + switch ($action) + { + case "input": + $mtable->set_pk($ad_id); + $mtable->send_header(); + echo $mtable->ajax_input()->saveXML(); + + break; + case "save": + $mtable->set_pk($http->request("p_id")); + $mtable->send_header(); + echo $mtable->ajax_save()->saveXML(); + + + break; + case "delete": + $mtable->set_pk($http->request("p_id")); + $mtable->send_header(); + echo $mtable->ajax_delete()->saveXML(); + break; + default: + break; + } +} +?> diff --git a/include/card_attr.inc.php b/include/card_attr.inc.php index fa8bcae8d..c098f7b0b 100644 --- a/include/card_attr.inc.php +++ b/include/card_attr.inc.php @@ -20,146 +20,18 @@ // Copyright Author Dany De Bontridder danydb@aevalys.eu /*!\file - * \brief Manage the attributs + * \brief Manage the attributs ,CFGATCARD */ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); -require_once NOALYSS_INCLUDE.'/class/fiche_attr.class.php'; -global $http; - - -$fa=new Fiche_Attr($cn); - -///////////////////////////////////////////////////////////////////////////// -// If data are post we save them first -///////////////////////////////////////////////////////////////////////////// -if ( isset($_POST['save'])) -{ - try - { - $ad_id=$http->post('ad_id'); - $ad_text=$http->post('desc'); - $ad_type=$http->post('type'); - $ad_size=$http->post('size'); - $ad_extra=$http->post('extra'); - $cn->start(); - for ($e=0;$eset_parameter('id',$ad_id[$e]); - $fa->set_parameter('desc',$ad_text[$e]); - $fa->set_parameter('type',$ad_type[$e]); - $fa->set_parameter('size',$ad_size[$e]); - $fa->set_parameter('extra',$ad_extra[$e]); - if ( trim($ad_text[$e])!='' && trim($ad_type[$e])!='') - $fa->save(); - } - $cn->commit(); - } - catch (Exception $e) - { - record_log($e); - alert($e->getMessage()); - $cn->rollback(); - } - -} -/* show list of existing */ -$gDossier=dossier::id(); -$array=$fa->seek(); - -$select_type=new ISelect('type[]'); -$select_type->table=0; -$desc=new IText('desc[]'); -$desc->size=50; -$size=new INum('size[]'); -$size->size=5; -$extra=new IText('extra[]'); - -$select_type->value=array( - array('value'=>'text','label'=>_('Texte')), - array('value'=>'numeric','label'=>_('Nombre')), - array('value'=>'date','label'=>_('Date')), - array('value'=>'zone','label'=>_('Zone de texte')), - array('value'=>'poste','label'=>_('Poste Comptable')), - array('value'=>'card','label'=>_('Fiche')), - array('value'=>'select','label'=>_('Selection')) - ); +require_once NOALYSS_INCLUDE.'/class/card_attribut_mtable.class.php'; +$obj=new Fiche_Attr($cn); +$mtable=new Card_Attribut_MTable($obj); +$mtable->add_json_param("op", "card"); +$mtable->add_json_param("op2", "attribute"); +$mtable->set_callback("ajax_misc.php"); +$mtable->create_js_script(); echo '
'; -echo '
'; - -echo HtmlInput::hidden('sa','fat'); -echo HtmlInput::hidden('p_action','divers'); -echo ''; -echo ''; -echo th(_("id")); -echo th(_("Description")); -echo th(_("Type")); -echo th(_("Taille")); -echo th(_("Paramètre")); -echo ''; -for ($e=0;$eget_parameter('id')).$row->get_parameter('id')); - $select_type->selected=$row->get_parameter('type'); - $desc->value=$row->get_parameter('desc'); - $size->value=$row->get_parameter('size'); - $extra->value=$row->get_parameter('extra'); - $remove=new IButton('rmfa'.$e); - $remove->label=_('Effacer'); - if ( $row->get_parameter('id')>= 9000) - { - $select_type->readOnly=false; - $desc->readOnly=false; - $size->readOnly=false; - $extra->readOnly=false; - - $desc->style=' class="input_text" '; - $r.=td($desc->input()); - $r.=td($select_type->input()); - $r.=td($size->input()); - $r.=td($extra->input()); - - $remove->javascript=sprintf('confirm_box(\'tb_rmfa\',\'Vous confirmez ?\',function() { removeCardAttribut(%d,%d,\'tb_rmfa\',$(\'rmfa%d\') );})', - $row->get_parameter('id'),$gDossier,$e); - $msg=''._("Attention : effacera les données qui y sont liées").' '; - $r.=td($remove->input().$msg); - } - else - { - $select_type->readOnly=true; - $desc->readOnly=true; - $size->readOnly=true; - $extra->readOnly=true; - - $r.=td($desc->input().HtmlInput::hidden('type[]','')); - $r.=td($select_type->input()); - $r.=td($size->input()); - $r.=td($extra->input()); - $r.=td(""); - } - - - - - echo tr($r); - -} -$desc->readOnly=false; -$select_type->readOnly=false; -$size->readOnly=false; -$extra->readOnly=false; -$desc->value=''; -$select_type->selected=-1; -$r=td(_("Nouvel attribut").HtmlInput::hidden('ad_id[]','0'),'class="highlight"'); -$r.=td($desc->input()); -$r.=td($select_type->input()); -$r.=td($size->input()); -$r.=td($extra->input()); -echo tr($r); - -echo '
'; -echo HtmlInput::submit('save',_('Sauver')); -echo '
'; +echo $mtable->display_table("order by ad_text"); echo '
'; + diff --git a/include/class/card_attribut_mtable.class.php b/include/class/card_attribut_mtable.class.php new file mode 100644 index 000000000..563838499 --- /dev/null +++ b/include/class/card_attribut_mtable.class.php @@ -0,0 +1,201 @@ + + +/** + * @file + * @brief manage the table attr_def + * @see card_attr.inc.php + */ +require_once NOALYSS_INCLUDE."/class/fiche_attr.class.php"; +require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php"; +require_once NOALYSS_INCLUDE."/lib/inplace_switch.class.php"; + +class Card_Attribut_MTable extends Manage_Table_SQL +{ + + function __construct(\Data_SQL $p_table) + { + parent::__construct($p_table); + $this->set_property_visible("ad_id", FALSE); + $this->set_property_updatable("ad_id", FALSE); + $this->set_col_label("ad_text", _("Nom")); + $this->set_col_label("ad_type", _("Type")); + $this->set_col_label('ad_size', _("Taille")); + $this->set_col_label("ad_extra", _("Option sup.")); + $this->set_col_label("ad_search_followup", _("Recherche suivi")); + + $this->set_col_type("ad_search_followup", "custom"); + $this->set_col_type("ad_text", "custom"); + $this->set_col_type("ad_size", "numeric"); + $this->set_col_type("ad_extra", "text"); + $this->set_col_type("ad_type", "select", + array( + ["value"=>"text", "label"=>_("Texte")], + ["value"=>"date", "label"=>_("Date")], + ["value"=>"numeric", "label"=>_("Nombre")], + ["value"=>"select", "label"=>_("Choix")], + ["value"=>"card", "label"=>_("Fiche")], + ["value"=>"zone", "label"=>_("Zone de texte")], + ["value"=>"poste", "label"=>_("Poste comptable")] + )); + $this->set_col_tips("ad_search_followup", 77); + // to prevent a call to this function for each row + $this->dossier_id=Dossier::id(); + } + + /** + * Display row of table attr_def + * @param array $row + */ + function display_row($row) + { + tracedebug("card_attribute.log", $row); + if ($row['ad_id']>=9000) + { + $this->set_delete_row(TRUE); + $this->set_update_row(TRUE); + } + else + { + $this->set_delete_row(FALSE); + $this->set_update_row(FALSE); + } + + parent::display_row($row); + } + + /** + * For the type custom , we can call a function to display properly the value + * @param $p_key string key name + * @param $p_value string value + * @see input_custom + * @see set_type + * @note must return a string which will be in surrounded by td in the function display_row + * @return string + */ + function display_row_custom($p_key, $p_value, $p_id=0) + { + if ($p_key=="ad_search_followup") + { + $ic=new Inplace_Switch(uniqid("search_follow_up"), $p_value); + $ic->set_callback("ajax_misc.php"); + $ic->add_json_param("op", "card"); + $ic->add_json_param("gDossier", $this->dossier_id); + $ic->add_json_param("op2", "attribute"); + $ic->add_json_param("action", "enable_search"); + $ic->add_json_param("ad_id", $p_id); + $ic->add_json_param("ctl", $p_id); + $ret=$ic->input(); + + return $ret; + } + if ($p_key == "ad_text"){ + return $p_value; + } + return; + } + + /** + * For the type custom , we can call a function to display properly the value + * @param $p_key string key name + * @param $p_value string value + * @see input_custom + * @see set_type + * @note must return a string which will be in surrounded by td in the function display_row + * @return string + */ + function input_custom($p_key, $p_value) + { + if ($p_key=="ad_search_followup") + { + $p_id=$this->get_table()->get("ad_id"); + $ic=new ISelect("ad_search_followup", $p_value); + $ic->value=array(["value"=>0, "label"=>_("Non")], + ["value"=>0, "label"=>_("Oui")] + ); + $ic->set_value($p_value); + echo $ic->input(); + } + /** + * Bug in firefox if id=ad_text , the widget is not displaid + */ + if ( $p_key == "ad_text") + { + $text=new IText("ad_text",$p_value); + $text->id=uniqid(); + echo $text->input(); + } + echo ""; + return; + } + + function check() + { + $nb_error=0; + $object_sql=$this->get_table(); + + if ($object_sql->get("ad_id")<9000 && $object_sql->get("ad_id")!=-1) + { + $this->set_error("ad_id",_("Bloqué")); + return false; + } + + // Duplicate + $count="select count(*) + from attr_def as ad1 + where + upper(trim(ad1.ad_text)) = upper(trim($1)) + and ad1.ad_id != $2 + "; + $count_duplicate=$object_sql->cn->get_value($count, [$object_sql->ad_text, $object_sql->ad_id]); + if ($count_duplicate>0) + { + $this->set_error("ad_text", _("Doublon")); + $nb_error++; + } + + // Name empty + if (trim($object_sql->ad_text)=="") + { + $this->set_error("ad_text", _("Description ne peut pas être vide")); + $nb_error++; + } + // select protect + + + if ($nb_error>0) + return false; + return true; + } + + function delete() { + $object_sql=$this->get_table(); + $db=$object_sql->cn; + try { + $db->start(); + $object_sql=$this->get_table()->delete(); + $db->commit(); + } catch (Exception $ex) { + $db->rollback(); + throw new Exception (_("Effacement bloqué : attribut utilisé")); + } + } +} diff --git a/include/class/fiche_attr.class.php b/include/class/fiche_attr.class.php index c764731e5..7133a0a05 100644 --- a/include/class/fiche_attr.class.php +++ b/include/class/fiche_attr.class.php @@ -1,286 +1,165 @@ column_name,"email"=>"column_name_email","val3"=>0); */ - protected $variable=array("id"=>"ad_id","desc"=>"ad_text","type"=>"ad_type","size"=>"ad_size","extra"=>"ad_extra"); - function __construct ($p_cn,$p_id=0) + function __construct($p_cn, $p_id=0) { - $this->cn=$p_cn; - if ( $p_id == 0 ) - { - /* Initialize an empty object */ - foreach ($this->variable as $key=>$value) $this->$value=''; - } - else - { - /* load it */ - $this->ad_id=$p_id; - $this->load(); - } + parent::__construct($p_cn, $p_id); } + public function get_parameter($p_string) { - if ( array_key_exists($p_string,$this->variable) ) - { - $idx=$this->variable[$p_string]; - return $this->$idx; - } - else - throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant'); + return $this->getp($p_string); } - public function set_parameter($p_string,$p_value) + + public function set_parameter($p_string, $p_value) { - if ( array_key_exists($p_string,$this->variable) ) - { - $idx=$this->variable[$p_string]; - $this->$idx=$p_value; - } - else - throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant'); - } - public function get_info() - { - return var_export($this,true); + $this->setp($p_string, $p_value); } + public function verify() { // Verify that the elt we want to add is correct /* verify only the datatype */ - if ( strlen(trim($this->ad_text))==0) - throw new Exception('La description ne peut pas être vide',1); - if ( strlen(trim($this->ad_type))==0) - throw new Exception('Le type ne peut pas être vide',1); + if (strlen(trim($this->ad_text))==0) + throw new Exception('La description ne peut pas être vide', 1); + if (strlen(trim($this->ad_type))==0) + throw new Exception('Le type ne peut pas être vide', 1); $this->ad_type=strtolower($this->ad_type); - if ( in_array($this->ad_type,array('date','text','numeric','zone','poste','card','select'))==false) - throw new Exception('Le type doit être text, numeric,poste, card, select ou date',1); - if ( trim($this->ad_size)=='' || isNumber($this->ad_size)==0||$this->ad_size>22) + if (in_array($this->ad_type, array('date', 'text', 'numeric', 'zone', 'poste', 'card', 'select'))==false) + throw new Exception('Le type doit être text, numeric,poste, card, select ou date', 1); + if (trim($this->ad_size)==''||isNumber($this->ad_size)==0||$this->ad_size>22) { switch ($this->ad_type) { - case 'text': + case 'text': $this->ad_size=22; - break; - case 'numeric': - $this->ad_size=9; - break; - case 'date': - $this->ad_size=8; - break; - case 'zone': - $this->ad_size=22; - break; + break; + case 'numeric': + $this->ad_size=9; + break; + case 'date': + $this->ad_size=8; + break; + case 'zone': + $this->ad_size=22; + break; - default: - $this->ad_size=22; + default: + $this->ad_size=22; } } - if ( $this->ad_type == 'numeric' ) { - $this->ad_extra=(trim($this->ad_extra)=='')?'2':$this->ad_extra; - if (isNumber($this->ad_extra) == 0) throw new Exception ("La précision doit être un chiffre"); - - } - if ( $this->ad_type == 'select') + if ($this->ad_type=='numeric') { - if (trim($this->ad_extra)=="") throw new Exception ("La requête SQL est vide "); - if ( preg_match('/^\h*select/i',$this->ad_extra) == 0) throw new Exception ("La requête SQL doit commencer par SELECT "); - try{ - - $this->cn->exec_sql($this->ad_extra); - }catch (Exception $e) - { - record_log($e); - throw new Exception ("La requête SQL ".h($this->ad_extra)." est invalide "); - } + $this->ad_extra=(trim($this->ad_extra)=='')?'2':$this->ad_extra; + if (isNumber($this->ad_extra)==0) + throw new Exception("La précision doit être un chiffre"); } - } - public function save() - { - - /* please adapt */ - if ( $this->ad_id == 0 ) - $this->insert(); - else - $this->update(); - } - /** - *@brief retrieve array of object thanks a condition - *@param $cond condition (where clause) - *@param $p_array array for the SQL stmt - *@see Database::get_array - *@return an empty array if nothing is found - */ - public function seek($cond='',$p_array=null) - { - if ( $cond != '') - $sql="select * from attr_def where $cond order by ad_text"; - else - $sql="select * from attr_def order by ad_text"; - - $aobj=array(); - $array= $this->cn->get_array($sql,$p_array); - // map each row in a object - $size=$this->cn->count(); - if ( $size == 0 ) return $aobj; - for ($i=0;$i<$size;$i++) + if ($this->ad_type=='select') { - $oobj=new Fiche_Attr ($this->cn); - foreach ($array[$i] as $idx=>$value) + if (trim($this->ad_extra)=="") + throw new Exception("La requête SQL est vide "); + if (preg_match('/^\h*select/i', $this->ad_extra)==0) + throw new Exception("La requête SQL doit commencer par SELECT "); + try { - $oobj->$idx=$value; + + $this->cn->exec_sql($this->ad_extra); + } + catch (Exception $e) + { + record_log($e); + throw new Exception("La requête SQL ".h($this->ad_extra)." est invalide "); } - $aobj[]=clone $oobj; } - return $aobj; } - public function insert() - { - try{ - $this->verify(); - /* please adapt */ - $sql="insert into attr_def(ad_text - ,ad_type,ad_size,ad_extra - ) values ($1 - ,$2,$3,$4 - ) returning ad_id"; - $this->ad_id=$this->cn->get_value( - $sql, - array( $this->ad_text,$this->ad_type,$this->ad_size,$this->ad_extra - ) - ); - } catch (Exception $e) - { - record_log($e); - throw $e; - } - - } public function update() { try { - $this->verify(); - if ( $this->ad_id < 9000) return; - /* please adapt */ - $sql=" update attr_def set ad_text = $1 - ,ad_type = $2,ad_size=$4,ad_extra=$5 - where ad_id= $3"; - $res=$this->cn->exec_sql( - $sql, - array($this->ad_text - ,$this->ad_type - ,$this->ad_id,$this->ad_size,$this->ad_extra) - ); - }catch (Exception $e) + $this->verify(); + if ($this->ad_id<9000) + return; + /* please adapt */ + parent::update(); + } + catch (Exception $e) { - record_log($e); + record_log($e); throw $e; } - - - } - /** - *@brief load a object - *@return 0 on success -1 the object is not found - */ - public function load() - { - - $sql="select ad_text - ,ad_type,ad_size,ad_extra - from attr_def where ad_id=$1"; - /* please adapt */ - $res=$this->cn->get_array( - $sql, - array($this->ad_id) - ); - - if ( count($res) == 0 ) - { - /* Initialize an empty object */ - foreach ($this->variable as $key=>$value) $this->$key=''; - - return -1; - } - foreach ($res[0] as $idx=>$value) - { - $this->$idx=$value; - } - return 0; } public function delete() { - if ($this->ad_id < 9000) return; - $sql=$this->cn->exec_sql("delete from fiche_detail where ad_id=$1 ", - array($this->ad_id)); + if ($this->ad_id<9000) + return; + $sql=$this->cn->exec_sql("delete from fiche_detail where ad_id=$1 ", array($this->ad_id)); - $sql="delete from jnt_fic_attr where ad_id=$1"; - $res=$this->cn->exec_sql($sql,array($this->ad_id)); + $sql="delete from jnt_fic_attr where ad_id=$1"; + $res=$this->cn->exec_sql($sql, array($this->ad_id)); $sql="delete from attr_def where ad_id=$1"; - $res=$this->cn->exec_sql($sql,array($this->ad_id)); - + $res=$this->cn->exec_sql($sql, array($this->ad_id)); } - /** - * Unit test for the class + + /* ! + * @brief used with a usort function, to sort an array of Attribut on the attribut_id (ad_id) */ - static function test_me() + + static function sort_by_id($o1, $o2) { - $cn=new Database(25); - $cn->start(); - echo h2info('Test object vide'); - $obj=new Fiche_Attr($cn); - var_dump($obj); - - echo h2info('Test object NON vide'); - $obj->set_parameter('j_id',3); - $obj->load(); - var_dump($obj); - - echo h2info('Update'); - $obj->set_parameter('j_qcode','NOUVEAU CODE'); - $obj->save(); - $obj->load(); - var_dump($obj); - - echo h2info('Insert'); - $obj->set_parameter('j_id',0); - $obj->save(); - $obj->load(); - var_dump($obj); - - echo h2info('Delete'); - $obj->delete(); - echo (($obj->load()==0)?'Trouve':'non trouve'); - var_dump($obj); - $cn->rollback(); - - } - /*! - *@brief used with a usort function, to sort an array of Attribut on the attribut_id (ad_id) - */ - static function sort_by_id($o1,$o2) - { - if ( $o1->ad_id > $o2->ad_id ) return 1; - if ( $o1->ad_id == $o2->ad_id ) return 0; + if ($o1->ad_id>$o2->ad_id) + return 1; + if ($o1->ad_id==$o2->ad_id) + return 0; return -1; } + public function save() + { + /* please adapt */ + if ($this->ad_id < 1) + { + $this->ad_id=-1; + $this->insert(); + } + else + $this->update(); + } + public function to_array($prefix="") + { + + $array=array(); + foreach ($this->name as $key=> $value) + { + $nkey=$prefix.$value; + $array[$nkey]=$this->$value; +// $nkey=$prefix.$key; +// $array[$nkey]=$this->$value; +// + } + tracedebug("card_attribute.log",$array); + return $array; + } } + //Fiche_Attr::test_me(); diff --git a/include/lib/manage_table_sql.class.php b/include/lib/manage_table_sql.class.php index 116d61ff3..b0e8cfa1f 100644 --- a/include/lib/manage_table_sql.class.php +++ b/include/lib/manage_table_sql.class.php @@ -103,7 +103,7 @@ class Manage_Table_SQL foreach ($this->table->name as $key=> $value) { - $this->a_label_displaid[$value]=$value; + $this->a_label_displaid[$value]=$key; $this->a_order[$order]=$value; $this->a_prop[$value]=self::UPDATABLE|self::VISIBLE; $this->a_type[$value]=$this->table->type[$value]; @@ -833,9 +833,10 @@ function check() */ function display_row($p_row) { - + + $pk_id=$p_row[$this->table->primary_key]; printf('', $this->object_name, - $p_row[$this->table->primary_key]) + $pk_id) ; if ($this->icon_mod=="left") @@ -847,10 +848,11 @@ function check() for ($i=0; $i<$nb_order; $i++) { $v=$this->a_order[$i]; + if ($i==0&&$this->icon_mod=="first"&&$this->can_update_row()) { $js=sprintf("onclick=\"%s.input('%s','%s');\"", $this->object_name, - $p_row[$this->table->primary_key], $this->object_name); + $pk_id, $this->object_name); $td=($i == $this->col_sort ) ? sprintf('',$p_row[$v]):""; echo $td.HtmlInput::anchor($p_row[$v], "", $js).''; } @@ -878,7 +880,7 @@ function check() $nb_search=(is_array($array_to_search))?count($array_to_search):0; $found=FALSE; for ( $e=0;$e< $nb_search;$e++) { - if (isset ($array_to_search[$e]['value']) && $array_to_search[$e]['value']==$value ) { + if (isset ($array_to_search[$e]['value']) && $array_to_search[$e]['value']==$value ) { $found=TRUE; echo td($array_to_search[$e]['label']); } @@ -891,7 +893,7 @@ function check() } elseif ($this->get_col_type($v)=="custom") { // For custom col - echo td($this->display_row_custom($v,$p_row[$v])); + echo td($this->display_row_custom($v,$p_row[$v],$pk_id)); } else { echo td($p_row[$v]); @@ -911,12 +913,13 @@ function check() * For the type custom , we can call a function to display properly the value * @param $p_key string key name * @param $p_value string value + * @param int $p_id id of the row (optional default 0) * @see input_custom * @see set_type * @note must return a string which will be in surrounded by td in the function display_row * @return string */ - function display_row_custom($p_key,$p_value) { + function display_row_custom($p_key,$p_value,$p_id=0) { return $p_value; } /** diff --git a/include/lib/message_javascript.php b/include/lib/message_javascript.php index e9b9d1ebf..cebdf2245 100644 --- a/include/lib/message_javascript.php +++ b/include/lib/message_javascript.php @@ -107,4 +107,5 @@ content[73]=""; content[75]=""; content[76]=""; +content[77]=""; diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 54c62c600..6ee0d7ed2 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,2 +1,7 @@ ALTER TABLE public.document_option ADD do_option varchar NULL; COMMENT ON COLUMN public.document_option.do_option IS 'Option for the detail'; + +alter table attr_def add column ad_search_followup int; +alter table attr_def alter column ad_search_followup set default 1; +update attr_def set ad_search_followup=1; +comment on column attr_def.ad_search_followup is '1 : search available from followup , 0 : search not available in followup'