diff --git a/include/class/action_document_type_mtable.class.php b/include/class/action_document_type_mtable.class.php index f56b1f267..574d8ac29 100644 --- a/include/class/action_document_type_mtable.class.php +++ b/include/class/action_document_type_mtable.class.php @@ -80,6 +80,7 @@ class Action_Document_Type_MTable extends Manage_Table_SQL $this->other['contact_multiple']=$http->request("det_contact_mul", "string", 0); $this->other['make_invoice']=$http->request("make_invoice", "string", 0); $this->other['followup_comment']=$http->request("followup_comment", "string", 0); + $this->other['editable_description']=$http->request("editable_description", "string", 0); $this->other['enable_followup']=$http->request("enable_followup", "string", 0); $this->other['seq']=$http->request("seq", "string", 0); $this->other['select_option_operation']=$http->request("select_option_operation", "string", null); @@ -258,6 +259,12 @@ class Action_Document_Type_MTable extends Manage_Table_SQL on conflict on constraint document_option_un do update set do_enable=$3 ", ["contact_multiple", $object_sql->dt_id, $this->other['contact_multiple']]); + // Save editable description + $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3) + on conflict on constraint document_option_un + do update set do_enable=$3 ", ["editable_description", $object_sql->dt_id + , $this->other['editable_description']]); + // Save make invoice $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3) on conflict on constraint document_option_un diff --git a/include/class/document_option.class.php b/include/class/document_option.class.php index 388284b5c..30630b21d 100644 --- a/include/class/document_option.class.php +++ b/include/class/document_option.class.php @@ -144,5 +144,23 @@ class Document_Option [$p_document_type, 'followup_comment']); return $option_operation; } + + /** + * returns true if it is possible to edit the description , otherwise false + * + * @param int $p_document_type Document_Type.dt_id + * @return boolean + */ + static function is_enable_editable_description($p_document_type) + { + $return=false; + $cn=Dossier::connect(); + if ($cn->get_value("select do_enable from document_option where document_type_id=$1 and do_code = $2", + [$p_document_type, 'editable_description'])=='1') + { + $return=true; + } + return $return; + } } diff --git a/include/template/action_document_type_mtable_input.php b/include/template/action_document_type_mtable_input.php index 25f2426b5..b0a32899f 100644 --- a/include/template/action_document_type_mtable_input.php +++ b/include/template/action_document_type_mtable_input.php @@ -94,6 +94,17 @@ echo $i->input(); echo _("Création de facture"); ?> + +
  • + dt_id)) $description->set_check(1); + else $description->set_check(0); + + echo $description->input(); + echo _("Description modifiable"); + ?> +
  • input(); ?>

    -
    +
    + dt_id) == "ONE_EDIT") - { - if ( count($acomment)==0) { - echo $desc->input(); - } else { + // description + $description = new ITextarea("ag_description"); + $description->id="ag_description"; + //---------------------------------- Description ------------------------------------------------------------------- + if ( count($acomment)> 0) { + $editable_description = Document_Option::is_enable_editable_description($this->dt_id); + if ( $editable_description == true){ + echo h2(_("Description")); + $itDescription=new ITextarea("ag_description"); + $itDescription->style='class="input_text field_follow_up" style="height:21rem;width:98%"'; + + $ag_description_id= $acomment[0]['agc_id']; + $itDescription->value=$acomment[0]['agc_comment']; + $itDescription->id="ag_description"; + + // One editable comment is available + $editable_description=new Inplace_Edit($itDescription); + $editable_description->add_json_param("op", "followup_comment_oneedit"); + $editable_description->add_json_param("agc_id", $ag_description_id); + $editable_description->add_json_param("ag_id", $ag_id); + $editable_description->add_json_param("gDossier", Dossier::id()); + $editable_description->set_callback("ajax_misc.php"); + + echo $editable_description->input(); + } + elseif ($p_view == 'READ' || $editable_description == false) + { + echo h2(_("Description")); + echo '
    ';
    -            echo h($acomment[0]['agc_comment']);
    -            echo '
    '; - + echo h($acomment[0]['agc_comment']); + echo ''; + } + } else { + echo h2(_("Description")); + echo $desc->input(); + } + + //---------------------------------- Comment ----------------------------------------------------------------------- + + if ( Document_Option::can_add_comment($ag_id) && + Document_Option::option_comment($this->dt_id) == "ONE_EDIT" ) + { + if (count($acomment) > 1 && $p_view != 'READ') { + echo h2(_("Commentaire")); $comment=new ITextarea("ag_comment_edit"); - $comment->style='class="input_text field_follow_up" style="height:21rem"'; - + $comment->style='class="input_text field_follow_up" style="height:21rem;width:98%"'; + $ag_comment_id= (count($acomment) > 1)?$acomment[1]['agc_id']:-1; $comment->value=(count($acomment) > 1 )?$acomment[1]['agc_comment']:''; $comment->id="ag_comment_edit"; @@ -269,16 +309,24 @@ function small(p_id_textarea){ $editable_comment->add_json_param("ag_id", $ag_id); $editable_comment->add_json_param("gDossier", Dossier::id()); $editable_comment->set_callback("ajax_misc.php"); - + echo '

    '; echo $editable_comment->input(); - + } else { + echo ''; + if ( $p_view == 'UPD' && Document_Option::can_add_comment($ag_id) && $add_comment) { + echo '

    '; + echo $desc->input(); + + } + echo '
    '; } - - - } elseif (Document_Option::can_add_comment($ag_id) + } + if ( Document_Option::can_add_comment($ag_id) && Document_Option::option_comment($this->dt_id) == "SOME_FIXED") { - for( $c=0;$c\1',$comment); + echo '

    '; echo $comment; - } -} -echo ''; -if ( Document_Option::can_add_comment($ag_id) && Document_Option::option_comment($this->dt_id) == "SOME_FIXED") { + } // end for + echo ''; + if ( $p_view == 'UPD' && Document_Option::can_add_comment($ag_id)) { + echo '

    '; echo $desc->input(); -} -echo '
    '; + } + echo '
    '; + } + + + ?> -dt_id) == "SOME_FIXED" ): ?> - -

    - value="+" onclick="enlarge('ag_comment');return false;"> - value="-" style="display:none" onclick="small('ag_comment');return false;"> -

    -
    ag_id > 0 && Document_Option::is_enable_operation_detail($this->dt_i
    - +

    - +

    + +