Fix problem in the suivi courrier

This commit is contained in:
sparkyx 2006-10-07 14:11:48 +00:00
parent d4a0111cba
commit 8f7408ed54
3 changed files with 98 additions and 11 deletions

View file

@ -245,11 +245,59 @@ if ( $sub_action=='detail' )
echo $upload->Submit("save","Sauve");
echo $upload->Submit("add_action_here","Ajoute une action à celle-ci");
echo '</form>';
echo '<form action="commercial.php" method="post" >';
echo $upload->Submit("delete","Efface cette action");
echo '<input type="hidden" name="p_action" value="suivi_courrier">';
echo '<input type="hidden" name="sa" value="delete">';
echo '<input type="hidden" name="ag_id" value="'.$act->ag_id.'">';
echo '</form>';
echo $retour;
echo '</div>';
}
//-------------------------------------------------------------------------------
// Delete an action
if ( $sub_action == 'delete' )
{
// first the confirmation
if ( ! isset ($_POST['confirm_delete']))
{
echo '<div class="u_redcontent">';
echo '<A class="mtitle" HREF="commercial.php?p_action=suivi_courrier"><input type="button" value="Retour"></A>';
$act=new action($cn);
$act->ag_id=$_REQUEST['ag_id'];
echo $act->get();
$act->ag_comment=Decode($act->ag_comment);
echo JS_SEARCH_CARD;
echo $act->display('READ',false);
// display the form
echo '<form action="commercial.php?p_action=suivi_courrier" method="post" >';
echo '<input type="hidden" name="p_action" value="suivi_courrier">';
echo '<input type="hidden" name="sa" value="delete">';
echo '<input type="hidden" name="ag_id" value="'.$act->ag_id.'">';
$upload=new widget("text");
echo $upload->Submit("confirm_delete","Confirmer l'effacement");
echo '</form>';
echo '</div>';
}
else
{
// confirmed
$act=new action($cn);
$act->ag_id=$_REQUEST['ag_id'];
$act->remove();
$sub_action="list";
}
}
//--------------------------------------------------------------------------------
// Show a list of the action
if ( $sub_action == "list" )
@ -372,3 +420,4 @@ if ( $sub_action == "save_action_st3" )
//---------------------------------------------------------------------
echo "</div>";
?>

View file

@ -59,6 +59,7 @@ class action
* \enum $f_id_dest fiche id (From field )
* \enum $f_id_exp fiche id (to field)
* \enum $ag_ref_ag_id concern previous action
* \enum $ag_id pk of the table action_gestion
* \todo replace attribut from class document document by an object document
*/
@ -174,9 +175,12 @@ class action
$state->selected=$this->d_state;
$str_state=$state->IOValue();
} else {
$str_state=getDbValue($this->db,"select s_value from document_state where s_id=".$this->d_state);
$g=new widget("hidden");
$str_state.=$g->IOValue('d_state',$this->d_state);
$str_state="";
if ( strlen($this->d_state) != 0 )
{ $str_state=getDbValue($this->db,"select s_value from document_state where s_id=".$this->d_state);
$g=new widget("hidden");
$str_state.=$g->IOValue('d_state',$this->d_state);
}
}
// Retrieve the value if there is an attached doc
$doc_ref="";
@ -190,10 +194,14 @@ class action
{
$h2->readonly=($p_view=='NEW')?false:true;
$doc=new Document($this->db,$this->d_id);
$d_id=new widget("hidden");
$doc_ref="<p> Document ".$doc->a_ref().'</p>';
$doc_ref.=$h2->IOValue().$d_id->IOValue('d_id',$this->d_id);
$doc->get();
if ( strlen(trim($doc->d_lob)) != 0 )
{
$d_id=new widget("hidden");
$doc_ref="<p> Document ".$doc->a_ref().'</p>';
$doc_ref.=$h2->IOValue().$d_id->IOValue('d_id',$this->d_id);
}
}
@ -643,6 +651,7 @@ class action
*/
function myList($p_filter="",$p_search="")
{
/*!\todo idea to add a sort */
// for the sort
$sort="";
if ( isset($_GET['s'])){
@ -794,8 +803,13 @@ class action
$r.="<td>".$row['dt_value']."</td>";
$r.="<td>".$row['ag_ref']."</td>";
$r.="<td>".$ref."</td>";
$doc=new Document($this->db,$row['d_id']);
$r.="<td>".$doc->a_ref()."</td>";
if ( $row['d_id'] != '')
{
$doc=new Document($this->db,$row['d_id']);
$doc->get();
if ( strlen(trim($doc->d_lob)) != 0 )
$r.="<td>".$doc->a_ref()."</td>";
}
$r.="</tr>";
}
@ -909,5 +923,30 @@ class action
}
return true;
}
/*!\brief remove the action
*
*/
function remove()
{
$this->get();
// remove the key
$sql=sprintf("delete from action_gestion where ag_id=%d",$this->ag_id);
ExecSql($this->db,$sql);
// remove the ref
$sql=sprintf("update action_gestion set ag_ref_ag_id=0 where ag_ref_ag_id=%d",
$this->ag_id);
ExecSql($this->db,$sql);
// if there is a document
if ( $this->dt_id != 0 )
{
$doc=new Document($this->db,$this->dt_id);
$doc->get();
$doc->remove();
if ( strlen(trim($doc->d_lob))!=0 )
pg_lo_unlink($this->db,$doc->dt_lob);
}
}
}

View file

@ -400,7 +400,7 @@ class Document
function get()
{
$sql="select * from document where d_id=".$this->d_id;
$ret=Exec($this->db,$sql);
$ret=ExecSql($this->db,$sql);
if ( pg_num_rows($ret) == 0 )
return;
$row=pg_fetch_array($ret,0);
@ -408,7 +408,6 @@ class Document
$this->d_mimetype=$row['d_mimetype'];
$this->d_filename=$row['d_filename'];
$this->d_lob=$row['d_lob'];
$this->d_number=$row[''];
$this->d_state=$row['ag_id'];
$this->d_number=$row['d_number'];