Suivi : description modifiable

This commit is contained in:
sparkyx 2020-10-31 00:20:50 +01:00
parent 6952f87934
commit 0f4b05ab46
5 changed files with 117 additions and 35 deletions

View file

@ -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

View file

@ -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;
}
}

View file

@ -94,6 +94,17 @@ echo $i->input();
echo _("Création de facture");
?>
</li>
<li>
<?php
$description=new ICheckBox("editable_description",1);
if ( Document_Option::is_enable_editable_description($table->dt_id)) $description->set_check(1);
else $description->set_check(0);
echo $description->input();
echo _("Description modifiable");
?>
</li>
<li>
<?php
$i=new ICheckBox("followup_comment",1);

View file

@ -242,22 +242,62 @@ function small(p_id_textarea){
<?php echo $title->input();
?>
</p>
<div style="margin-left:10px;">
<div>
<?php
/**********************************************************************************************************************
* Start BLOCK Comment and description
**********************************************************************************************************************/
?>
<?php
$style_enl='style="display:inline"';$style_small='style="display:none"';
if ( Document_Option::can_add_comment($ag_id)
&& Document_Option::option_comment($this->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 '<pre class="field_follow_up">';
echo h($acomment[0]['agc_comment']);
echo '</pre>';
echo h($acomment[0]['agc_comment']);
echo '</pre>';
}
} 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 '<p></p>';
echo $editable_comment->input();
} else {
echo '<span class="noprint">';
if ( $p_view == 'UPD' && Document_Option::can_add_comment($ag_id) && $add_comment) {
echo '<p></p>';
echo $desc->input();
}
echo '</span>';
}
} 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<count($acomment);$c++){
echo h2(_("Commentaire"));
for( $c=1;$c<count($acomment);$c++){
if ($c == 0) { $m_desc=_('Description');}
else
{ $m_desc=_('Commentaire');}
@ -309,26 +357,22 @@ function small(p_id_textarea){
}
$comment=preg_replace('/#([0-9]+)/','<a class="line" href="javascript:void()" onclick="view_action(\1,'.
Dossier::id().',0)" >\1</a>',$comment);
echo '<p></p>';
echo $comment;
}
}
echo '<span class="noprint">';
if ( Document_Option::can_add_comment($ag_id) && Document_Option::option_comment($this->dt_id) == "SOME_FIXED") {
} // end for
echo '<span class="noprint">';
if ( $p_view == 'UPD' && Document_Option::can_add_comment($ag_id)) {
echo '<p></p>';
echo $desc->input();
}
echo '</span>';
}
echo '</span>';
}
?>
<?php if ($p_view != "READ"
&& Document_Option::can_add_comment($ag_id)
&& Document_Option::option_comment($this->dt_id) == "SOME_FIXED" ): ?>
<p class="noprint">
<input type="button" id="bt_enlarge" <?php echo $style_enl?> value="+" onclick="enlarge('ag_comment');return false;">
<input type="button" id="bt_small" <?php echo $style_small?> value="-" style="display:none" onclick="small('ag_comment');return false;">
</p>
<?php endif; ?>
</div>
</div>
<?php
@ -353,9 +397,9 @@ if ( $this->ag_id > 0 && Document_Option::is_enable_operation_detail($this->dt_i
<div class="myfieldset" id="div_action_attached_doc">
<legend>
<h2>
<?php echo _('Pièces attachées')?>
</legend>
</h2>
<div class="noprint">
<?php
/**********************************************************************************************************************

View file

@ -41,6 +41,8 @@ $option_detail= Document_Option::option_operation_detail($document_type);
$menu=new Default_Menu();
?>
<div id="follow_up_detail">
<?php echo h2(_("Détail opération")) ?>
<?php echo HtmlInput::hidden("nb_item", $article_count); ?>
<table style="width:100%" id="sold_item">