Task #2332: Suivi : ajout fichier lié aux commentaires
This commit is contained in:
parent
2f0334d9a4
commit
6e627baa45
5 changed files with 71 additions and 32 deletions
|
|
@ -322,33 +322,32 @@ if ($sub_action == "save_action_st2")
|
|||
{
|
||||
$act = new Follow_Up($cn);
|
||||
$act->fromArray($_POST);
|
||||
try {
|
||||
$act->d_id = 0;
|
||||
$act->ag_id=$http->request("ag_id","number");
|
||||
$act->md_id = $http->post('gen_doc','number',0);
|
||||
try {
|
||||
$act->d_id = 0;
|
||||
$act->ag_id = $http->request("ag_id", "number");
|
||||
$act->md_id = $http->post('gen_doc', 'number', 0);
|
||||
|
||||
$act->verify();
|
||||
$sup_parameter=HtmlInput::array_to_string(["sc","sb","f_id","qcode"], $_REQUEST,"&");
|
||||
// insert into action_gestion
|
||||
$act->update();
|
||||
|
||||
$url = "?sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get()."&ac=".$http->request("ac").
|
||||
$sup_parameter;
|
||||
echo '<p><a class="mtitle" href="' . $url . '">' . hb(_('Action Sauvée').' : ' . $act->ag_ref) . '</a></p>';
|
||||
$act->verify();
|
||||
$sup_parameter = HtmlInput::array_to_string(["sc", "sb", "f_id", "qcode"], $_REQUEST, "&");
|
||||
// insert into action_gestion
|
||||
$act->update();
|
||||
|
||||
Follow_Up::show_action_list($cn,$base);
|
||||
$url = "?sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get()."&ac=".$http->request("ac").
|
||||
$sup_parameter;
|
||||
echo '<p><a class="mtitle" href="' . $url . '">' . hb(_('Action Sauvée').' : ' . $act->ag_ref) . '</a></p>';
|
||||
} catch (Exception $e)
|
||||
{
|
||||
echo '<span class="notice">';
|
||||
echo _("Erreur")." ".$e->getMessage();
|
||||
echo '</span>';
|
||||
$sub_action="add_action";
|
||||
$error_id=$e->getCode();
|
||||
record_log($e);
|
||||
}
|
||||
$url = "?sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get() . "&ac=" . $http->request("ac") .
|
||||
$sup_parameter;
|
||||
echo '<p><a class="mtitle" href="' . $url . '">' . hb(_('Action Sauvée') . ' : ' . $act->ag_ref) . '</a></p>';
|
||||
|
||||
Follow_Up::show_action_list($cn, $base);
|
||||
$url = "?sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get() . "&ac=" . $http->request("ac") .
|
||||
$sup_parameter;
|
||||
echo '<p><a class="mtitle" href="' . $url . '">' . hb(_('Action Sauvée') . ' : ' . $act->ag_ref) . '</a></p>';
|
||||
} catch (Exception $e) {
|
||||
echo '<span class="notice">';
|
||||
echo _("Erreur") . " " . $e->getMessage();
|
||||
echo '</span>';
|
||||
$sub_action = "add_action";
|
||||
$error_id = $e->getCode();
|
||||
record_log($e);
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
// Add an action
|
||||
|
|
|
|||
|
|
@ -449,7 +449,10 @@ class Document
|
|||
/**
|
||||
* @brief upload a file into document
|
||||
* all the needed data are in $_FILES we don't increment the seq
|
||||
* @param $p_file : array containing by default $_FILES
|
||||
* $_FILES : array containing by default $_FILES
|
||||
* @param int $p_ag_id ACTION_GESTION.AG_ID
|
||||
* @param int $agc_id ACTION_GESTION_COMMENT.AGC_ID
|
||||
* @returns array of int DOCUMENT.D_ID (id of saved documents )
|
||||
*
|
||||
*/
|
||||
function upload($p_ag_id)
|
||||
|
|
@ -463,6 +466,7 @@ class Document
|
|||
// Start Transaction
|
||||
$this->db->start();
|
||||
$name=$_FILES['file_upload']['name'];
|
||||
$document_saved=array();
|
||||
for ($i=0; $i<sizeof($name); $i++)
|
||||
{
|
||||
$new_name=tempnam($_ENV['TMP'], 'doc_');
|
||||
|
|
@ -487,12 +491,13 @@ class Document
|
|||
$this->d_description=strip_tags($_POST['input_desc'][$i]);
|
||||
// insert into the table
|
||||
$sql="insert into document (ag_id, d_lob,d_filename,d_mimetype,d_number,d_description)"
|
||||
. " values ($1,$2,$3,$4,$5,$6)";
|
||||
$this->db->exec_sql($sql,
|
||||
. " values ($1,$2,$3,$4,$5,$6) returning d_id";
|
||||
$document_saved[]=$this->db->get_value($sql,
|
||||
array($p_ag_id, $this->d_lob, $this->d_filename, $this->d_mimetype, 1, $this->d_description));
|
||||
}
|
||||
} /* end for */
|
||||
$this->db->commit();
|
||||
return $document_saved;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -948,7 +948,7 @@ class Follow_Up
|
|||
}
|
||||
// upload documents
|
||||
$doc=new Document($this->db);
|
||||
$doc->upload($this->ag_id);
|
||||
$document_saved=$doc->upload($this->ag_id);
|
||||
|
||||
/* save action details */
|
||||
$http=new HttpInput();
|
||||
|
|
@ -966,8 +966,15 @@ class Follow_Up
|
|||
if (trim(strip_tags($this->ag_comment??"")) !='')
|
||||
{
|
||||
$notag_comment=strip_tags($this->ag_comment);
|
||||
$this->db->exec_sql("insert into action_gestion_comment (ag_id,tech_user,agc_comment,agc_comment_raw) values ($1,$2,$3,$4)"
|
||||
$action_comment_id=$this->db->get_value("insert into action_gestion_comment (ag_id,tech_user,agc_comment,agc_comment_raw) values ($1,$2,$3,$4) returning agc_id"
|
||||
, array($this->ag_id, $_SESSION[SESSION_KEY.'g_user'], $notag_comment,$this->ag_comment));
|
||||
// saved also documents for this comment
|
||||
if ( ! empty ($document_saved)) {
|
||||
foreach ($document_saved as $document_id) {
|
||||
$this->db->exec_sql("insert into action_comment_document(document_id,action_gestion_comment_id) values ($1,$2)",
|
||||
[$document_id,$action_comment_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trim(strip_tags($this->ag_description??""))!='' )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -377,6 +377,7 @@ function small(p_id_textarea){
|
|||
echo '</span>';
|
||||
}
|
||||
}
|
||||
$dossier_id=Dossier::id();
|
||||
if ( count($acomment) > 0
|
||||
&& Document_Option::can_add_comment($ag_id)
|
||||
&& Document_Option::option_comment($this->dt_id) == "SOME_FIXED")
|
||||
|
|
@ -395,7 +396,7 @@ function small(p_id_textarea){
|
|||
$js=Icon_Action::trash("accom".$acomment[$c]['agc_id'], $rmComment);
|
||||
$comment= h($m_desc.' '.$acomment[$c]['agc_id'].'('.$acomment[$c]['tech_user']." ".
|
||||
$acomment[$c]['str_agc_date'].')').$js.
|
||||
'<div class="nicEdit-main field_follow_up" style="margin-left:5%;margin-bottom:2rem;width:90%" id="com'.$acomment[$c]['agc_id'].'"> '.
|
||||
'<div class="nicEdit-main field_follow_up" style="margin-left:5%;margin-bottom:auto;width:90%" id="com'.$acomment[$c]['agc_id'].'"> '.
|
||||
" ".$acomment[$c]['agc_comment_raw'].'</div>'
|
||||
;
|
||||
|
||||
|
|
@ -414,10 +415,30 @@ function small(p_id_textarea){
|
|||
Dossier::id().',0)" >\1</a>',$comment);
|
||||
echo '<p></p>';
|
||||
echo $comment;
|
||||
// link to files to download
|
||||
$aFile=$this->db->get_array('select d_id,d_filename,d_description,d_mimetype
|
||||
from action_comment_document
|
||||
join document on (d_id=document_id) where action_gestion_comment_id=$1'
|
||||
, array( $acomment[$c]['agc_id']));
|
||||
if ( ! empty ($aFile)) {
|
||||
echo '<div style="left:10%">';
|
||||
echo _("Fichiers :");
|
||||
foreach ($aFile as $file)
|
||||
{
|
||||
$url="export.php?".http_build_query(array("act"=>'RAW:document'
|
||||
,"gDossier"=>$dossier_id
|
||||
,"d_id"=>$file["d_id"]));
|
||||
printf('<a class="print_line" href="%s">%s</a>',
|
||||
$url,h($file['d_filename']));
|
||||
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
} // end for
|
||||
if ( $has_description && $p_view == 'UPD' && Document_Option::can_add_comment($ag_id)) {
|
||||
echo '<span class="noprint">';
|
||||
echo '<div style="margin-left:5%">';
|
||||
echo '<div style="margin-left:5%;margin-top:2.5rem">';
|
||||
echo $desc->input();
|
||||
echo '</div>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
create table action_comment_document (acd_id bigint generated by default as identity primary key
|
||||
, document_id bigint references document(d_id) on delete cascade on update cascade,
|
||||
action_gestion_comment_id bigint references action_gestion_comment(agc_id) on delete cascade on update cascade);
|
||||
|
||||
alter table action_comment_document
|
||||
add constraint action_comment_document_un
|
||||
unique (document_id, action_gestion_comment_id);
|
||||
Loading…
Add table
Add a link
Reference in a new issue